I've been tweaking my
CLAUDE.md files for months now and I'm pretty sure I'm not doing it the "right" way, so I figured I'd share how mine work and steal your ideas in return π
I don't have one CLAUDE.md, I have a bunch of them stacked on top of each other. Claude Code loads every CLAUDE.md between $HOME and the folder you're in, so I just organised my disk around that.
- ~/.claude/CLAUDE.md for the global stuff (answer language, my notes, browser automation...)
- ~/Repositories/CLAUDE.md for how I code: TDD, atomic commits, how reviews should look
- one per git host: on github.com it's English and GFM, on my work GitLab it's French, GLFM and the right MCP server
- and the project one on top
All my clones live at $HOME/Repositories/<host>/<path>, like the URL. That's the whole trick for per-host rules, nothing fancy.
I do the exact same thing with .mcp.json. Playwright sits in my home folder, so it's everywhere. Each git host folder gets its own MCP server, and my infra and monitoring tools only show up in the infra repo. Every CLAUDE.md sits right next to the .mcp.json it goes with: one brings the tools, the other says how to use them ("use the MCP server, never the CLI"). Claude only sees the servers that make sense where I am, and tokens are all ${ENV_VARS} so the files have no secrets in them: easy-sharing, easy-syncing with no worries.
I write everything with RFC 2119 keywords (MUST, SHOULD, MAY). Sounds overkill but honestly Claude takes a MUST way more seriously than a "please try to". And the files are in English even though I want my answers in French, it works better that way.
I almost never write a rule upfront though. Claude does something dumb, I add a line, it never happens again. My favorites so far:
- "you MUST NOT resolve a thread whose feedback was not addressed just to unblock the merge". Yes, it did that π
- "if the bulk publish fails, you MUST NOT retry it". Every review comment, twice
- "you MUST NOT write praise in reviews". I got tired of "Great job on this clean refactoring! π" right before the actual problem
Two other things I learned the hard way: name the real tools instead of describing what you want, and I tell the agent what to do when it can't follow a rule ("if you fall back to the CLI, say so"). Oh and when I type "misclick" it retries the tool call I just denied by mistake. Small thing, use it every day.
What about you? One file or a cascade? What's the weirdest rule you had to add? π
GitHubGitHub Β· Change is constant. GitHub keeps you ahead. Β· GitHubJoin the world's most widely adopted, AI-powered developer platform where millions of developers, businesses, and the largest open source community build software that advances humanity.
3 other commits about this linkcommit e165d2a
TL;DR how I do my CLAUDE.md, curious about yours π
- a cascade, not one file: global, coding, per git host, per project
- same for .mcp.json, each next to its CLAUDE.md. Tools on one side, rules on the other
- RFC 2119 keywords: a MUST beats a "please try to"
- every rule comesβ¦