Skip to navigation

Claude Code CLAUDE.md: Keep Only Instructions Every Task Needs

In short: Trim CLAUDE.md to durable project facts and decisions instead of turning it into a transcript, manual, or task-specific prompt.

Published 17 min read
On this page

Direct answer: keep durable, non-discoverable project context

CLAUDE.md should contain the project facts and team decisions that remain useful across tasks and cannot be reliably discovered by reading the repository. Move one-off requests into the task prompt, move detailed procedures into linked references, and remove explanations that the current code already makes clear. Review the file when a project decision changes rather than letting it grow into a history of past sessions.

Official memory documentation says CLAUDE.md is loaded into every session, and larger files take more context and attention (F040, official). Official best practices recommends keeping it short and focused on non-discoverable information (F041, official). The memory documentation offers an under-200-line target for better adherence, but that is guidance rather than a loading limit or universal quality threshold (F042, official).

The practical win is a smaller, reviewable brief whose instructions still matter when an unrelated task begins. The loss is that moving context elsewhere can make an important rule harder to find. Critical cross-project rules belong close, and conditional detail should be linked instead of copied into every instruction file.

Why an overgrown project brief costs attention

An always-loaded file competes for the same finite attention as the current request. That does not mean every extra line causes a measured failure. The fact pack supports a relevance and attention cost, not a quantified quality penalty (F040, official). The engineering problem is still concrete: stale or task-specific text gives the reader more material to reconcile before the actual requirement is clear.

Consider a file that contains a current architecture decision, an old migration note, a walkthrough of a utility, and instructions for a feature completed last month. A new task about the utility now has to separate the active decision from historical explanation. A task about another subsystem carries all of it anyway. The file has become a transcript of what previous work needed, not a stable description of what this project needs.

Maintenance creates a second cost. When code changes, duplicated explanations can remain in the brief and become false. A reviewer must then determine whether the code or the instruction is authoritative. Keeping discoverable explanations out of CLAUDE.md reduces that reconciliation work. It does not remove the need to inspect the code.

Evidence and the limit of the line target

The memory documentation supplies the loading and attention facts (F040, official) and the under-200-line target (F042, official). The Claude Code best-practices guide supplies the recommendation to focus on non-discoverable information (F041, official).

Read those sources together, not as competing rules. A short file can still be full of irrelevant instructions. A somewhat longer file can remain useful if every line carries durable project context. The target is a review aid, not permission to pad the file or a reason to delete a necessary decision merely to cross a line boundary.

Evidence map separating durable context, a task-specific brief, a linked reference, and a review trigger
Evidence map based on official Claude Code memory and best-practices documentation. The caveat is that the under-200-line target is guidance, not a hard limit or proof of adherence.

What CLAUDE.md is for

Use CLAUDE.md to carry context that changes how a task should be approached but is not obvious from the code alone. Examples include a deliberate architectural boundary, a team decision that favors one supported approach, or a project-specific definition of done. These are categories for review, not a mandatory template.

A useful instruction has an owner, a reason, and a review trigger. The owner is the team or role responsible for the decision. The reason explains why the rule exists. The review trigger names the event that should cause reconsideration, such as a dependency replacement or a change in the supported interface.

Avoid treating the file as enforced configuration. It is project context, and the instructions still require interpretation and inspection. If a rule must be mechanically guaranteed, this article does not convert it into a configuration prescription. Keep the factual boundary clear: the memory documentation describes CLAUDE.md as context rather than enforced configuration, a limit also central to the guide on conflicting instructions and precedence.

Choose the right home for each instruction

CLAUDE.md Task prompt Linked reference
Durable project decision The current requested outcome Detailed procedure used only in a specific workflow
Non-discoverable architectural boundary File targets, symptoms, and acceptance examples Long rationale, migration history, or operational notes
Cross-task team convention Temporary exclusions for this edit Conditional instructions for a path, subsystem, or skill
Rule with an owner and review trigger Clarification needed for this request Material that should be read only when relevant

The table is an editorial routing aid. A rule can begin in a task prompt and later earn a place in CLAUDE.md if it becomes a durable project decision. The reverse move is equally important. A rule that mattered for one migration should leave the always-loaded file once that migration is complete.

Task prompts already have a natural scope: the current request. Use them for precise file names, symptoms, examples, and exclusions. The guide to prompt specificity through files, symbols, and exceptions explains how to add those details without prescribing the whole solution.

Identify durable project facts

Apply four questions to each candidate line:

  1. Recurrence: Does this matter across unrelated tasks, or only during one feature?
  2. Discoverability: Can a reader reliably learn it from current code, types, tests, or repository documentation?
  3. Durability: Is it a stable decision, or a temporary state that will change soon?
  4. Consequence: Would missing it cause a plausible task to violate an important project boundary?

A line that fails recurrence belongs in the task prompt. A line that fails discoverability may belong in CLAUDE.md, provided it is also durable and consequential. A line that fails durability needs a review trigger or removal. A line that fails consequence may be background reading rather than an instruction.

Durable does not mean permanent. The official best-practices recommendation explicitly allows for changing project decisions (F041, official). Treat the file as maintained context. An old decision can be more harmful than no decision if it directs a new task toward an abandoned approach.

Durable fact versus temporary note

Candidate text Classification Better home Review trigger
“The public client must not import server-only modules.” Durable architectural boundary if still true CLAUDE.md Package or boundary redesign
“Fix the checkout heading in this task.” Current task outcome Task prompt Task completion
“The auth migration used the old token field.” Historical explanation Linked migration note Note archival
“Prefer the existing repository helper for this concern.” Durable team convention when the helper remains supported CLAUDE.md or scoped rule Helper deprecation
“Use the temporary local fixture today.” Temporary setup detail Task prompt Fixture removal
“Do not paste credentials into prompts or screenshots.” Durable safety instruction CLAUDE.md Security-policy revision

The examples are illustrative wording, not claims about a real repository. Their value is the routing decision. A reviewer should be able to explain why each line remains in the file.

Remove task-specific instructions

Task-specific text often arrives through helpful accumulation. A session discovers a naming exception, adds it to CLAUDE.md, and the exception remains after the task ends. Over time, the always-loaded file begins to describe edge cases that most sessions will never encounter.

Look for temporal phrases, ticket-shaped requirements, one named bug, or a requested output that belongs to a single change. Move those lines to the current brief. If the task reveals a broader rule, rewrite the broader rule without the incident details and record why it applies across tasks.

For example, “While fixing the export timeout, also change the date label in the report header” is a task instruction. “Date labels in exported reports follow the project’s locale policy” may be a durable convention if that policy exists and is not obvious from the code. The second sentence should point to the policy rather than repeat a changing table of locale details.

Removing task text is not the same as removing the task’s evidence. Relevant files and examples belong in the task context. The guide to file references that reduce context noise covers targeted inclusion without turning CLAUDE.md into an attachment list.

Workflow routing durable context, task-specific briefs, linked references, and review triggers
Editorial routing workflow based on official guidance to keep CLAUDE.md short and non-discoverable. The caveat is that relevance still requires project judgment.

Remove discoverable explanations

A code walkthrough can become stale without anyone noticing. If CLAUDE.md explains how a function works, the function’s implementation remains the primary evidence. The brief should stay focused on the decision that the implementation alone cannot explain.

Ask: “Would a careful reader discover this by opening the owning module?” If yes, remove the duplicated explanation or replace it with a pointer. If the code shows the mechanism but not the reason, keep the reason in a short sentence. “This boundary exists because the browser bundle cannot include server credentials” is more durable than a list of every import currently crossing the boundary.

This distinction also supports local editing quality. A request to follow current code conventions does not require copying the whole style guide into CLAUDE.md. The guide to style-preserving edits that follow local patterns shows how code itself can supply evidence while exceptions remain explicit.

Instruction, relevance, and review table

Instruction Why it stays or moves Relevance test Review trigger
Public package boundary Encodes a team decision not obvious from every import Applies across public API work Boundary redesign
Step-by-step local setup Detailed procedure belongs in a reference Needed only during setup Setup change
Current release checklist Temporary operational state Needed only for the release Release completion
Supported extension point Guides many feature tasks without appearing in one file Applies across extension work Extension contract change
Last session’s failed approach Historical evidence, not an active rule Rarely changes a new task Convert lesson into a durable rule or archive
Definition of acceptable evidence Cross-task review decision Applies whenever work is called complete Review-policy change

A linked reference keeps detail available without loading it into every session. Use a descriptive path or repository document name and state when the reader should open it. Avoid a chain of links that forces a task to traverse several documents before finding the active rule.

The rule itself should stay close when missing it would be costly. A link can carry examples, rationale, and procedures; the always-loaded brief can carry the short boundary. This is progressive disclosure without making the critical instruction disappear. The companion guide to path-scoped rules and progressive disclosure covers conditional placement in more detail.

When a reference moves, update the pointer as part of the same change. A stale link is worse than a concise duplicated rule because it presents the appearance of available guidance while sending the reader to a dead end. Treat reference paths as maintained project context, not permanent trivia.

Worked example: trimming a hypothetical project brief

The following before-and-after example is illustrative. It does not describe a measured repository or a benchmark result.

A hypothetical CLAUDE.md contains an architecture boundary, a request to fix a settings label, an explanation of a date helper, a temporary note about a local fixture, and a link to a detailed migration procedure. The file mixes durable decisions with one task and two pieces of discoverable or conditional material.

A leaner version keeps the architecture boundary and the migration link, with a short condition explaining when the migration reference applies. The settings request moves to the task prompt. The date-helper explanation is removed because the implementation can be inspected. The fixture note moves to the task prompt because it describes local setup for a specific session.

The resulting brief might read:

# Project context

- Keep browser code separate from server-only modules. The public client must not import server credentials or server-only packages.
- Read docs/migration-notes.md before changing the legacy settings import path. It records the supported compatibility decisions.

This is a model of routing, not a universal template. The actual file should name the project’s real boundaries and references. It should not contain secrets, private endpoints, tokens, or sensitive data.

Before asking Claude Code to perform the trim, provide the current file and the task context. A safe editorial request is: “Classify each CLAUDE.md line as durable non-discoverable context, task-specific instruction, discoverable explanation, or linked-reference detail. Propose moves without deleting the source text until I approve the classification.” That request creates an inspectable review step rather than an unreviewed rewrite.

Keep the file short enough to review

Short enough means that a maintainer can review the whole file and explain why each line is present. The official under-200-line target supports that review goal (F042, official), but line count alone cannot establish relevance.

Use headings only when they help a reviewer find distinct responsibilities. Collapse repetitive warnings. Remove multiple sentences that restate the same boundary. Prefer one concrete instruction over several vague statements. Specificity helps review because the reader can tell what would violate the rule.

Do not compress away important conditions merely to reduce the count. If a rule needs a scope, an exception, and an owner, keep those elements. The separate guide to clear goals, rules, and examples in prompt structure is useful for organizing a complex instruction without relying on emphasis words.

Check loading scope before assuming the rule is active

F040 establishes that CLAUDE.md is loaded into every session and that larger files consume more context and attention (F040, official). That makes file location and current contents important. Before adding another rule, confirm which project instruction file you are editing and whether the current session is actually using the intended project context.

Do not assume that a file on disk has produced the expected behavior. Ask for the relevant instruction to be identified, inspect the current file, and compare the observed edit with the stated rule. The guide to auditing loaded files before adding context provides a separate inspection workflow.

Loading scope and behavioral compliance are different questions. A file can be present and still contain a vague or conflicting instruction. A clean file audit answers “what context is available?” It does not answer “was the rule followed?” That second question requires inspecting the resulting work.

Tradeoff diagram comparing durable context, task-specific briefs, and linked references
Tradeoff view derived from official Claude Code guidance. Moving detail can improve relevance, but the caveat is that critical rules must remain easy to find.

Revise when project decisions change

Tie CLAUDE.md edits to the decisions that justify them. When an architectural boundary changes, update the instruction in the same review. When a helper is deprecated, remove or revise the convention that recommends it. When a temporary policy expires, delete the temporary text.

A review trigger can be written beside the instruction or tracked in the owning design document. The important property is that someone can tell when the rule should be reconsidered. Without a trigger, durable context slowly becomes historical context.

Use a diff review to check that the shorter file still preserves the intended boundaries. Compare each removed line with its new home or its reason for deletion. Do not judge the trim by line count alone. The requirements guide supports documenting constraints and assumptions, but the packet contains only search-index evidence for that independent vendor guidance. Treat it as supporting context, not a universal standard.

Concrete win, concrete loss, and implication

Win: A hypothetical brief can move a settings request, a discoverable helper explanation, and a temporary fixture note out of CLAUDE.md while preserving the architecture boundary and migration reference. Unrelated sessions no longer carry those task remnants.

Loss: A migration rule hidden behind a poor link can be missed, and deleting a duplicated explanation can remove the only statement of why a boundary exists. The line target does not prove adherence (F042, official).

Implication: Review CLAUDE.md as a small decision register. Durable non-discoverable boundaries belong close, task detail routes to the prompt, and conditional references should be easy to open and maintain.

Maintenance checklist

For each line, record one disposition:

  • Keep in CLAUDE.md because it is durable, non-discoverable, and consequential.
  • Move to the task prompt because it applies only to the current request.
  • Move to a linked reference because it is conditional or detailed.
  • Remove because the code makes it discoverable and no separate decision remains.
  • Rewrite because it is vague, duplicated, stale, or missing a scope.

Then review the whole file:

  • Confirm the file belongs to the intended project context.
  • Remove secrets and sensitive data.
  • Check that every reference resolves.
  • Critical rules belong close to the top-level brief.
  • Add or update review triggers for decisions that can change.
  • Inspect a resulting task edit rather than assuming the instruction was followed.
Control checklist for durable context, task briefs, linked references, and review triggers
Editorial control checklist based on F040 through F042. Official guidance supports relevance and brevity; the checklist is not a compliance mechanism.

Data gaps and future updates

The packet contains no measured relationship between CLAUDE.md length and task accuracy. It also contains no universal adherence threshold. The under-200-line target should therefore be reported as official guidance, not as a proven cutoff (F042, official).

No verified community report is used. The research register contains no community issue with confirmed reproduction scope and outcome. A future update should revisit the live memory documentation and add project measurements only if they describe the task set, instruction changes, and comparison method.

Verdict separating durable context, a task-specific brief, and a linked reference
Verdict synthesized from official memory and best-practices guidance. The caveat is that brevity helps review but does not prove that the remaining instructions are relevant or followed.

One AI API Key for a separate OpenAI-format agent

For evaluations that use an OpenAI-format agent, One AI API Key provides a separate route at https://api.oneaiapikey.com/v1 with one key and 46 live free IDs as checked in this batch. See the free model list or the quickstart before choosing a model. This option is not a model source for Claude Code, and the packet records Claude IDs as unavailable on 2026-11-27.

FAQ

Should CLAUDE.md contain the project’s full architecture guide?

No. Keep the durable decisions that affect many tasks, and link the detailed guide. A short boundary plus a descriptive reference is easier to review than a copied manual.

Is staying below 200 lines enough?

No. The official target is guidance for better adherence, not a hard loading limit or proof of quality (F042, official). A short file can still contain stale or irrelevant instructions.

Where should a one-time exception go?

Put it in the task prompt with its scope. If the exception reveals a durable rule, rewrite that rule separately and give it an owner or review trigger.

Can CLAUDE.md guarantee that Claude Code follows a rule?

No. Treat it as context, not enforced configuration. Inspect the resulting work and resolve vague or contradictory instructions rather than relying on the file’s presence.

Batch reading path

For requirement quality, read observable requirement outcomes, negative requirements that protect scope, ambiguous requirements clarified before editing, and acceptance examples with observable results.

For planning, compare reversible small-step plans, exploration plans that resolve unknowns, plan approval before editing, and replanning when evidence changes assumptions.

For scoped context, read progressive disclosure through path-scoped rules, context relevance and evidence selection, and instruction conflicts and precedence.

For execution, use task breakdown with exit conditions, plan dependencies, and inspectable task checkpoints.

For tool evidence, see structured agent briefs where outputs are supported, investigation before answers, independent parallel reads, evidence-shaped tool results, and deferred API tool discovery.

For edit quality, read exact edit targets, style-preserving local edits, and behavior-preserving refactor scope.

For visual and boundary decisions, see image prompts with written constraints, file references without repository noise, loaded-context audits, unambiguous tool inputs, and stop conditions at the agreed boundary.

Sources

More in Blog

Try it

One API key for GPT, Grok, DeepSeek, Kimi, GLM, MiniMax, Qwen, Step, Beam, Nemotron, ERNIE, Hunyuan, Gemma, Laguna, LFM, LongCat, Llama, Solar, Jais, Mistral, K2 and Roleplay.

One AI API Key speaks the OpenAI and Anthropic formats, so you change the base URL and the key, not your code. Credit packs start at $10, and every model has a published per-token rate.

New accounts$10 credit on sign-up
  • 100requests
    per day
  • 3Mtokens
    per day
  • 47free
    models
  • $0per
    token
  • No card
  • No end date
Claim $10 credit →