Writing a good Claude.md
TL;DR Highlight
Keeping CLAUDE.md short and moving details elsewhere makes Claude ignore fewer instructions
Who Should Read
A developer who keeps adding rules to CLAUDE.md but finds Claude Code ignoring them
Core Mechanics
- CLAUDE.md is an onboarding doc
- The agent knows nothing about your codebase at the start of every session.
- The post says to cover WHAT (stack, structure), WHY (purpose), and HOW (how to work and verify).
- In a monorepo, give a map of apps and shared packages.
- Claude skips what it deems irrelevant
- Claude Code attaches CLAUDE.md with a system-reminder saying to ignore it unless highly relevant.
- The more non-universal instructions you add, the more likely it is ignored.
- You can verify this with a logging proxy via ANTHROPIC_BASE_URL.
- Fewer instructions work better
- Frontier thinking models follow roughly 150-200 instructions with reasonable consistency, per the post.
- Smaller models decay exponentially as instructions grow, while large thinking models decay linearly.
- Claude Code's system prompt alone has about 50 instructions.
- The author admits this research is not rigorous.
- Stay under 300 lines, shorter is better
- Anthropic has no official length guidance, and under 300 lines is the general consensus.
- HumanLayer's root CLAUDE.md is under 60 lines.
- Leave out task-specific things like database schema rules.
- Move details to separate md files
- Put files like building_the_project.md and running_tests.md under agent_docs/.
- CLAUDE.md lists them with one-line descriptions and Claude reads only the relevant ones.
- Use file:line pointers instead of copied code snippets.
- Don't send an LLM to do a linter's job
- Style rules add instructions and eat context, hurting performance.
- Use a Stop hook to run your formatter and linter and pass errors to Claude.
- The post likes Biome for auto-fixing.
- Don't auto-generate with /init
- CLAUDE.md affects every session and every phase, so it is the highest-leverage point.
- One bad line can spread into bad plans and bad code.
- Write each line deliberately.
Community Reactions
- Commenters check adherence with a canary
- One commenter's friend has Claude always call him "Mr Tinkleberry" and knows it's drifting when it stops.
- Another commenter also sets a specific form of address to detect inattention.
- Opinion that the codebase itself should be the CLAUDE.md
- One commenter automates lint, typecheck, and tests and tells Claude to run them before finishing.
- They found adding a lint rule or test works better than tweaking CLAUDE.md when Claude repeats a mistake.
- Pushback on separate md files vs nested CLAUDE.md
- A commenter notes Anthropic's docs recommend CLAUDE.md files in subdirectories.
- Child-directory CLAUDE.md files load on demand when working on files there.
- They worry arbitrarily named md files may not stand out to Claude.
- Experience that CLAUDE.md barely works
- One user said adding a rule like a 50-line method limit and using Claude for 10 minutes showed it breaking the rule repeatedly.
- Another resets context and re-pastes instructions manually.
- Another commenter said giving the LLM code without comments gives better quality on hard problems.
How to Apply
- Audit your CLAUDE.md instruction by instruction
- Open your current CLAUDE.md and mark instructions that don't apply to every task.
- Delete style rules and task-specific instructions or move them to separate md files.
- Paste the prompt below into Claude to help classify them.
- Split details into an agent_docs/ folder
- Move build, test, and DB schema notes into md files under agent_docs/.
- Leave only filenames and one-line descriptions in CLAUDE.md, and tell Claude to read only the relevant ones.
- Use file:line references instead of copied code.
- Move style rules into formatter/linter hooks
- Delete code style text from CLAUDE.md.
- Run your formatter and linter in a Stop hook and feed errors to Claude.
- Enable auto-fixable linter rules first.
- Trim the root CLAUDE.md to 60-300 lines
- Keep only WHAT, WHY, and HOW.
- If it exceeds 300 lines, split with progressive disclosure.
Try It
# Paste into Claude or Claude Code (simple audit prompt based on the post's guidance)
Below is my CLAUDE.md. Audit it with these criteria.
1. Keep only instructions that apply to every task, and mark task-specific ones as candidates to move into separate md files.
2. Mark code style rules as candidates to replace with a linter or formatter.
3. Rewrite what remains into three sections, WHAT (stack, structure) / WHY (purpose) / HOW (build, test, verify), in under 60 lines.
4. Propose filenames and one-line descriptions for what moves into agent_docs/.
5. Tell it to use file:line references instead of copying code snippets.
{{CLAUDE.md content}}Terminology
Related Papers
Frostbite: A new CPU architecture discovered, designed and verified by AI
AI agents designed a CPU from scratch, claiming 4.59x perf/W over a traditional core
Restricting AI agents in mobile operating systems platforms from capturing data
Signal now blocks OS-level AI agents from reading its screen on iOS 27 and Android
Actions Speak Louder than Words: Stateful Privacy Sniffing of LLM Agents via Behavioral Covert Channels in Web Interactions
Agents' link choices alone let attackers rebuild user queries at F1 0.89; SOR cuts it to 0.39.
Tracking and Limiting Unsupported Claim Propagation in Multi-Agent LLM Systems: A Provenance-Aware Framework
Passing claims with source, evidence and history kept equivalence at 5 agent stages at 96% versus 31%.
LLM assisted reverse engineering
Pointing an agent at binaries with skills and MD notes made years-long hacks feasible
Metrics-in-the-Loop: Complexity Feedback Reshapes Agent-Written Code
Injecting per-turn complexity reports into coding agents cut code erosion without changing correctness
Why is Gemini 4 Carbon taking so long?
Carbon took nearly an hour on bug fixes that Astra and Opus finished in minutes, mostly from extra unrequested work.
Weight-Space Programming builds neural networks like a 1990s researcher
LLM hand-wrote MNIST weights to 91.3%, using 1990s-style techniques