Why Does Your Claude Often Get “Confused” When Starting a New Project?
If you frequently use Claude Code or Claude Projects for refactoring, you’re likely familiar with this scenario. With every new session, the AI asks obvious questions: “What framework does the project use?”, “Where are the test commands?”. Worse, it might write code in its own style, breaking the team’s established standards.
Instead of getting frustrated, use CLAUDE.md. This isn’t documentation for humans but a configuration file designed to guide the AI’s reasoning. In practice, having this file helps Claude grasp context faster and reduces silly coding style errors by up to 90%.
The Difference Between README.md and CLAUDE.md
Many wonder why the AI can’t just read the README.md. The issue lies in the intended purpose:
- README.md: For humans. It’s full of badges, flowery introductions, and environment setup guides. AI has to filter out about 60-70% of redundant content to find build commands, wasting tokens.
- CLAUDE.md: Contains only the technical “backbone.” It focuses on execution commands, directory structures, and specific rules that the AI needs to follow immediately.
Practical Efficiency Comparison
| Criteria | Traditional Method (README) | Modern Method (CLAUDE.md) |
|---|---|---|
| Token Usage | Usually > 2,000 tokens | Usually < 500 tokens |
| Time to get started | Takes 2-3 chat turns to understand | From the very first command |
| Style Accuracy | 50/50 (Easily distracted) | Nearly absolute |
Key Benefits of Implementing CLAUDE.md
After applying this to projects of all sizes, I’ve identified two key advantages:
First is cost efficiency. Consolidating core information into one file prevents Claude from having to scan the entire codebase, significantly reducing input tokens. Second is behavior control. You can force the AI to never use an outdated library or mandate that it always writes Unit Tests after modifying logic.
The Standard CLAUDE.md File Structure
Create a CLAUDE.md file in your project’s root directory. An effective file typically consists of these three main sections.
1. Execution Commands (Build & Development)
This section tells Claude exactly which commands to run when you ask it to debug or build the project.
## Build and Development
- Install: `npm install`
- Dev server: `npm run dev`
- Build: `npm run build`
- Test: `npm test`
- Lint: `npm run lint`
2. Coding Rules (Code Style & Patterns)
Don’t let the AI innovate freely. Confine it to your team’s standards. For example, if you use Tailwind, forbid it from writing raw CSS.
## Code Style Patterns
- Use TypeScript for all logic; no `any` allowed.
- Prefer functional components and hooks.
- Styling: Use Tailwind CSS only; avoid inline styles.
- Error handling: Wrap async calls in try-catch using `logger.error()`.
3. Structure and Tech Stack
Help Claude quickly locate the files it needs to modify without searching the entire drive.
## Tech Stack
- Next.js 14 (App Router), Prisma, Zustand
## Key Directories
- `/src/components/ui`: Shadcn components
- `/src/hooks`: Custom React hooks
- `/src/lib`: API clients and utils
Tips to Upgrade CLAUDE.md into a “Senior Assistant”
To truly unlock the power of this file, you should apply the following techniques:
Establish an Anti-patterns list: Clearly state what you dislike. For example: “Strictly forbid the use of ‘any’ type. Use ‘unknown’ if necessary.” Claude will follow this more strictly than any junior developer.
Update after every major task: When you change the architecture—for example, switching from Redux to React Query—tell Claude: “Update CLAUDE.md to reflect our new state management.” This ensures future sessions don’t rely on outdated knowledge.
Leverage Claude Code (CLI): Anthropic’s new CLI tool automatically reads this file upon startup. You’ll notice much faster response times because the AI already has the context in mind.
Here is a practical example for a Python/FastAPI project:
# CLAUDE.md for FastAPI
## Commands
- Dev: `uvicorn main:app --reload`
- Test: `pytest`
## Standards
- Use Pydantic v2 for models.
- Async/Await for all DB operations.
- Follow PEP 8 strictly.
Conclusion
Spending 5 minutes writing a CLAUDE.md will save you hours of explanation and bug-fixing later. It’s like giving a map to a skilled driver; instead of directing every turn, you can just sit back and enjoy the results. Try creating this file for your current project and you’ll see Claude become noticeably “smarter”!

