BLOG

How much context CLAUDE.md and memory files take in Claude Code

5 min read • October 2026
On this page
  1. Which memory files load at session start
  2. How to see what memory costs
  3. How big is too big
  4. What caching does and does not save
  5. How to trim CLAUDE.md without losing instructions
  6. Frequently asked questions
  7. Related

Every memory file Claude Code loads at session start goes out with every request in that session. A 2,000-token CLAUDE.md in a session of 300 model calls is 600,000 tokens of input, cached or not. The file is small. The multiplier is not.

SkillKeeper Memory tab under the menu bar: tokens per CLAUDE.md, MEMORY.md, rules and CLAUDE.local.md over a month

This post covers which files load, how to see what each one costs, and how to cut them down without losing the instructions that matter.

Which memory files load at session start

Claude Code concatenates memory files instead of letting one override another. According to the memory docs, these load at launch, broadest first:

  1. A managed policy CLAUDE.md, if your organization sets one
  2. Your user file, ~/.claude/CLAUDE.md
  3. The project file, ./CLAUDE.md or ./.claude/CLAUDE.md
  4. ./CLAUDE.local.md
  5. CLAUDE.md files in parent directories, from the root down to where you started Claude
  6. Every file in .claude/rules/ that has no paths: field
  7. The first 200 lines or 25 KB of auto memory, ~/.claude/projects/<project>/memory/MEMORY.md

Two things load later, only when Claude reads a matching file: CLAUDE.md files in subdirectories and rules with a paths: field.

@path imports pull another file in, up to four hops deep. An import changes where the text lives, not what it costs: the imported file loads in full.

How to see what memory costs

/context: the current session

/context draws a grid of everything in the context window and lists memory files among the parts. It also suggests trims when memory looks bloated. The limit: it describes this one session, right now.

/memory: which files are active

/memory lists the files loaded in this session and opens any of them for editing. It shows no token counts.

Per file, across all sessions

Neither command answers "how much did CLAUDE.md cost me this week". For that you need the size of each file multiplied by the number of requests it rode along on, across sessions.

SkillKeeper does that count from your local Claude Code logs. Its Memory tab lists every CLAUDE.md, rules file and auto-memory file that loaded in the period, with the number of requests each one was in and the tokens that added up to. Tokens are estimated from the file's size, so treat them as a close count, not an invoice. A pinned row shows how much of your usage had nothing to do with memory, so you can see the share at a glance. The same tab is in the SkillKeeper mod for Claude Code, which runs on Windows, Linux and Mac.

How big is too big

The docs give one number: "target under 200 lines per CLAUDE.md file. Longer files consume more context and reduce adherence." Claude Code warns at startup and in /status when a file runs past the recommended length, and since v2.1.281 it also warns when files add up past a combined limit.

The second half of that sentence, adherence, is the part research backs up:

  • More instructions, fewer followed. In the IFScale benchmark, the best frontier models followed 68% of instructions when given 500 at once, and favored the ones that came first.
  • Context files raise cost more than results. An ETH Zurich study from February 2026 found that repository context files "do not generally improve task success rates, while increasing inference cost by over 20%".
  • Short and specific wins. In Vercel's evals, a docs index cut from about 40 KB to 8 KB in AGENTS.md reached a 100% pass rate.

So a long CLAUDE.md costs twice: tokens on every request, and instructions that get skipped because there are too many of them.

What caching does and does not save

Memory files sit in the cached part of the prompt, right after the system prompt (prompt caching docs). A cached read is cheaper than a fresh one, but not free.

Three details change the math:

  • The cache expires. It lives for an hour on a subscription and five minutes with an API key. The first request after a break pays the full rate for every memory file again.
  • Edits wait. CLAUDE.md is read at session start. A change mid-session applies after /clear, /compact or a restart.
  • Compaction reloads. After /compact, the project-root CLAUDE.md, unscoped rules and auto memory are re-read from disk (what survives compaction). A long session does not shed them, only a shorter file does.

How to trim CLAUDE.md without losing instructions

  1. Measure first. Find the file that is actually big across your sessions. It is often a user-level ~/.claude/CLAUDE.md that loads in every project, or an auto-memory file that grew quietly.
  2. Scope rules to paths. A rule about database migrations does not need to load while you edit CSS. Move it to .claude/rules/ with a paths: field and it loads only when Claude reads a matching file.
  3. Move workflows into skills. Instructions for something you do once a week belong in a skill. Claude Code loads a skill's name and description at start and its body only when the skill runs.
  4. Push detail down the tree. A CLAUDE.md in src/api/ loads when Claude works there, not in every session.
  5. Delete what the code already says. Directory overviews and style rules a linter enforces add tokens without changing what Claude does.
  6. Measure again. The same view should show the file smaller and its total down over the next few days.

Frequently asked questions

Does Claude Code send CLAUDE.md with every message?

Yes. Claude Code sends the full context with every request, and memory files are part of it. Prompt caching makes repeated sends cheaper but not free, and the cache expires after an hour on a subscription or five minutes with an API key.

How long should CLAUDE.md be?

The Claude Code docs recommend under 200 lines per file. Claude Code warns when a file runs past its recommended length. Shorter files also get followed more reliably, because models skip more instructions as their number grows.

Do @imports reduce token usage?

No. An imported file loads in full at session start, the same as if its text were pasted into CLAUDE.md. To load text only when needed, use path-scoped rules, a subdirectory CLAUDE.md or a skill.

How much of MEMORY.md loads?

The first 200 lines or the first 25 KB, whichever comes first. Topic files in the same memory folder load only when Claude decides to read them.

How do I see which memory file costs the most?

/context shows memory in the current session. To compare files across sessions and days, count each file's size against the number of requests it was loaded for, by hand or with a tool like SkillKeeper that reads your local logs.

About SkillKeeper