Anatomy of CLAUDE.md
Team memory, conventions, patterns, and living architecture.

The project memory and "contract" that tells Claude how your project really works.
TL;DRโ
CLAUDE.mdis a markdown file at the repo root that Claude reads first.- It encodes your stack, conventions, architecture, and guardrails.
- Keep it short (โค 300 lines), specific, and current.
- Treat it like a living onboarding doc โ for humans and the AI.
- Update it whenever a real-world decision changes.
Why this mattersโ
Think of CLAUDE.md as the employee handbook you hand to a brilliant new hire on day one. Without it, they guess. With it, they ship like a senior teammate.
Bottom line: A great
CLAUDE.mdis the single highest-leverage file in your repo.
The Big Pictureโ
Bottom line: Context flows top-down โ
CLAUDE.mdsets the tone for everything else.
Ideal Structure (sections to include)โ
| Section | Purpose |
|---|---|
| Project overview | One paragraph: what this repo is |
| Tech stack | Languages, frameworks, versions |
| Project layout | Folder responsibilities |
| Conventions | Naming, commits, style |
| Workflows & commands | How to build/test/deploy |
| Testing strategy | What "done" means |
| Security & data handling | Non-negotiables |
| Do's & don'ts | Quick guardrails |
| Integrations & MCP servers | External tools available |
| Known issues / gotchas | Save future-debug time |
| Pitfalls to avoid | Past mistakes encoded |
| Important project history | Why things are the way they are |
Step-by-Step Setupโ
1. Create the fileโ
touch CLAUDE.md
2. Drop in the skeletonโ
# Project: <your-project>
> One-line summary of what this project does.
## 1. Tech Stack
- Next.js 14 (App Router) ยท TypeScript ยท Tailwind CSS
- Supabase (Auth, Postgres, Storage)
- Prisma ORM ยท tRPC API ยท Zod validation
## 2. Project Layout
- `src/app/` โ Routes (App Router)
- `src/components/` โ Reusable UI components
- `src/services/` โ Business logic
- `src/utils/` โ Helpers & utilities
- `prisma/` โ Schema & migrations
- `tests/` โ Unit & integration tests
## 3. Conventions
- Use TypeScript strict mode.
- Prefer server components; use client only when needed.
- Use functional components & hooks.
- File names: kebab-case. Components: PascalCase.
- Export types explicitly.
## 4. Workflows
- Dev: `npm run dev`
- Build: `npm run build`
- Test: `npm test`
- MCP: GitHub, Postgres, Slack (see `.mcp.json`)
## 5. Testing
- Vitest for units; Playwright for e2e.
- Min 80% line coverage on `src/services`.
- Write tests **before** implementation.
## 6. Security
- No secrets in code or logs.
- Validate all user input with Zod.
- Parameterized queries only.
## 7. Git
- Conventional commits (`feat:`, `fix:`, `chore:`).
- Never commit directly to `main`.
- PRs require: green CI + 1 reviewer.
## 8. Known Issues
- Prisma migrations must be applied before deploy.
- Tailwind purges class names built dynamically โ use safelist.
## 9. Do / Don't
โ
Be specific and concrete.
โ
Reference docs/ for depth.
โ Don't include vague statements.
โ Don't put secrets here.
3. Commit itโ
git add CLAUDE.md && git commit -m "docs: add CLAUDE.md"
4. Iterate every sprintโ
Add one section each time you notice Claude getting something wrong.
Variants for Different Team Settingsโ
๐ค Solo developerโ
Keep it โค 100 lines. Skip "Git" rules; focus on stack + conventions.
๐ฅ Small team (2โ10)โ
Add Workflows, Testing, and Git rules. Reference docs/onboarding.md for depth.
๐ข Enterprise / regulatedโ
- Add Security, Compliance, and Data classification sections.
- Link to internal policy docs.
- Lock changes behind a code-owner review.
## Compliance
- All PRs must pass `policy-check.sh`.
- PII access requires `@security-auditor` review.
- Data residency: EU only.
๐ Open-sourceโ
- Include Contribution guide + Code of Conduct links.
- Make examples newcomer-friendly.
- Mark decisions (
[DECISION]) so contributors don't relitigate them.
Bottom line: Same skeleton, escalating depth.
Anatomy of a Single Section (zoom-in)โ
## Conventions
- **Language:** TypeScript strict mode (`"strict": true`).
- **Style:** Prettier defaults + ESLint recommended.
- **Naming:** files `kebab-case`, components `PascalCase`, vars `camelCase`.
- **Imports:** absolute paths via `@/` alias.
- **Comments:** only "why", never "what".
Notice: concrete, enforceable, terse.
Common Patterns & Recipesโ
Pattern 1 โ Reference external docsโ
> For deep architecture details, see `docs/architecture.md`.
Pattern 2 โ Encode a non-negotiableโ
> โ **NEVER** call third-party APIs without a retry + timeout wrapper.
Pattern 3 โ Few-shot a conventionโ
### Commit messages โ examples
โ
`feat(auth): add magic-link login`
โ
`fix(api): handle 429 from Stripe`
โ `update stuff`
Pattern 4 โ Decision logโ
## Decisions
- [2026-03-12] Chose tRPC over REST for type safety. (Owner: @vk)
- [2026-04-08] Adopted Prisma migrations as the source of truth.
Best Practices โ โ
- Be specific & concrete โ examples over adjectives.
- Show examples for every convention.
- Keep it concise (< 300 lines).
- Update when things change.
- Link to docs for depth instead of inlining everything.
Anti-Patterns โโ
- Vague statements ("write clean code").
- Outdated info (last edited 9 months ago).
- Secrets or tokens.
- Walls of text with no structure.
- Internal jokes nobody outside the team understands.
Troubleshootingโ
| Symptom | Cause | Fix |
|---|---|---|
| Claude ignores rules | File too long / vague | Trim to bullets, add examples |
| Wrong stack assumed | Stack section missing | Pin versions explicitly |
| Repeated mistakes | No "anti-patterns" section | Add it; cite real examples |
| Drift over time | Not updated | Add to PR checklist: "Updated CLAUDE.md?" |
| Sensitive leak risk | Secrets in file | Remove; reference env vars |
Starter Template (the bare minimum)โ
# Project: <name>
> One-line summary.
## Tech Stack
-
## Workflows
- Dev:
- Build:
- Test:
## Conventions
-
## Security
-
## Notes
-
๐ก Tip: Treat
CLAUDE.mdlike a README for Claude. Keep it living & true.
Glossaryโ
- CLAUDE.md โ Root-level memory file Claude reads first.
- Convention โ A rule the team agrees to follow consistently.
- Decision log โ A dated record of architectural choices.
- Guardrail โ A non-negotiable safety/quality rule.
Further Readingโ
- Search: "Claude Code project memory CLAUDE.md best practices"
- Search: "awesome-claude-md examples GitHub"
- Search: "AI coding agent prompt engineering for repositories"