CLAUDE.md works as a memory file that Claude Code reads before it answers anything: its contents are pulled into the session's context alongside your prompt and the files the agent opens, so the model treats them as standing instructions rather than as a document you happened to leave in the repo. Everything in it is paid for on every turn.
That one sentence explains most of the confusion around the file. Where it goes, what belongs in it, whether subfolders need their own copy, why the agent still ignores the line you wrote in capital letters. The answers matter less than the consequence. A file built to save you repetition became the most expensive paragraph in your repository.
I work on HarnessUp, a toolkit that measures where Claude Code and Codex actually burn tokens on your machine, and CLAUDE.md is one of the first places the waste shows up. The files are usually fine. The problem is that they never stop being read. If you have read about why Claude Code rereads the same file, you know the pattern already: the cost hides in the part that repeats.
What does CLAUDE.md actually do when a session starts?
It injects your standing instructions into the model's context before your first request is processed, and they stay there for the whole session, competing with your code, your errors and your actual question. Claude Code does not consult the file later the way you consult a style guide. There is no later. The text is already in the room.
You can let the agent write a first version with the init command, and most people do. That is where the trouble starts, because the generated file is a description of the repository, and a description of the repository is something the agent can read for itself. Paying to be told what sits in the folder you just opened is a strange transaction.
The layout is more sensible than the folklore suggests. A file at the project root applies to the whole repo. A user-level file in your home configuration applies to everything you do, on every project, forever. Nested files in subdirectories get pulled in when the agent works in those directories. Imports let you reference other files so the main one stays short, which sounds like housekeeping and is really a way to hide how much you are loading.
Here is the part that surprises people arriving from other tools.
Nothing in that file is enforced.
It is a prompt, not a configuration. Write that the agent must never touch the migrations folder and it may still touch the migrations folder, because a markdown sentence cannot stop a tool call. A test can. A linter can. A permission rule can. The file can only ask nicely, and it asks nicely in every single turn.
One detail bites harder than the rest. Edit the file in the middle of a session and the agent may keep working from the version it loaded at the start. The next turn does not reread your correction, so you spend an hour convinced the model is stubborn when it is simply holding an older copy of your instructions. Start a fresh session and the new lines take effect.
Why does a more thorough CLAUDE.md make the agent worse?
Because attention inside a context window is finite and the file spends it before the work begins. Every rule, every architecture note, every line about which package manager to use sits in front of the actual problem. A model holding forty instructions while reading a stack trace is a model with less room for the stack trace.
Watch what happens over a month. Someone hits a bug caused by a stale import, so a line goes in. Someone else gets a test file written in the wrong style, so another line goes in. Nobody removes one, because removing a rule feels like inviting the bug back. The file thickens like scar tissue, one bad afternoon at a time.
The rule you wrote after one bad Tuesday
Most lines in a mature CLAUDE.md are not knowledge. They are damage. They are the residue of a specific failure that happened once, in a specific file, for a reason nobody wrote down. The rule outlives the reason, and then it applies to every task that follows, including the thousands where it is irrelevant.
There is a second-order effect almost nobody counts. Rules contradict each other. Always write tests, keep changes minimal, match the existing style. Those three cannot all win in the same pull request, so the model picks, and it picks differently depending on what else is in the window that day. You did not buy reliability. You bought a small internal parliament.
Length also changes the shape of the answers. A file full of prohibitions produces an agent that hedges, asks permission, and explains what it is about to do before doing it. You wrote forty sentences about caution, then wondered why the thing opened every reply with a summary of its own plan.
None of this means the file is useless.
It means the file is not free.

Who is the file really written for?
Mostly for a colleague who will never read it and a reviewer who skims it, while the entity that actually reads it gets a briefing written for a different species: a model with no memory of yesterday, no way to ask a follow-up question, and a meter running on every word. Half the file is onboarding notes, a fine thing to write and a poor thing to load on every turn. The other half is an apology for decisions the team never documented anywhere else, written by someone who assumed a reader with patience and a memory.
That mismatch explains the odd tone of these files. They are written in the imperative, as if volume created obligation. They explain conventions the code already demonstrates. They describe the folder structure the agent will list in its first move anyway. You are paying for a guided tour of a building the agent is standing in.
The quiet winner is the developer with the shortest file. Not because they care less, but because they moved the enforceable parts to places where enforcement exists. Formatting lives in the formatter. Types live in the compiler. Forbidden commands live in permissions. What remains in the markdown is the small set of things a machine cannot infer and a test cannot catch: why the billing module is shaped that way, which service is deprecated but still called, the naming decision that looks wrong until you know the history.
There is a social cost too. Once the file lives in the repo, it gets reviewed like code, and adding a line becomes the cheapest way to end an argument in a pull request. Two engineers disagree about naming, one appends a rule, the discussion closes.
The file remembers what the team agreed to forget.
If you have read about what to carry into your next Claude Code session, this is the same discipline pointed inward. Context handed over on purpose beats context that accumulates by accident.
How do you write a CLAUDE.md that earns its tokens?
Treat it as a short briefing where every line must survive one test: could the agent learn this by reading the code, running a command, or hitting a test? If yes, delete it. Keep the history, the traps and the decisions, then reread the file once a month and cut it back to what still earns its place.
That sounds like editing. It is closer to bookkeeping, and the ledger has two columns.
| Line you are tempted to write | Where it actually belongs |
|---|---|
| Always run the formatter | A pre-commit hook |
| Never touch the migrations folder | A permission rule |
| Use the Button component, not raw HTML | A lint rule, or one example |
| Deploys freeze on Fridays | CI, plus a line in the file |
The habit generalizes. If you want the wider version of the same discipline, the guide to cutting token usage in Claude Code without making the agent stupid covers the rest of the window.
Start with measurement rather than opinion. Cut the file in half, run a normal week, and watch whether the agent gets dumber or just quieter. If something breaks, you have learned which line was load-bearing, and you can put that one line back with a note explaining why. That is a shorter file with better reasons, and it costs a fraction of what you were paying.
If it goes wrong the other way, if the agent starts ignoring conventions it used to follow, resist the urge to paste the old file back in full. Find the one convention that mattered and show it as a snippet instead of describing it as a command. Three lines of the pattern you want beat a paragraph about the pattern, and they take up far less of the window on every turn that follows.
The file is a bill.
Read it like one.