Where Tokens Go in Claude Code: 9 Loss Patterns and How to Fix Them in 2026
MarkdownWhere context leaks in Claude Code before Claude sees the prompt: CLAUDE.md, MCP, history — and how to fix 9 leaks.
Read full article
Key points
A large share of tokens is used before the model reads your request: on an inflated CLAUDE.md, on rereading old conversation history, and up to 49% on MCP servers. This article explains nine sources of overhead and a 15-minute cleanup checklist. Savings depend on the session: occupied context, processed tokens, cache use, and cost must be measured separately.
In one example, /context in a fresh Claude Code session showed 60K tokens occupied out of 200K before the first message. Only claude had been launched in the project repository. Sixty thousand tokens—that’s a third of the budget spent on “preparing” for the conversation.
Two weeks later, I figured out exactly where they went. Below are all 9 patterns that burn your tokens before you even start typing, and how to fix them. The figures come from official Anthropic docs and measurements from real sessions.
Ailoot documentation — reference materials for using the service.
Where Do Tokens Go Before the Prompt?
Key points
A large share of your tokens is used before Claude reads your actual request: by an inflated CLAUDE.md, by recounting old chat history, and by seven other patterns—from MCP servers to background summarization. This isn’t about subscription limits; it’s about how context works.
Here are the 9 patterns in one table, with figures from measurements of real sessions and Anthropic’s official page on cost management.
| Pattern | Share of losses | Source |
|---|---|---|
| 1. Inflated CLAUDE.md | — | — |
| 2. Recounting old history | — | — |
| 3. MCP servers | up to 49% (historically), now 8-15% with Tool Search | measurements from real sessions |
4. Accumulated tool_use output | 5-15% | measurements from real sessions |
| 5. System prompt + system tools | 9.6% (1.6% + 8%) | /context measurement |
| 6. Duplicate skills and plugins | 2-5% | — |
| 7. Agent teams in Plan Mode | up to 700% | Anthropic docs |
| 8. Extended thinking budget | 5-20% | Anthropic docs |
9. Background summarization with --resume | ~$0.04/session passively | Anthropic docs |
The exact shares depend on your setup. But the overall picture is right, and each pattern can be fixed individually. I’ll cover three at a time below.
How Does Claude Build Context Before Reading Your Request?
Key points
Before you type your first character, Claude has already loaded five layers: the system prompt, descriptions of built-in tools, the CLAUDE.md file, tool names and instructions from connected MCP servers (their full descriptions when tool search is disabled), and memory (memory_files). On a 200K window, this can easily take up 60-100K, or one-third to one-half of the budget. What’s left is for the conversation itself and tools like Read/Edit.
In one real session with six MCP servers, /context showed this breakdown:
| Context layer | Tokens | % of 200K |
|---|---|---|
| System prompt | 3 200 | 1.6% |
| System tools (Read/Edit/Bash, etc.) | 16 100 | 8.0% |
| MCP tools (6 servers: google-docs + asana + calendar + slack + atlassian + gmail) | 98 700 | 49.3% |
Memory files (memory_files, Memory tool exports) | 3 000 | 1.5% |
| Free space | 34 000 | 17.0% |
| Autocompact buffer | 45 000 | 22.5% |
Notice: even if you haven’t written anything, almost half the window is occupied. Less than half is left for free space and the autocompact buffer, and that half has to fit your entire conversation—messages, Claude’s replies, files read, and command output.
The window size depends on the model. According to Anthropic’s model documentation, as of September 2026, Opus 4.7 and newer, Sonnet 5, and Fable models have a 1M-token window on every plan, including Pro. 200K remains for Opus 4.6 and Sonnet 4.6 without extended context, and for sessions where 1M is disabled with the CLAUDE_CODE_DISABLE_1M_CONTEXT=1 variable. A larger window doesn’t solve the problem of bloated context: everything loaded before the first message is sent to the model with each request, and the cost documentation explicitly says that the more context there is, the more tokens are spent. A subscription doesn’t change that—on any plan, each extra token counts against your limit.
Where Does the First Third of Context Go: CLAUDE.md, History, and MCP?
Key points
The three main patterns take up 36-76% of context before you start the conversation. CLAUDE.md contributes to the context supplied on repeated requests. History grows across turns, so later requests can process more input; cost also depends on prompt-cache reads and writes. There is no universal exponential growth rate. MCP servers historically burned up to 49% of the window, and although the new Tool Search capability introduced in December 2025–January 2026 removed most of that, many configurations still use the old model.
Pattern 1. CLAUDE.md Before Every Message
The file is loaded before every message you send, not just once per session. A 5,000-token CLAUDE.md occupies that much context on requests containing it, but fresh input, cache writes, and cache reads need separate accounting; repeated content is not necessarily charged at the full uncached rate.
Anthropic says directly in the docs:
Aim to keep CLAUDE.md under 200 lines, including only the most important information. Move specialized instructions into skills, which are loaded on demand.
In one example, the project’s CLAUDE.md contains 180 lines—everything specialized (how to write workshop instructions, the TG post format, the legal checklist) was moved into Skills and Markdown files inside business/, which Claude reads only when it looks there specifically. That cuts the baseline by 60-70% compared with two months ago.
Pattern 2. Conversation History Is Reread with Every Response
This is the pattern with the worst visibility from the outside, because it’s invisible externally. The model receives the retained conversation context on subsequent requests. Prompt caching can reuse a stable prefix; compaction and clearing can change the retained text. Repeatedly supplied context still occupies the window even when cache pricing reduces its cost.
The solution is /clear between unrelated tasks. My rule: a new chat for every new task. If a task is long and you need the history, use /compact to summarize the past into a short summary and continue from there.
More on this rule in the guide “How Not to Burn Through Your Claude Code Limits in a Day: 8 Rules for Saving Tokens”, with examples from my sessions.
Pattern 3. MCP Servers Register All Their Tools in Context
This was a historic pain point in Claude Code, causing the biggest losses up to 2026. In the session above, six connected MCP servers (Google Docs, Asana, Calendar, Slack, Atlassian, Gmail) occupied 98 700 tokens—49% of the entire window before the conversation started.
Anthropic released the Tool Search feature in December 2025–January 2026, which solves half of this problem.
In Anthropic’s docs, the description now reads:
MCP tool definitions are deferred by default—only the names enter context until Claude calls a specific one. Run
/contextto see what’s taking up space. Where possible, prefer the CLI: tools likegh,aws,gcloud, andsentry-cliare still more efficient than MCP servers because they don’t add per-tool descriptions.
What to do in production:
- Update Claude Code to a version with Tool Search (all current versions after December 2025).
- Open
/mcpand disable servers you don’t need in the current session. In the example described, two are connected all the time—Playwright and shadcn. I enable the others for one task and run/mcp disconnectimmediately afterward. - Replace MCP with CLI where possible. Use
ghinstead of an MCP server for GitHub. Use the calendar in a browser instead of Google Calendar MCP.
I covered what MCP servers are in principle and how to configure them sensibly in “Claude Code MCP Servers in 2026: 7 Ready-Made Setups and Step-by-Step Installation”.
Part of the CLAUDE.md and Skills problem is not just the size, but the structure. One instruction file (CLAUDE.md) is the core. Additional project knowledge (audience, products, legal documents, day-by-day instructions) lives in the business/ folder—that’s the project knowledge base. Claude reads only what’s needed right now, and context compression already happens at this level. The full breakdown is in a separate guide.
And one more detail that’s often overlooked: cleaning up CLAUDE.md, switching to Skills, and disabling MCP are the first step. After that, the context engineering methodology comes into play—what to put in each prompt, in what order, what to hand off through Plan Mode, and what to handle through /compact. This guide covers one building block.
What Accumulates in a Session, and What Can’t Be Cut?
Key points
The fourth pattern is tool output. Every file read, every bash output, every MCP server response stays in the session context forever. Read 10,000 lines of logs? They stay with you until /clear. The fifth pattern is the system baseline: 19K tokens for the system prompt and descriptions of built-in tools. You can’t cut these, but knowing about them helps you do the math.
Pattern 4. Tool Output Accumulates Throughout the Session
A detail few people mention: when Claude runs bash cat huge-file.log, the ENTIRE output of that command goes into context and stays there until the end of the session or /clear. The same goes for Read on a large file—all 10,000 lines remain there, taking up tokens in every subsequent message (see Pattern 2).
Solutions:
- Use
head,tail,grepinstead of reading everything.bash tail -100 deploy.loginstead ofRead deploy.log. This immediately cuts the output by 10-100 times. - Hooks for preprocessing. Put a script in
~/.claude/hooksthat filters bash output before Claude sees it. An example from Anthropic docs is a PreToolUse hook that runsnpm test 2>&1 | grep -A 5 -E 'FAIL|ERROR'instead of printing the full test output. This compresses it by 50-100 times. Details are in “Claude Code Hooks 2026: Step-by-Step Setup and 7 Ready-Made Examples”. /clearafter a large read. If you read a huge file for one specific task and no longer need it, don’t leave it in context “just in case”; start a new chat.
Pattern 5. System Prompt + System Tools = Permanent Baseline
This pattern can’t be changed because there’s almost nothing you can do about it. Claude Code starts with a system prompt (~3 200 tokens) and descriptions of all built-in tools—Read, Edit, Write, Bash, Glob, Grep, WebSearch, WebFetch, TodoWrite (~16 100 tokens). In total, that’s a permanent baseline of 19 300 tokens that you can’t cut.
What to do in practice:
- Awareness. Know that you have a 19K baseline “tax”: with a 200K window, that’s 200K - 19K = 181K for everything else (minus CLAUDE.md, MCP, and the autocompact buffer). There’s more room in a 1M window, but that “tax” still goes with every request.
- Measure repeated processing. The baseline occupies the window and can recur in later requests. It is not a once-per-session token charge; separate input, cache-write, cache-read, and output totals when calculating cost.
Where Are Tokens Lost on Skills, Plugins, and Agent Teams?
Key points
The sixth pattern is duplicate registration of skills and plugins: many skills are never invoked during a session, but are constantly loaded into context. The seventh pattern is agent teams: when you spin up several Claude instances in Plan Mode, total token consumption grows about 7 times compared with a single session. Anthropic has explicitly documented this.
Pattern 6. Skills and Plugins Can Be Registered Twice
This problem appeared with the arrival of plugins in Claude Code (late 2025). When you install a plugin that adds skills, those skills enter the context. If you also have similar user skills installed in ~/.claude/skills/, they load too. And sometimes they duplicate.
Many skills are never invoked during a session, but their descriptions are constantly loaded into context.
What to do:
/contextshows what’s actually occupied. If you see a Skills section above 3K, clean it up.ls ~/.claude/skills/—check which skills you actually have installed. Remove those you haven’t used in over a month./plugin removefor plugins you installed “to try” and forgot about.
What the right structure for Skills looks like and how they differ from CLAUDE.md is covered in “Claude Code Skills in 2026: How to Build a Personal Skills Library”.
Pattern 7. Agent Teams Burn 7 Times More in Plan Mode
Agent teams are a feature where Claude Code spins up several parallel model instances, each with its own context. Anthropic says directly in the docs:
Agent teams consume about 7 times more tokens than regular sessions when team members work in Plan Mode: each has its own context window and runs as a separate Claude instance. Keep team tasks small and self-contained to limit consumption per member.
That means five team members in Plan Mode equal five parallel sessions, each loading its own system baseline + its own copy of CLAUDE.md + its own MCP tools. Total token consumption grows nonlinearly.
What to do:
- Use Sonnet or Haiku for team members. Use Opus only for the team lead coordinating them. The per-token rate may be lower, but measure each member’s complete task cost and quality rather than assuming a fixed saving.
- Small teams. Two or three team members instead of ten.
- Clean up inactive team members. If the task is done but a team member is still running, it keeps burning tokens in the background.
More on Plan Mode and when it actually helps in “Plan Mode in Claude Code: Step-by-Step Guide and 4 Stages in 2026”.
What Does Claude Charge Tokens for While You’re Not Looking?
Key points
The eighth pattern is extended thinking. Claude thinks “out loud” before answering, and those thinking tokens count as output. By default, the budget is tens of thousands of tokens for complex tasks. The ninth pattern is background summarization: even when you’re not typing, Claude Code processes previous sessions for --resume and saves summaries. About $0.04 per session is spent “idling.”
Pattern 8. Extended Thinking Uses Tokens Without Your Involvement
Extended thinking is a mode where Claude “thinks through” the solution in a hidden thinking block before answering. In terms of calculation, these are output tokens, counted like an ordinary response, but you don’t see them in the chat.
Extended thinking is enabled by default because it significantly improves results on difficult planning and reasoning tasks. Thinking tokens are billed as output, and the default budget can be tens of thousands of tokens per request, depending on the model.
That means a single complex request can use 10-30K thinking tokens that “eat into” the budget, while you see only a short summary in the chat.
What to do:
/effort lowfor simple tasks. It reduces the thinking budget to a minimum.MAX_THINKING_TOKENS=8000in the environment to set a ceiling./config→ disable thinking for very routine tasks where Claude doesn’t need to “think.”
When thinking is actually useful (complex architecture, complex multi-step reasoning), and when it isn’t, is covered in “Sonnet or Opus 4.7 in Claude Code: Choosing a Model and /effort in 2026”.
Pattern 9. Background Summarization While Idle
This is a very small but interesting pattern. Claude Code runs a background process that summarizes previous sessions for the claude --resume command. This process runs even when you’re not typing.
Anthropic explicitly says this in the docs about it:
Claude Code uses tokens for background functionality even when idle: conversation summarization (background tasks that condense previous sessions for
claude --resume) and command processing. These background processes consume a small number of tokens (typically less than $0.04 per session) even without active interaction.
Four cents per session isn’t a catastrophe. But if you have 10 open sessions a day, that’s already $0.40 in passive spending per day, $12 a month. Close sessions you don’t need right now. A session can be restored with /resume from the index—you don’t have to keep it open.
How to Measure Your Losses: The /context Command and Its Caveats
Key points
The /context command in Claude Code shows where your tokens are going right now. But it has a known bug: historically, it overestimates MCP tools by 3 times because it counts per-tool overhead for each tool separately. Anthropic fixed this in newer versions. If MCP is above 30K in your /context report, update Claude Code first, then measure.
First, the command. In Claude Code, open /context (or /usage for the calculation) and you’ll get something like this:
Context window: 200 000 tokens
System prompt: 3 200 (1.6%)
System tools: 16 100 (8.0%)
MCP tools: 12 600 (6.3%)
CLAUDE.md: 4 800 (2.4%)
Memory files: 3 000 (1.5%)
Conversation: 18 400 (9.2%)
Free space: 141 900 (71.0%)
This is a normal permanent baseline after the first cleanup. Great—71% of the window is free.
Known /context Bug: 3x Overstatement for MCP
Until a recent update, /context showed about 3 times the actual MCP loss, because per-tool overhead was counted separately for each tool.
Anthropic fixed this in newer versions. So:
- If
/contextshows 50K+ for MCP tools—you may be on an old version of Claude Code. Update it. - If MCP is 8-15K—that’s normal, the real cost with Tool Search.
- If MCP is 30-50K on a new version, you really have many unused servers connected. Go to
/mcpand disconnect them.
What Else to Check Besides /context
/usage—shows your plan usage over the past 24 hours or 7 days. On Pro and Max, it shows a breakdown by skills, subagents, plugins, and individual MCP servers. Useful for identifying which skill burns the most.
/cost—for API users. Shows the prorated cost of the current session in dollars. Not for Pro/Max subscribers—they don’t need it.
/usage-credits—on Pro/Max, lets you set a monthly spending limit. Useful if you don’t want a scripted agent team to accidentally max out your credit card.
How to Clean Up Claude Code Context in 15 Minutes
Key points
Use these eight steps to reduce avoidable context. A target such as 70% free space or 40–50% lower usage is not a guaranteed outcome, and a context snapshot alone does not measure total session usage. Most items take 1-2 minutes. The biggest ones are cleaning up CLAUDE.md and disconnecting unused MCP, five minutes each. Do them in order; don’t skip any.
Open your project in Claude Code and go through the steps:
/context—write down the current breakdown. This is your baseline./clear—if the chat has accumulated history unrelated to the current task. Fresh window.ls -la ~/.claude/skills/—see which skills are installed. Remove those you haven’t used in a month. Command:rm -rf ~/.claude/skills/[skill-name](or delete the folder through the interface)./plugin list—same for plugins. Remove what you don’t use with/plugin remove <name>./mcp—check the connected MCP servers. Keep only those needed for the current task. Disconnect the rest with/mcp disconnect <name>.- Open CLAUDE.md in an editor. If the file is over 200 lines, move specialized instructions into Skills (
~/.claude/skills/[topic]/SKILL.md). Aim for a 100-200-line core + 5-15 topical Skills. The detailed guide is in “How to Configure CLAUDE.md in 2026: Ready-Made Template and 6 Rules”. - Check
/effort—use/effort lowfor simple tasks. A high thinking budget is needed only for complex architecture. - Final
/contextmeasurement. Compare it with step 1.
In the described sessions, occupied context fell from 60–80K to 25–30K after cleanup. That is a change in the snapshot’s footprint, not proof of a fixed reduction in total processed tokens or cost. Compare complete runs of the same task, including cache and output usage, before claiming savings.
When Does Switching to Sonnet or Haiku Help More Than Cleaning Up Context?
Key points
Context cleanup isn’t always the most cost-effective action. If your tasks are mostly routine (text edits, template generation, formatting), a model with a lower per-token rate can lower cost, but switching models does not establish any fixed reduction in token usage. Different tokenizers, reasoning, output lengths, and retries can change the actual counts. For complex architecture, complex multi-step reasoning, and debugging tricky bugs, Opus is still needed. Choose based on the task.
Anthropic writes about models in the docs:
Sonnet handles most coding tasks well and costs less than Opus. Save Opus for complex architectural decisions and complex multi-step reasoning. Use
/modelto switch mid-session, or set the default in/config. For simple subagent tasks, specifymodel: haikuin their configuration.
A rough breakdown of input-token prices (as of May 27, 2026):
| Model | Price / 1M input | When to use |
|---|---|---|
| Opus 4.7 | $15 | Architecture, complex multi-step reasoning, difficult debugging |
| Sonnet 4.5 | $3 | 80% of regular coding tasks: edits, refactoring, tests, docs |
| Haiku 4.5 | $1 | Formatting, simple parsing, subagent tasks, routine text edits |
My setup:
- Default—Sonnet 4.5. This is
/config → default model. It covers 80% of tasks. - Manually run
/model opuswhen a task is truly difficult (an architectural choice, diagnosis of a puzzling bug, a new product). - Use
/model haikufor tests and formatting. Or explicitly setmodel: haikuin the subagent config. /effortseparately from the model. You can use Opus with/effort low—you get a powerful model with minimal thinking, for quick answers to medium-difficulty tasks.
When context cleanup is more worthwhile than switching models:
- Context is over 50% full—clean it first.
- Context is fine, but tasks are complex—use Opus with normal effort.
- Context is fine and tasks are routine—use Haiku.
For a detailed breakdown of models and effort, see “Sonnet or Opus 4.7 in Claude Code: Choosing a Model and /effort in 2026”.
Which Tips Increase Usage Instead of Saving It?
Key points
Blogs often contain advice that works in the short term but breaks the workflow over time. The three main ones are: “delete all MCP,” “forget CLAUDE.md and put everything in the prompt,” and “always work through Plan Mode.” All three solve one problem and create three new ones. Let’s break them down.
Anti-pattern 1. “Delete All MCP; They Burn Tokens”
Laziness is the most common mistake. Yes, MCP historically burned up to 49% of context—but after Tool Search this dropped to 8-15%. And MCP provides real tools that you’d otherwise have to build by hand. Deleting all MCP means returning to manual work that will “eat up” more time than the tokens it saves.
The right approach: keep only MCP servers you actually use regularly. I keep Playwright (for testing landing pages) and shadcn (for generating interfaces). Everything else is for one task at a time.
Anti-pattern 2. “Don’t Use CLAUDE.md; Put Everything Directly in the Prompt”
It sounds “logical”: if CLAUDE.md loads with every request, let’s not load it. In practice, without CLAUDE.md you start each message by typing the same instructions by hand, and Claude forgets the context between messages. That means more tokens, not fewer—they’re just coming through another channel.
The right approach: keep CLAUDE.md compact (100-200 lines), with the core in it and specialized material in Skills. Details are in “How to Configure CLAUDE.md in 2026”.
Anti-pattern 3. “Always Work Through Plan Mode”
Plan Mode is an excellent tool for complex tasks where you first need to explore the codebase and propose a plan. But it uses an average of 7x more tokens when working through agent teams (Anthropic docs). On a simple task like “fix a typo in the README,” Plan Mode burns 7 times more than a direct edit.
The right approach: use Plan Mode for complex tasks that take 30 minutes or more. For short tasks, make a direct request without plan mode. When to use each mode is covered in “Plan Mode in Claude Code: Step-by-Step Guide and 4 Stages in 2026”.
Sources
Anthropic Docs: Manage costs effectively — official figures on costs, models, MCP, agent teams, and thinking budgets
Anthropic Docs: Model configuration - Extended context — window size by model and plan, auto-compaction thresholds
Ailoot materials: How to Configure CLAUDE.md, Project knowledge in Claude Code, Context Engineering in 2026, Plan Mode in Claude Code, Skills, MCP Servers, Hooks, Sonnet or Opus, How Not to Burn Through Limits.
More materials are available on Ailoot.
More details
Questions about Where Tokens Go in Claude Code: 9 Loss Patterns and How to Fix Them in 2026
Does a cheaper per-token model necessarily use fewer tokens?
No. A lower rate changes the price of a token, while actual counts depend on the tokenizer, reasoning, output, and retries. Compare completed runs on the same task before claiming a token or cost reduction.
Does /context show how much I have been billed across the session?
No. It shows the current context footprint. To assess processing and cost, inspect separate input, cache-write, cache-read, and output totals; repeated baseline text is not simply a once-per-session charge.