CLAUDE.md: the file that decides how good Claude Code is
One file explains why Claude Code is brilliant on one project and mediocre on another. Seven tips to write it, keep it short, and keep it alive.
July 19, 2026 · 10 min read
You open Claude Code on one project and it understands everything on the first try. You open it on another and it reinvents your folder structure, runs the wrong test command, and suggests a library you banned six months ago. Same tool, same model, opposite results.
The difference almost never comes from the model. It comes from a text file at the root of your project.That file is CLAUDE.md. Claude Code reads it automatically at the start of every session, before you have typed anything. It is the one place where you can hand over, once and for all, what it cannot figure out by reading your code. Most people create it once, never reread it, and wonder why the agent keeps making the same mistakes.
The Claude AI Lab is my Skool community where I share my Claude systems and the more advanced modules. Access is $67/month.
Join the Lab →Anything you tell the agent more than once belongs in this file. If you are repeating it, it is not in there.
Understanding what it actually is
The starting mistake is treating CLAUDE.md as technical documentation. People dump the full architecture into it, the rationale behind every choice, the history of the project. The file swells, and its value drops.
This file is a table of contents. Its job is not to contain everything, it is to say where everything lives. Where the code sits, which commands to run, which conventions to respect, and which documents to open for the detail.
docs/api.md" beats three hundred lines of specs pasted into the file.If a new developer cannot read your CLAUDE.md in two minutes and get to work, neither can the agent.
Letting Claude write the first draft
The blank page is the real reason this file does not exist in most projects. Nobody knows where to start, so nobody starts.
You do not have to write the first version yourself. From your project root:
claude
Then, inside the session:
/init
Claude Code walks the project, picks up the stack, the scripts, the folder layout and the recurring patterns, then generates a starting CLAUDE.md from it. You go from nothing to a structured base in one command.
The agent is very good at describing what is observable in your code. That is exactly half the job. The other half, the one it cannot do, is the next tip.
Treating the output as a draft
This is where most people stop. They run /init, see a file appear, decide it is done, and move on. The result is a file that correctly describes the surface of the project and misses everything that matters.
What /init produces is a starting point, never a finished deliverable. It needs a line-by-line review.
package.json does not belong there.Maintain this file like code, not like a note. It gets reread, corrected, and committed with the rest.
What actually belongs in it
A structure that holds on just about any project, in this order.
At the end of the file, add the pointers to deeper documentation: the spec file, the contributing guide, the database schema. One line per pointer, with the exact path.
The rules. It is the one that changes the agent's behaviour session after session, and the one /init cannot generate for you.
Keeping it short, no exceptions
The tip almost everyone ignores, and the one with the most impact.
A CLAUDE.md that swells dilutes its own instructions. When a critical rule is buried in six hundred lines of context, it carries less weight in the agent's attention than it would among eighty. You do not get more compliance by writing more, you get less.
Two hundred lines is the official target, and the stated reason is exactly that trade-off: longer files eat more context and reduce adherence. Past that point, you have started pasting documentation instead of pointing to it.
docs/. The CLAUDE.md keeps one line pointing there. You can even import it explicitly with the @docs/api.md syntax, which pulls the file's content in at load time (imports chain, up to four levels deep).main" is enough. The paragraph justifying the rule can go.A short file the agent follows beats an exhaustive file it follows loosely. The most productive version is always the leanest.
Using the three memory levels
Here is the point guides on this topic almost always skip, and it completely changes how you hold the previous tip. CLAUDE.md is not a single file, it is a layered system where every level stacks.
~/.claude/CLAUDE.md. Loaded on every project you own, no exceptions. This is where your personal preferences live: your language, your response style, your security rules../CLAUDE.md at the repo root. Committed, shared with the team. Everything specific to this project.CLAUDE.md inside src/api/, for example. It carries the context specific to that part of the code without polluting the root file.The benefit is immediate: your root file no longer has to carry the rules of every sub-area of the project. You push the detail down to the level where it applies, and the root stays under your two hundred line ceiling.
The detail that makes this genuinely pay off: subfolder files are not loaded at startup. They enter the context only when the agent touches files in that folder. In other words, you can be precise and detailed in src/api/CLAUDE.md without spending a single line of context on the sessions where you are not working on the API.
The global level is what makes Claude Code consistent from one project to the next. You write your preferences once, they apply everywhere, including on projects you will open six months from now.
Maintaining it without thinking about it
A CLAUDE.md written once and then forgotten goes stale within weeks. Commands change, conventions evolve, and the file turns into a source of errors instead of a source of truth. The problem is not willpower, it is timing: nobody opens their editor to document a rule in the middle of a task.
The fix is to capture the rule at the exact moment it shows up, without leaving your session. There is nothing special to learn: ask in plain language, and the agent saves it to memory.
Remember that tests run with npm run test:unit, never with npx jest directly.
That is three seconds instead of a round trip through your editor, and it is the whole difference between a living file and a dead one.
/memory. The command lists your memory files and opens them in your editor. One cleanup pass every few weeks is enough to cut the rules that went stale.If you have not had to repeat the same instruction twice this month, your file is doing its job. If you are repeating it, you just found the next line to write.
What this file will not do for you
Two points of honesty.
The first: CLAUDE.md steers, it does not constrain. A written rule is a strong instruction, not a technical barrier. For things that must never happen, a line in a file does not replace a real safeguard on your project's side.
The second: it does not make up for an unreadable project. If your structure is incoherent and your commands are broken, describing that mess cleanly does not tidy it. The file speeds up a healthy project, it does not rescue a sick one.
Where to start
Open your most active project, run /init, and give yourself ten minutes of serious review. Cut the generic lines, add the three bans you repeat the most, and check that you are under two hundred lines.
Then build the habit that actually matters: next time you correct the agent, do not just correct it. Have the rule written down.
How good Claude Code is on your project is not a property of the model. It is a property of what you wrote for it before you started.
Want to go further?
In the Lab, I share the configs, instructions and architectures I keep refining to turn Claude into a real copilot.
A dedicated session or program, tailored to your tools and use cases.
And day-to-day, I post one reel a day on Instagram: @quentin_iamarketing