The single most useful thing in a CLAUDE.md. Clear any you don't have.
One per line, as path - purpose.
Things Claude would not guess. One per line.
# Project
## Stack
TypeScript, Next.js, Tailwind CSS
## Commands
- Dev server: `pnpm dev`
- Build: `pnpm build`
- Test: `pnpm test`
- Single test: `pnpm test path/to/file.test.ts`
- Lint: `pnpm lint`
- Type check: `pnpm tsc --noEmit`
## Layout
- `app/`: routes and pages
- `components/`: shared UI
- `lib/`: data access and helpers
## Code style
- Prefer small, focused functions and early returns
- Match the style of the surrounding code over personal preference
## Rules
- Run the tests and the type checker before saying a task is done
- Ask before adding a new dependency
- Never commit secrets, `.env` files or credentials
- Keep changes focused: no unrelated refactors in the same change
What makes a CLAUDE.md work
- Commands first. The exact command to run one test saves Claude more time than any style rule.
- Specific beats general. "Use
pnpm, nevernpm" works; "write clean code" does nothing. - Hard rules belong in settings. CLAUDE.md is guidance. To actually block something, use a deny rule or a hook.
- Keep it current. When Claude makes the same mistake twice, add one line.
Where the files go: ./CLAUDE.md for the team, ./CLAUDE.local.md for your own notes (keep it out of git), and ~/.claude/CLAUDE.md for preferences across every project. See the cheat sheet for the other files Claude Code reads.
Frequently asked questions
What is CLAUDE.md?
CLAUDE.md is a Markdown file of instructions that Claude Code loads into every session for a project: how to build and test it, the conventions to follow and the gotchas to avoid. Put it in the repo root and commit it so your whole team benefits.
What should I put in CLAUDE.md?
Things Claude cannot work out by reading the code: exact build, test and lint commands, how to run a single test, where things live, code style rules you enforce, and traps such as "the e2e tests need the database running". Leave out anything a linter already enforces or that is obvious from the code.
How long should CLAUDE.md be?
Short. Anthropic recommends under 200 lines per file, because a longer file uses more context and Claude follows it less reliably. Move instructions that only matter for part of the codebase into .claude/rules/ files scoped to those paths.
Is /init better than a generator?
Use both. /init reads your repo and drafts a CLAUDE.md from what it finds. This generator is useful when you want to decide the rules yourself, start a new project, or standardise the format across repos. Merge the two and trim.
Does Claude Code read AGENTS.md?
Yes. Recent versions read AGENTS.md when a repo has no CLAUDE.md. If you have both, it reads CLAUDE.md only, so the usual setup is to keep shared instructions in AGENTS.md and put a one-line @AGENTS.md import in CLAUDE.md.
Sources: Claude Code memory and CLAUDE.md, Best practices. Claude Code Agents is an independent site, not affiliated with Anthropic.