What Is CLAUDE.md, and What Should You Put in It?
Published:
CLAUDE.md is a plain text file of standing instructions that Claude Code reads at the start of every session. Claude starts each session with a blank slate, so this file is how it already knows your test command, your naming habits and the folder it should never touch. Write a rule once and you stop typing the same correction. It only works if the file stays short and specific. Below: what goes in it, where it lives, and a starter to copy.
What CLAUDE.md is
It is an ordinary markdown file that you write and Claude reads. Anthropic’s docs describe two things that carry knowledge from one session to the next. One is the CLAUDE.md files you write. The other is “auto memory”, notes Claude writes for itself based on your corrections. This article is about the first one.
One honest limit first: Claude treats CLAUDE.md as context, not as enforced configuration. It is not the system prompt either: the docs say it arrives as a user message after the system prompt. So Claude usually follows it, but nothing guarantees it. For a rule that must hold every time, like blocking a risky command, the docs point you to a hook instead.
Where it lives
The docs list four places, from widest to narrowest:
- Your whole organization. IT can deploy a managed CLAUDE.md to every machine. You will rarely write this one yourself.
- You, in every project.
~/.claude/CLAUDE.mdholds your personal habits, like your preferred code style. - The project, shared with the team.
./CLAUDE.mdor./.claude/CLAUDE.md. This is the one most people mean. - You, in one project only.
./CLAUDE.local.mdis for things like your own test data or sandbox URLs. Add it to.gitignoreso it stays off the team’s repo.
Claude also reads the CLAUDE.md files in the folders above the one you launched it from, and it picks up one inside a subfolder once it starts working on files there. To check what loaded, type /context and look under “Memory files”.
What to put in it, and what to leave out
The docs’ test is simple: write down what you would otherwise re-explain. Add a line when Claude makes the same mistake twice, when a code review catches something Claude should have known, or when a new teammate would need the same context.
Put in:
- Commands. How to build, run the tests and start the app.
- Conventions that differ from the default. “Use 2-space indentation” works. “Format code properly” does not.
- The few places that are not obvious. “API handlers live in
src/api/handlers/” beats “keep files organized”. - Always-do rules. “Run
npm testbefore committing.” - Gotchas. The odd thing in your project that has already cost you an afternoon.
Leave out:
- A full tour of the codebase, like every folder or dependency. Claude can work those out from the code, and Claude Code’s
/doctorcheckup proposes cutting exactly that kind of content. Keep only the non-obvious bits. - Multi-step procedures. Those belong in a skill.
- Rules for one corner of the project. Those belong in a path-scoped rule, which loads only when Claude touches matching files.
- Secrets. Never paste a password or key into a file that gets committed.
- Rules that contradict each other. Per the docs, Claude may pick one arbitrarily.
A starter CLAUDE.md to copy
Swap the details for your own project, and delete any line you cannot fill in honestly.
# Project notes
## Commands
- Install: npm install
- Run the app: npm run dev
- Test: npm test (run it before every commit)
## Where things live
- Pages live in src/pages/
- Shared components live in src/components/
- Do not edit anything in dist/ (it is generated)
## Conventions
- 2-space indentation, single quotes
- Name components in PascalCase, everything else in camelCase
- Write commit messages in the present tense, under 60 characters
## Watch out for
- The test database resets at midnight, so do not rely on saved test data
- Ask me before adding a new dependency
If you would rather not start from blank, type /init and let Claude draft one from your code, then cut and sharpen it. You can also type /memory to open your memory files from inside a session, and /doctor prompt-audit on recent versions asks Claude to flag outdated or conflicting instructions.
CLAUDE.md vs skills vs custom instructions
All three tell an AI how you like to work. They differ in when the AI sees them.
| Loads | Best for | |
|---|---|---|
| CLAUDE.md | Every session | Short facts: commands, conventions, layout |
| A skill | Only when used | A procedure or long reference you need sometimes |
| Custom instructions | Every chat in an app | Personal preferences in a chat tool, no project needed |
The docs give a clean rule for the first two: when a section of CLAUDE.md has grown into a procedure instead of a fact, turn it into a skill, because a skill’s body loads only when it is used. If you are unsure which of the extension types you need, our guide to skills vs subagents vs MCP walks through the choice.
What about AGENTS.md?
AGENTS.md is the same idea under a different name, used by other tools. Cursor and Codex both read it, and so does Claude Code, with one rule: on recent versions Claude reads AGENTS.md by default only when there is no CLAUDE.md (or CLAUDE.local.md) in your working folder or above it. If your repo already has an AGENTS.md and you want Claude to follow it alongside a CLAUDE.md, put @AGENTS.md on the first line of CLAUDE.md. On Windows, prefer that import over a symlink, because a symlink can check out as a one-line text file.
Keep it short
Every line in CLAUDE.md is read at the start of every session, so every line costs tokens in your context window each time. Anthropic’s docs suggest staying under 200 lines per file. Longer files use more context and Claude follows them less closely.
Splitting a long file with @path imports helps you stay organized, but it does not save anything: imported files load along with the file that imports them. To actually shrink it, cut lines, or move them into path-scoped rules and skills. More habits like this are in our guide to cutting Claude Code token usage.
One more tip from the docs: block-level HTML comments in CLAUDE.md are stripped before Claude sees it, so you can leave notes for teammates without spending any tokens.
Start small
A short CLAUDE.md is quick to write and spares you the same correction every session. Pair it with committing before you prompt so any mistake is easy to undo. If you are still choosing a tool, our free AI for Coders helps you pick an assistant, install it for your system and start with a lean rules file. Then grow the file one hard-won lesson at a time.
Keep reading
Frequent questions
Does Claude Code create CLAUDE.md for me? +
It can. Type /init in a session and Claude reads your codebase, then writes a starting CLAUDE.md with the build commands, test steps and conventions it finds. If you already have one, /init suggests improvements instead of overwriting it. Treat the result as a first draft and add what Claude could not work out alone, like the mistakes it keeps making.
Should I commit CLAUDE.md to git? +
Yes for the project file (./CLAUDE.md or ./.claude/CLAUDE.md). The docs describe it as team-shared instructions that travel through source control, so everyone who works on the repo gets the same rules. Keep personal preferences in ./CLAUDE.local.md and add that file to .gitignore. Either way, never put passwords or API keys in a CLAUDE.md.
Do Cursor or Codex read CLAUDE.md? +
Their docs name AGENTS.md, not CLAUDE.md. Cursor says it supports AGENTS.md in the project root and subdirectories, and Codex reads AGENTS.md files before doing any work. Recent versions of Claude Code read AGENTS.md too, but by default only when there is no CLAUDE.md or CLAUDE.local.md in your working folder or above it. To share one file across tools, put a line that says @AGENTS.md at the top of CLAUDE.md.
How long should a CLAUDE.md be? +
Anthropic's docs suggest under 200 lines per file. Longer files use more context and Claude follows them less reliably. If yours is growing, move the rules that only matter for one folder into path-scoped rules, and move step-by-step procedures into skills.