← All guides
claude md best practices

Claude MD Best Practices: What to Keep, Cut and Move

8 min read

Claude md best practices from four sources: the instruction budget, a line-count target, a cut test, and where to move what stays out of CLAUDE.md.

Claude MD Best Practices: What to Keep, Cut and Move
On this page

Treat CLAUDE.md as a scarce instruction budget, not a notes file. These claude md best practices come down to one rule: frontier LLMs follow roughly 150-200 instructions with reasonable consistency (humanlayer.dev), and Claude Code's own system prompt already uses about 50 of them, so every line you add competes with the rest. Keep the file short, cut any line that fails the remove-it test, and move everything else into imports, rules, skills or hooks.

Prerequisites

  • Claude Code installed and working in your project root.
  • An existing CLAUDE.md (hand-written or from /init) that you are willing to edit.
  • A git repository, so you can compare before and after.

What should a CLAUDE.md actually contain?

CLAUDE.md is the only file that by default goes into every conversation with the agent (humanlayer.dev). That is why it is worth writing carefully, and why it should hold only what applies to nearly every task.

Cover three things: the what (stack and project structure), the why (the project's purpose), and the how (how to work on it and verify changes). For the how, write down the exact commands and their arguments. A Dometrain 2026 guide notes that documenting commands stops the AI from hallucinating flags or running nonexistent commands (dometrain.com). Name the directory each command runs in, too, since that reduces wrong-directory errors. If Claude commits, add branch naming and commit message conventions.

Step 1. Write a draft with one short block each for what, why and how. Expected result: a file where a new teammate could find the test command and the verification step in seconds.

Why does Claude ignore parts of your CLAUDE.md?

Because of the budget. HumanLayer's 2025 analysis found that as instruction count increases, instruction-following quality decreases uniformly (humanlayer.dev). That means the model does not just drop the last rules; it gets worse at all of them. With about 50 instructions already spent by the harness, your headroom is smaller than 150-200 suggests.

TurboDocx's 2026 advice gives the diagnosis in one line: if Claude repeatedly ignores a rule, the file is too long, so prune it (turbodocx.com). We agree. Before rewording a rule in capitals, shorten the file.

How long should CLAUDE.md be?

Published guidance clusters tightly. Anthropic has no official recommendation (humanlayer.dev), so pick a ceiling from the sources below.

SourceGuidance
HumanLayer (2025) (humanlayer.dev)Under 300 lines is best, shorter is better
HumanLayer's own root file (humanlayer.dev)Less than sixty lines
claude-code-best-practice repo (github.com)Under 200 lines per file
TurboDocx (2026) (turbodocx.com)About 300 lines is the absolute ceiling

We'd set 200 as a hard limit and aim well below it. The 300-line figure is where signal starts to drown, not a target. If your file is a monorepo's single entry point, the limit applies per file, so split rather than stretch.

How do you cut a CLAUDE.md down to a budget it can keep?

Take a bloated file and sort every line into keep, move or delete.

Step 2. Count the lines. Over 200 means you must cut. Expected result: a number to beat.

Step 3. Apply TurboDocx's test to each line: "If I remove this line, will Claude make mistakes?" If not, cut it (turbodocx.com). Expected result: generic advice and things Claude already does correctly disappear.

Step 4. Delete frequently changing information such as version lists or status notes. It goes stale and causes confusion (turbodocx.com). Expected result: only stable facts remain.

Step 5. Mark each survivor. Applies to every task: keep. Applies to one area or feature: move (see the next section). Style enforcement: move to a hook. Expected result: three piles, with "keep" short enough to sit under your ceiling.

Keep the corrections that earn their place. Dometrain found that even a few clarifying style points reduced refactoring, such as removing unnecessary comments and fixing naming (dometrain.com). Those are lines that prevent a repeated mistake, which is exactly what passes the test.

When this is the wrong approach: if your project is small and the file is already under sixty lines, more cutting buys little. Spend the effort on checking that the commands are correct.

Where should the rest go: imports, rules, skills or hooks?

Instruction typeHomeWhy
Needed every sessionCLAUDE.mdAlways loaded (humanlayer.dev)
Detailed reference doc@importPulls files in on demand, recursive up to 5 levels deep (turbodocx.com)
Applies to certain files.claude/rules with paths: frontmatterLazy-loaded only when Claude touches matching files (github.com)
Feature-specific workflowSubagent with skillsProgressive disclosure over general-purpose agents (github.com)
Formatting and lintStop hookRuns formatter and linter and shows errors to Claude (humanlayer.dev)

Two cautions. A rules file without paths frontmatter loads every session like CLAUDE.md (github.com), so it spends the same budget. And do not use Claude as an expensive linter: put style checks in a Stop hook instead of prose rules (humanlayer.dev).

Workflows suit details the agent repeatedly misses (dometrain.com). Add one only after you see the miss, not in advance.

Step 6. Move each "move" line to its home from the table. Expected result: CLAUDE.md shrinks, and the detail still loads when it is relevant.

Wrong choice: if an instruction truly applies to every task, do not hide it behind an import. Imports are for reference material, not for rules you need always followed.

Should you generate it with /init?

Running /init in the project root launches an analysis agent that generates the file (dometrain.com). It is a fine starting point, but HumanLayer argues CLAUDE.md is the highest leverage point of the harness, so avoid auto-generating it (humanlayer.dev). Dometrain adds that /init may miss or misidentify architecture patterns, so always review and correct the output.

Our pick: use /init if you are staring at a blank page, then run the whole cut process above on the result. Generated files tend to be thorough rather than selective, which is the opposite of what a budget needs. If you already know your conventions, write it by hand.

Step 7. Run /init, then review every line against the remove-it test. Expected result: a trimmed file whose architecture notes you have personally verified.

Where do personal and project files live, and how do you check them?

Personal project overrides go in CLAUDE.local.md, which should be gitignored (turbodocx.com). Shared rules stay in the committed CLAUDE.md. For a full walkthrough of the global, project and local layers, see A Real, Annotated CLAUDE.md Example.

Step 8. Add CLAUDE.local.md to.gitignore, then run /doctor for diagnostics. Expected result: personal notes stay out of commits, and /doctor reports your setup.

ClockedCode: Upgrade your Claude Code setup in one paste A curated Claude Code setup: vetted tools, subagents, and a tuned CLAUDE.md, compiled into one master prompt you paste once.

Frequently asked questions

Does Claude Code read CLAUDE.md every session?

Yes, by default it goes into every conversation (humanlayer.dev). Rules files with paths frontmatter are the exception: they load only when matching files are touched (github.com). That is why moving niche guidance there saves budget.

Is there an official maximum length for CLAUDE.md?

No. Anthropic has no official recommendation, and the general consensus is under 300 lines (humanlayer.dev). Treat 200 as a safer working limit.

Should CLAUDE.md be committed to git?

The shared project file, yes, so the team gets the same instructions. Keep personal overrides in CLAUDE.local.md and gitignore it (turbodocx.com). Then audit the committed file whenever Claude starts ignoring a rule.

Next action: open your CLAUDE.md, count the lines, and run the remove-it test on the first twenty.

Frequently asked questions

Does Claude Code read CLAUDE.md every session?

Yes, by default it goes into every conversation (humanlayer.dev). Rules files with paths frontmatter are the exception: they load only when matching files are touched (github.com). That is why moving niche guidance there saves budget.

Is there an official maximum length for CLAUDE.md?

No. Anthropic has no official recommendation, and the general consensus is under 300 lines (humanlayer.dev). Treat 200 as a safer working limit.

Should CLAUDE.md be committed to git?

The shared project file, yes, so the team gets the same instructions. Keep personal overrides in CLAUDE.local.md and gitignore it (turbodocx.com). Then audit the committed file whenever Claude starts ignoring a rule.

Next action: open your CLAUDE.md, count the lines, and run the remove-it test on the first twenty.