CLAUDE.md: the highest-leverage file in your repository

CLAUDE.md is the difference between an agent that rediscovers your conventions every session and one that arrives knowing them. It is also loaded on every session, which makes it the one file where verbosity has a running cost.

By the Continuum team. We build a workbench that runs Claude Code, Codex, and their peers, so the model rates quoted here are the ones our own cost analytics ship with.

The short version

CLAUDE.md is a Markdown file Claude Code loads into context at the start of every session. It can live at four scopes: a managed policy path, ~/.claude/CLAUDE.md, the project root as ./CLAUDE.md or ./.claude/CLAUDE.md, and ./CLAUDE.local.md for personal notes. Every discovered file is concatenated rather than overridden, broadest scope first. Anthropic documents a target of under 200 lines per file, because longer files consume context and reduce adherence. Write only what a competent engineer new to the repository would get wrong.

What you need to know
  • Loaded at the start of every session. Length is a recurring cost, not a one-off.
  • Files are concatenated, not overridden. Broadest scope first, your working directory last.
  • Target under 200 lines per file (Anthropic docs, August 2026). Past that, adherence drops.
  • Bloat has a proper fix: .claude/rules/ with a paths: glob loads only when it is relevant.
  • Claude Code reads CLAUDE.md, never AGENTS.md. Import or symlink it if you carry both.

Where the files live and how they load

Four scopes, listed here in load order from broadest to most specific. A project instruction therefore appears in context after a user instruction.

CLAUDE.md scopes, in the order they enter context. Verified against Anthropic docs, August 2026.

ScopeLocationCommit it?
Managed policymacOS /Library/Application Support/ClaudeCode/CLAUDE.md, Linux and WSL /etc/claude-code/CLAUDE.md, Windows C:\Program Files\ClaudeCode\CLAUDE.mdDeployed by IT
User~/.claude/CLAUDE.mdNo, it is personal
Project./CLAUDE.md or ./.claude/CLAUDE.mdYes
Local./CLAUDE.local.mdNo, gitignore it

Files in subdirectories below your working directory are found too, but they are not loaded at launch. They enter context when Claude reads a file in that subdirectory. Within any one directory, CLAUDE.local.md is appended after CLAUDE.md, so your personal notes are the last thing read at that level.

Confirm what actually loaded, rather than what you think loaded.
# in a session: lists Memory files that are in context right now
/context

# open or create any memory file across user and project scope
/memory

# generate a starting CLAUDE.md from the codebase
/init

What belongs in it

One test for every line: would a competent engineer new to this repository get this wrong? If no, delete it. Anthropic’s own guidance is to add an entry when Claude makes the same mistake a second time, or when you type the same correction you typed last session.

Include, and the reason.

IncludeWhy
Build, test, and lint commandsNot discoverable; the agent will guess wrong
How to run one testStops it running the whole suite and paying for the output
Conventions that contradict the ecosystem defaultExactly what it will otherwise get wrong
Directory map for a large or unusual repoSaves many exploration turns
Known traps and their reasonsPrevents a reverted fix being re-reverted
Things it must never doCheap insurance

Leave out, and the reason.

Leave outWhy
What the language or framework doesIt knows
Your full API documentationIt can read the code
Directory layouts and dependency listsDerivable from the codebase; /doctor proposes cutting exactly these
Team process and ticket workflowNot actionable in an edit
A multi-step procedureThat is a skill, and a skill loads only when used
Long prose about philosophyCosts context every session, changes nothing

A complete example

A real-shaped CLAUDE.md. Short on purpose.
# Project context

TypeScript API on Fastify, Postgres via Drizzle. pnpm workspace.

<!-- Maintainer note: block HTML comments are stripped before this
     file reaches the model, so notes like this cost no context. -->

## Commands

- `pnpm dev` - local server on :3000
- `pnpm test` - full suite, about 4 minutes
- `pnpm test src/routes/auth.test.ts` - ONE file. Prefer this.
- `pnpm lint --fix` - run before proposing a diff
- `pnpm db:migrate` - after any schema change

## Conventions

- **No default exports.** Named exports only, enforced by lint.
- Errors: throw `AppError` from `src/errors.ts`, never a bare `Error`.
- All money is integer minor units. Never a float.
- Dates cross the wire as ISO 8601 UTC strings, never Date objects.

## Traps

- `src/legacy/billing.ts` is load-bearing and untested. Ask before touching it.
- Drizzle migrations are NOT reversible here. Check the generated SQL first.
- The test suite needs Postgres running: `docker compose up -d db`.

## Never

- Never commit directly to `main`.
- Never add a dependency without asking.
- Never edit anything under `src/generated/`.

Keeping it under 200 lines

Anthropic documents a target of under 200 lines per CLAUDE.md file, and is explicit about why: longer files consume more context and reduce adherence. Splitting into @path imports helps organisation but does not reduce context, because imported files load at launch too. The mechanism that actually reduces context is path-scoped rules.

01

Move procedures out to skills

If an entry is a multi-step workflow rather than a fact, it belongs in .claude/skills/<name>/SKILL.md. A skill body loads only when it is invoked, so long reference material costs almost nothing until you need it.

02

Move file-specific rules to .claude/rules/

A Markdown file in .claude/rules/ with a paths: frontmatter glob loads only when Claude touches a matching file. Rules with no paths field load at launch with the same priority as .claude/CLAUDE.md.

.claude/rules/api.md
---
paths:
  - "src/api/**/*.{ts,tsx}"
---

# API rules

- Every endpoint validates input with the shared zod schema.
- Errors use the standard response envelope in `src/errors.ts`.
- Add an OpenAPI comment block above each handler.
03

Import only what has to be there

Use @path/to/file to pull in another file. Relative paths resolve against the file containing the import, imports may recurse to a maximum of four hops, and paths inside backticks are not treated as imports. An import in a project file that resolves outside your working directory triggers a one-time approval dialog.

04

Run the trim check

The /doctor setup checkup proposes trims for a checked-in CLAUDE.md. It cuts content Claude can derive from the codebase (directory layouts, dependency lists, architecture overviews) and keeps pitfalls, rationale, and conventions that differ from tool defaults.

CLAUDE.md, rules, skills, and auto memory

Claude Code now has four ways to carry knowledge into a session, and picking the wrong one is the most common cause of a file that is both long and ignored.

Which mechanism for which kind of knowledge. As of August 2026.

MechanismWritten byLoadsUse for
CLAUDE.mdYouEvery session, in fullFacts true in every session: commands, conventions, traps
.claude/rules/*.mdYouAt launch, or on a paths: matchRules that only apply to part of the tree
.claude/skills/YouOnly when invokedMulti-step procedures and long reference material
Auto memoryClaudeIndex only, every sessionLearnings Claude picks up from your corrections

Auto memory is on by default. Claude writes its own notes to ~/.claude/projects/<project>/memory/, keyed on the git repository so every worktree of the same repo shares one directory. Only MEMORY.md is loaded at session start, and only the first 200 lines or 25KB of it, whichever comes first. Topic files next to it are read on demand.

Turn auto memory off for one project, in .claude/settings.json.
{
  "autoMemoryEnabled": false
}

AGENTS.md, and repos that carry both

Claude Code reads CLAUDE.md. It does not read AGENTS.md, which is the cross-tool file Codex and several others use. If your repository already has one, do not duplicate it.

CLAUDE.md that imports AGENTS.md, then adds Claude-specific instructions.
@AGENTS.md

## Claude Code

Use plan mode for changes under `src/billing/`.
Or symlink, if you have nothing Claude-specific to add.
ln -s AGENTS.md CLAUDE.md

# then confirm it loaded
claude
> /context

When the file is loaded and still ignored

CLAUDE.md is delivered as a user message after the system prompt. It is context, not enforced configuration, so there is no guarantee of compliance, particularly for vague or conflicting instructions.

Causes, in the order worth checking.

SymptomLikely causeFix
Nothing from the file is honouredIt never loadedRun /context and check Memory files
Followed sometimes, not alwaysInstruction is vagueRewrite it as something verifiable
Two behaviours alternateContradictory files in the treeReconcile ancestor and nested files; both are in context
Instruction disappears after /compactIt was a nested or path-scoped fileProject-root CLAUDE.md is re-injected; nested files reload on next match
A rule must hold every timeWrong mechanism entirelyUse a PreToolUse hook, which runs regardless of what Claude decides
Other teams’ files are pulling in noiseMonorepo ancestor discoveryAdd claudeMdExcludes globs in .claude/settings.local.json

Questions people ask

A Markdown file Claude Code loads into context at the start of every session. It is where you record project commands, conventions, and traps so the agent does not have to rediscover them each time.

At the repository root as ./CLAUDE.md or ./.claude/CLAUDE.md, committed to version control. Personal project notes belong in CLAUDE.local.md, gitignored, and machine-wide preferences in ~/.claude/CLAUDE.md.

Anthropic documents a target of under 200 lines per file as of August 2026. Longer files consume more context and reduce adherence, so move procedures into skills and file-specific rules into .claude/rules/ instead of growing the one file.

No. Every discovered file is concatenated, ordered from the filesystem root down to your working directory. Both are in context at once, so contradictory instructions across the tree are resolved arbitrarily rather than by proximity.

Run /context in a session and look at the Memory files list. If your file is not there, Claude cannot see it, and no amount of rewriting the content will change the behaviour.

Yes. It is documentation read by a machine, it benefits from code review, and one person working out a convention should benefit everyone. Keep personal overrides in the gitignored CLAUDE.local.md.

No. Claude Code reads CLAUDE.md and not AGENTS.md, which is the cross-tool file Codex and others read. Carry both by making CLAUDE.md a single @AGENTS.md import, or a symlink if you have nothing Claude-specific to add.

Auto memory is a second system where Claude writes its own notes to ~/.claude/projects/<project>/memory/ based on your corrections. It is on by default. Only MEMORY.md loads at session start, capped at the first 200 lines or 25KB.

Sources

Every figure above was read from these pages on August 2026. Vendors reprice without notice; if you find a stale number, tell us.

  1. Claude Code: how Claude remembers your project
  2. Claude Code skills reference
  3. Claude Code settings reference
  4. AGENTS.md specification
Try it

See which repos
need one.

Continuum shows cost per repository, and an expensive repo is usually one the agent cannot navigate.

free app · your subscriptions · local-first