{"slug": "how-long-should-claude-md-be-the-200-line-target-and-what-it-costs-you", "title": "How long should CLAUDE.md be? The 200-line target and what it costs you", "summary": "A developer guide published at aicoding-guide.com explains that Anthropic's Claude Code documentation recommends keeping each CLAUDE.md file under 200 lines, since longer files consume more context and reduce instruction adherence, while a separate 4 MiB hard limit causes the entire file to be skipped. The guide distinguishes this target from the 200-line/25KB truncation rule that applies only to auto memory's MEMORY.md, and notes that subagents load CLAUDE.md into their own context, effectively multiplying its cost. It advises trimming, splitting, or moving content once a file exceeds the target, and points users to the /context command to see actual memory-file token usage.", "body_md": "*Originally published at [https://aicoding-guide.com](https://aicoding-guide.com/en/posts/claude-md-length-guideline/).*\n\nAs you keep adding to `CLAUDE.md`, it gets hard to tell how much detail is too much. Longer feels more thorough, but it works the other way around: an oversized `CLAUDE.md` is a common reason instructions get ignored.\n\nThe documented target is specific: **under 200 lines per file**. This article explains what that number actually means, how it differs from the 4 MiB limit, and how to decide between trimming, splitting and moving content.\n\n**Key point**\n\nWhat you will learn\n\n- What the 200-line target means, and how the 4 MiB number differs\n- How much of the context window\n`CLAUDE.md` consumes at startup- Whether to trim, split or move content when the file grows\n\nTwo numbers show up in the documentation, and they behave differently.\n\n| Number | Kind | What happens past it | \n|---|---|---|\n| 200 lines | Recommended target | Still loads, but consumes more context and reduces adherence | \n| 4 MiB | Actual limit | **The whole file is skipped** and never loads | \n\nThe documentation phrases the first as: target under 200 lines per CLAUDE.md file, because longer files consume more context and reduce adherence. Nothing breaks at line 201 — the cost grows gradually.\n\nThe 4 MiB figure is a real behavioral boundary: Claude Code loads a CLAUDE.md file of up to 4 MiB in full and skips a larger one. Plain prose will never reach that, but pasting a large log or generated artifact into the file can.\n\n**Don't confuse this with the auto memory limit**\n\nThe rule that only the first 200 lines or 25KB are loaded, whichever comes first, applies to auto memory's `MEMORY.md`. The documentation states explicitly that this limit applies only to `MEMORY.md`. Your `CLAUDE.md` is not truncated at 200 lines. The same number means two different things depending on which file you are talking about.\n\nThe documentation includes an interactive simulation of what loads when a session begins. The values it uses as an example are:\n\n| What loads | Example tokens shown | \n|---|---|\n| System prompt | 4,200 | \n| Project `CLAUDE.md` | 1,800 | \n| `~/.claude/CLAUDE.md` (user scope) | 320 | \n| Auto memory ( `MEMORY.md` ) | 680 | \n| Skill descriptions | 450 | \n\nThese are illustrative figures from the simulation, not measurements of your files. They do give you the scale: a project `CLAUDE.md` costing roughly 1,800 tokens against a 200,000-token window.\n\nThe part people miss is **subagents**. A subagent loads `CLAUDE.md` into its own context. As the documentation puts it, the subagent loads CLAUDE.md too: same file, same content, but it counts against the subagent's context rather than yours. The built-in Explore and Plan agents skip it to keep their context smaller. If your workflow leans on subagents, the length of `CLAUDE.md` effectively multiplies.\n\nTo see the real numbers for your setup, run `/context` and read the **Memory files** section.\n\n```\n/context\n```\n\nOnce you are past 200 lines, you have three moves. They do not have the same effect, so consider them in order.\n\nThe best practices page suggests testing each line with one question: **would removing this cause Claude to make mistakes?** If not, cut it. It also warns that bloated CLAUDE.md files cause Claude to ignore your actual instructions.\n\nThe documentation splits content this way:\n\n| Include | Exclude | \n|---|---|\n| Bash commands Claude can't guess | Anything Claude can figure out by reading code | \n| Code style rules that differ from defaults | Standard language conventions Claude already knows | \n| Testing instructions and preferred test runners | Detailed API documentation (link to it instead) | \n| Repository etiquette (branch naming, PR conventions) | Information that changes frequently | \n| Architectural decisions specific to your project | Long explanations or tutorials | \n| Developer environment quirks (required env vars) | File-by-file descriptions of the codebase | \n| Common gotchas or non-obvious behaviors | Self-evident practices like \"write clean code\" | \n\nFor a checked-in `CLAUDE.md`, `/doctor` proposes trims: it cuts content Claude can derive from the codebase, such as directory layouts, dependency lists and architecture overviews, and keeps pitfalls, rationale and conventions that differ from tool defaults. The trim check requires Claude Code v2.1.206 or later.\n\nPulling sections into separate files with `@path` imports makes the file easier to read. It does **not** reduce context. The documentation is explicit: imported files are expanded and loaded into context at launch, and splitting into imports helps organization but doesn't reduce context.\n\nUse it for readability, not for budget. The syntax and its pitfalls are covered in the Claude Code documentation on imports.\n\nThis is the option that actually reduces tokens.\n\n`.claude/rules/` with a `paths` field only enters context when Claude reads a matching file. See `CLAUDE.md`\nThe documentation gives the same advice: if an entry is a multi-step procedure or only matters for one part of the codebase, move it to a skill or a path-scoped rule.\n\nIn a monorepo where other teams' files are being picked up, exclude them instead of shrinking your own file. See [Stop Claude Code loading other teams' CLAUDE.md files](https://aicoding-guide.com/en/posts/claude-code-claude-md-excludes/). For managing context during a session rather than at startup, see [Managing context in Claude Code](https://aicoding-guide.com/en/posts/claude-code-context-compact/).\n\n**Glossary**\n\n**Context window**: the total amount of text the model can reference in one exchange, including the conversation, every file read, and every command output. Accuracy degrades as it fills.\n\nBlock-level HTML comments in a `CLAUDE.md` are stripped before the content reaches Claude's context.\n\n``` php\n<!-- Note for human maintainers; never reaches Claude's context -->\n\n## Tests\n- Unit tests: `pnpm test`\n```\n\nThe documentation describes this directly: block-level HTML comments are stripped before the content is injected into Claude's context, so you can leave notes for human maintainers without spending context tokens on them. Comments inside code blocks are preserved, and opening the file with the Read tool shows them.\n\nOne caveat: reducing line count without reducing content does not save tokens. Collapsing several lines into one long line changes nothing. Delete the content you do not need.\n\n`MEMORY.md`, not `@` imports does not reduce context; path-scoped rules and skills do`/doctor` and `/context`", "url": "https://wpnews.pro/news/how-long-should-claude-md-be-the-200-line-target-and-what-it-costs-you", "canonical_source": "https://dev.to/aicoding-guide/how-long-should-claudemd-be-the-200-line-target-and-what-it-costs-you-5a2e", "published_at": "2026-09-13 19:10:54+00:00", "updated_at": "2026-09-13 19:20:36.461627+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "large-language-models", "ai-agents"], "entities": ["Claude Code", "Anthropic", "aicoding-guide.com"], "alternates": {"html": "https://wpnews.pro/news/how-long-should-claude-md-be-the-200-line-target-and-what-it-costs-you", "markdown": "https://wpnews.pro/news/how-long-should-claude-md-be-the-200-line-target-and-what-it-costs-you.md", "text": "https://wpnews.pro/news/how-long-should-claude-md-be-the-200-line-target-and-what-it-costs-you.txt", "jsonld": "https://wpnews.pro/news/how-long-should-claude-md-be-the-200-line-target-and-what-it-costs-you.jsonld"}}