Why standing instructions matter
Anthropic's documentation says each Claude Code session begins with a fresh context window. Whatever you explained yesterday, how to run the tests, which folder holds the API code, that you prefer small functions, is gone unless it is written down somewhere Claude Code reads.
That place is CLAUDE.md. Anthropic describes CLAUDE.md files as markdown files that give Claude persistent instructions for a project, your personal workflow or your whole organisation, written in plain text and read at the start of every session. If your repository already uses a file called AGENTS.md for other coding tools, the docs say Claude Code can read that instead.
Think of it as the note you would leave a capable new colleague on their first day: the few facts and rules they need to avoid wasting time or breaking things.
Where the file goes
Anthropic's memory page lists several locations, each with a different scope. The ones most people use:
- Project instructions: ./CLAUDE.md or ./.claude/CLAUDE.md in your project. Shared with your team through version control. For build commands, coding standards, architecture notes and common workflows.
- Your personal instructions for every project: ~/.claude/CLAUDE.md in your home folder. For your own preferences.
- Personal instructions for one project: ./CLAUDE.local.md at the project root, which the docs say you should add to .gitignore so it is not committed. For things like your local test data or sandbox addresses.
Organisations can also set managed instructions for everyone, which the docs describe for IT and DevOps teams.
Getting started: let it draft the first version
You do not have to write the file from scratch. Anthropic's docs say that running /init in a session generates a starting CLAUDE.md: Claude analyses the codebase and writes build commands, test instructions and conventions it discovers. If a CLAUDE.md already exists, the docs say /init suggests improvements rather than overwriting it.
Treat that draft as a first pass. Read it, delete anything wrong or obvious, and add the things Claude could not discover by reading the code: decisions, preferences and warnings that live in people's heads.
What to put in it
Anthropic's guidance is to keep it to facts Claude should hold in every session: build commands, conventions, project layout and "always do X" rules. It suggests adding to CLAUDE.md when:
- Claude makes the same mistake a second time.
- A code review catches something Claude should have known about the codebase.
- You type the same correction you typed last session.
- A new teammate would need the same context to be productive.
That last test is a good one. If you would tell a new person, write it down.
A small example
Here is an original example for a small web project. Notice that every line is something you could check.
# Project notes
## Commands
- Install: npm install
- Run locally: npm run dev
- Run tests: npm test (run before every commit)
## Layout
- Pages are in src/pages/, one file per page
- Shared components are in src/components/
- API calls go through src/lib/api.ts only
## Rules
- Use TypeScript, no plain .js files in src/
- Keep components under 150 lines; split if longer
- Never edit files in public/vendor/ (third-party code)
- Ask before adding a new dependencyThe commands, folders and rules here are placeholders for your project's real ones. Do not copy them as they are.
How to write instructions it follows
Anthropic's docs say Claude treats CLAUDE.md as context, not enforced configuration, so how you write instructions affects how reliably they are followed. Their advice, in summary:
- Be concrete enough to verify. The docs contrast "Use 2-space indentation" with "Format code properly", and "Run npm test before committing" with "Test your changes".
- Keep it short. The docs suggest targeting under 200 lines per CLAUDE.md file, because longer files use more context and are followed less reliably.
- Use structure. Group related instructions under headings and bullets, which the docs say are easier to follow than dense paragraphs.
- Keep it consistent. If two instructions contradict each other, the docs say Claude may pick one arbitrarily. Review the file now and then and remove outdated rules.
Our own addition: keep it true. A CLAUDE.md that describes a test command you removed months ago does more harm than having none, because it confidently points Claude in the wrong direction.
When the file grows
As a project grows, so does the temptation to put everything in one file. Anthropic's docs describe two ways to keep things organised.
- Imports. A CLAUDE.md can pull in other files using @path/to/file syntax, for example pointing to your README or a workflow document. The docs note that imports help organise a long file but do not reduce how much context it uses, because imported files load along with it.
- Rules for parts of the codebase. The docs describe a .claude/rules/ folder for topic-specific instruction files, which can be scoped to particular file paths so they load only when Claude works with matching files. Instructions that only matter for, say, your database code can live there instead of in the main file.
For a small project, one short CLAUDE.md is plenty. Reach for these only when the main file starts creeping past what you can read in a minute.
When an instruction seems ignored
If Claude Code keeps ignoring something in your CLAUDE.md, check these before rewriting everything:
- Is the instruction concrete and checkable, or vague?
- Does another instruction, in this file or another one, contradict it?
- Is the file long enough that the rule gets lost? Trim it.
- Did you give the instruction only in conversation? Anthropic's docs say the project-root CLAUDE.md is re-read after the /compact step that shrinks a long session, but instructions given only in chat may not survive it. Put lasting rules in the file.
It is not a lock
Because CLAUDE.md is guidance, not a hard rule, do not rely on it for anything that must never happen. Anthropic's memory page says that to block an action regardless of what Claude decides, you should use a hook, and it points to managed settings for blocking specific tools, commands or file paths. "Never touch the production database" belongs in permissions and settings, not only in a polite sentence.
Better requests
CLAUDE.md handles what is always true. Each task still needs a clear request. Anthropic's quickstart gives three tips that match the prompting lessons on this site.
Be specific. The quickstart contrasts "fix the bug" with "fix the login bug where users see a blank screen after entering wrong credentials". Say what is wrong, where you see it and what "fixed" means.
make the search better
Search on the products page is case-sensitive, so "Lamp" finds results but "lamp" doesn't. Make search case-insensitive, keep the existing behaviour otherwise, and add a test for both spellings.
Use steps for complex tasks. The quickstart shows breaking a feature into numbered steps: create a table, then an API endpoint, then a page. Steps give you natural points to review.
Let it explore first. The quickstart suggests asking it to analyse something, such as the database schema, before asking for changes. Understanding first, then planning, then editing catches misunderstandings while they are still cheap.
Read the code that sends order confirmation emails and explain how it works, including which files are involved. Then propose how to add the delivery date to the email. Don't change anything until I approve the plan.
Review like a colleague's work
However good the instructions and requests, review the result the way you would review a capable colleague's pull request. Read the diff. Run the tests yourself. Ask "why did you change this file?" when something looks unrelated. Push back when a change is bigger than the task needed.
When you find yourself correcting the same thing twice, that is your cue to update CLAUDE.md. Over time, the file becomes a record of how your project actually works, and the first attempts get noticeably closer.
Common mistakes
- Writing an essay. A long file full of general advice is followed less reliably. Keep it to what is specific to this project.
- Leaving it stale. Update it when commands, folders or conventions change.
- Putting secrets in it. Project CLAUDE.md files are shared through version control. Never put passwords, keys or tokens in them.
- Using it as a security control. Use permissions, settings and hooks for anything that must be enforced.
- Putting one-off task details in it. Those belong in the request for that task.
Try it
- In a project, run /init and read the CLAUDE.md it drafts.
- Delete anything wrong or obvious. Add three things only you know: a rule, a warning and a preference.
- Start a new session and give it a small task that should follow one of your rules. Check that it does.
- Next time you correct it twice on the same thing, add that to the file.
Questions people ask
How do I know the file was loaded?
Anthropic's memory page says you can run /context all in a session and check the list under Memory files.
What is auto memory?
The docs describe it as notes Claude writes itself based on your corrections and preferences, as opposed to CLAUDE.md, which you write. The memory page explains how to configure it.
Should CLAUDE.md be committed to Git?
The project file is meant to be shared with your team through version control, according to the docs. Personal preferences go in CLAUDE.local.md, which you keep out of Git, or in your home-folder file.
Sources: Claude Code docs: How Claude remembers your project · Claude Code docs: Quickstart · Claude Code docs: Overview