CLAUDE.md Best Practices
Write system instructions that make Claude Code work the way you want.
Overview
CLAUDE.md is your persistent context file. Put it in the project root. Include: tech stack, conventions, boundaries. Keep it under 500 lines. Update it when Claude makes repeated mistakes. This guide is the practical companion to AOL 2 - Aware.
What CLAUDE.md does
Claude Code reads CLAUDE.md at the start of every session. It is system-level context that shapes all of Claude's responses for your project. The agent knows where it is and what the rules are before the first message.
- What the project is and what it does
- How to run, build, and test the project
- The main technologies and frameworks used
- Rules the agent must follow - naming, patterns, what not to touch
- Project folder structure with short explanation
- Links to key /docs files the agent should read first
- Recurring corrections - mistakes Claude kept making that you fixed
- Everything at once - keep it focused
- Outdated information - a wrong map is worse than no map
- Repeating what Claude can already see in your code
The three-layer strategy
One CLAUDE.md is a start. Three layers is structured intelligence. Each layer loads only where it is needed.
Traffic Controller pattern
Use CLAUDE.md as a navigation map, not a copy of your docs. Claude fetches only what it needs, when it needs it - keeping the main context lean and focused:
## Documentation Map
For API rules: @docs/api/contracts.md
For UI rules: @docs/design/design-system.md
For business constraints: @docs/business/rules.md
Rule: if it is documented, read it. Do not guess. package.json. Tailwind is visible in the config. Writing it again wastes tokens and creates drift when things move.Patterns that work
These three patterns cover most of what makes a CLAUDE.md effective. Each one addresses a common failure mode - vague descriptions, missing boundaries, and repeated corrections.
Reference files
Point Claude to examples rather than describing patterns in prose:
## Reference Files
When creating components, follow the patterns in:
- src/lib/components/ui/Button.svelte (props structure)
- src/lib/components/hub/HubNavCard.svelte (styling approach) Boundaries
Explicit rules are more reliable than implicit expectations. Tell the agent what it must never do - and what it must always do:
## Boundaries
### Do NOT
- Modify package.json without asking
- Change the build configuration
- Touch .env or credentials files
- Refactor code I did not ask about
### Always
- Run tests after changes
- Use existing design tokens
- Follow the patterns in similar files Common fixes
Document recurring corrections once, so you stop repeating them in every session:
## Common Mistakes to Avoid
- Do not use $app/stores - use $app/state for Svelte 5
- Do not add comments unless the logic is non-obvious
- Do not create new utility files for one-off functions Anti-patterns
Most CLAUDE.md files fail in one of these four ways. The result is always the same - the agent ignores the file, contradicts it, or uses it as a source of false confidence.
Iteration process
CLAUDE.md is not a setup task - it is a living document. The best version is never the first version. Build it by working with the agent, not before.
Treat CLAUDE.md like code. Every repeated correction is a signal that the file needs updating. Every answered question that reappears is a missing rule.
To get started faster, download the ABA starter files and let Claude set up or improve your project from them. See Downloads for the files and the setup prompt.