How do I reduce Claude Code token usage?
Keep each request small and cached: /clear between tasks, noisy work in subagents on a smaller model, and the same model for the whole task. /context shows what fills the window; /usage shows tokens, cost and cache hits.
# In Claude Code: /context and /usage
# What every request carries
npx github:henrikdukefoss/contexttax --probe-mcp
# Last 7 days at API list prices
npx github:henrikdukefoss/tokenreceipt --since 7d
In the settings tabs, merge the keys into your existing files and adjust the deny paths to your repo.
What every request carries
Claude Code sends the whole session with every request, including each batch of tool results. The fixed parts load once per session; the conversation grows with every turn.
| Part | When it loads | Example size |
|---|---|---|
| System prompt and tools | Every request | 4,200 tokens |
| CLAUDE.md, rules, @imports | Every request, read at session start | 2,100 tokens |
| Auto memory (MEMORY.md) | First 200 lines or 25KB, every request | 680 tokens |
| Skill descriptions | Every request; a full skill only when used | 450 tokens |
| MCP tools | Names only with tool search, full schemas without it | 120 tokens, names only |
| Conversation | Grows every turn: prompts, replies, file reads, command output | 2,400 tokens for one file read |
| Output and thinking | Billed at the output rate, 5x input on Sonnet 5.5 | Depends on effort level |
Example sizes from Anthropic's context-window walkthrough (code.claude.com/docs/en/context-window). Run /context for your own.
How context grows in a session
On our gateway, the 100th request of a session carried 5.4 times the input of the first. A one-line question late in a long session pays for everything before it.
Where the tokens go, and where the money goes
Cache reads are most of the tokens and a fifth of the bill. Uncached input costs the most, so a cache miss on a long session outweighs any single file in CLAUDE.md.
| Token type | Share of tokens | Share of cost |
|---|---|---|
| Cache reads | 86.7% | 22% |
| Uncached input | 11.9% | 60% |
| Output | 0.5% | 13% |
| Cache writes | 0.8% | 5% |
79,276 coding-agent requests on our gateway (OpenCode, Kilo, Roo, Cline and others), September 13 to October 12, 2026, priced at Claude Sonnet 5.5 list prices. Claude Code was not in the sample. With no cache hits, the same requests would have cost 5.1 times as much.
Ten levers, biggest first
Ranked by what they save a developer paying per token. Savings are our estimates from the data above and Anthropic's list prices unless marked measured.
| Lever | Do this | What it saves |
|---|---|---|
| 1. /clear per task | /clear when you switch to unrelated work. At a natural break, /compact with a focus, such as /compact Focus on code samples and API usage | Measured: the next task starts back at the first-request size in the chart above. /clear is free; /compact is one large request |
| 2. A warm cache | Choose the model before you start, and don't connect or remove MCP servers mid-task. On an API key the cache lasts 5 minutes; set promptCacheTtl to "1h" if you take longer breaks | A miss on 100K tokens costs $0.25 on Sonnet 5.5, a hit $0.01. One-hour cache writes cost $4 per million instead of $2.50 |
| 3. Subagents | Ask for test runs, log digging and wide searches in a subagent; Claude also hands searches to its built-in Explore subagent | Only a summary returns to the main conversation, so later requests don't re-send the output. The subagent's own requests still count |
| 4. Smaller models | Sonnet for most work, Opus for the hard steps. CLAUDE_CODE_SUBAGENT_MODEL=haiku plus CLAUDE_CODE_SUBAGENT_MODEL_FORCE=1 covers every subagent, Explore included (v2.1.257+). ANTHROPIC_DEFAULT_HAIKU_MODEL sets the background model | Opus 5.5 costs twice Sonnet 5.5. On our token mix, Haiku 5.5 costs about 6% of Sonnet 5.5, or 30% once a request passes 100K tokens and Haiku's higher rates apply |
| 5. Lower effort | The 5.5 models start at medium. Use /effort low for routine edits, xhigh and max only for hard problems. MAX_THINKING_TOKENS applies only to fixed-budget models | Thinking bills as output: $10 per million on Sonnet 5.5, 100 times the cache-read price |
| 6. Read deny rules | Read deny rules under permissions.deny for lockfiles, build output and logs, such as Read(./dist/**). Claude Code ignores .claudeignore files | One Read returns up to 25,000 tokens, re-sent with every later request until /clear or /compact |
| 7. Short CLAUDE.md | Under 200 lines. Workflows go into skills, area rules into .claude/rules files with paths: frontmatter. Mention long docs by path in backticks; @imports load at launch | Cutting 1,000 tokens saves 1M per 1,000 requests: $0.10 cached on Sonnet 5.5, $2 uncached. Small in dollars, real for the context window |
| 8. Fewer MCP servers | Disable the rest in /mcp, and use a CLI such as gh where one exists | Without tool search, one 18-tool server in contexttax's sample adds 2,867 tokens to every request |
| 9. Tool search | On by default with Anthropic's API, off when ANTHROPIC_BASE_URL points at a gateway. ENABLE_TOOL_SEARCH=true works there only if the gateway forwards tool_reference blocks | The same server drops to 181 tokens: names up front, a schema only when needed |
| 10. Concise replies | /output-style concise, or outputStyle "Concise" in settings (v2.1.237+). Replies lead with the result, without narration or recaps | Our estimate: a few percent of cost in chatty sessions |
Settings go in the env block of ~/.claude/settings.json or .claude/settings.json. On the 5.5 models with an API key or a Claude subscription, changing effort keeps the cache; switching models never does. Settings, commands and version numbers from Anthropic's Claude Code docs.
How to check each lever worked
| Check | What it shows | Levers |
|---|---|---|
| /context | What fills the context window now, with suggestions for heavy tools and memory files | 1, 3, 6, 7, 8, 9 |
| /usage, alias /cost | Session tokens and cost by model, plus a Prompt cache line with the share served from cache, misses and the likely cause. On Pro and Max, usage by skill, subagent and MCP server | 2, 3, 4, 5, 10 |
| /tasks | The model each running subagent uses | 4 |
| contexttax | Tokens that CLAUDE.md, rules, skills and MCP schemas add to every request, per file, largest first | 7, 8, 9 |
| tokenreceipt | A week of your local Claude Code, Codex and OpenCode usage at API list prices. Run it before and after | All |
The Prompt cache line needs Claude Code v2.1.251 or later, its likely-cause text v2.1.260 (code.claude.com/docs/en/costs).
The same levers in Codex and OpenCode
Both send every enabled MCP server's full schemas with every request, so turning off unused servers saves more there than in Claude Code.
| Lever | Codex CLI | OpenCode |
|---|---|---|
| Start fresh | /new, or /clear to reset the screen too | /new, alias /clear |
| Compact | /compact; model_auto_compact_token_limit sets when it runs on its own | /compact, alias /summarize; compaction.prune removes old tool output |
| Instruction files | AGENTS.md on every request; project_doc_max_bytes caps how much is read | AGENTS.md, or CLAUDE.md when there is none, on every request |
| MCP servers | enabled = false under the server's [mcp_servers] entry | "enabled": false on the server |
| Lighter thinking or models | model_reasoning_effort in config.toml | small_model handles light tasks such as session titles |
| Check | /status shows the context left | contexttax and tokenreceipt |
Sources: developers.openai.com/codex (slash commands, configuration reference) and opencode.ai/docs (TUI, config, MCP servers).
The catch
On Claude Pro and Max you hit 5-hour and weekly windows instead of a bigger bill, so none of this lowers your price; it stretches the windows, which fill with the same tokens. Some levers trade quality for tokens: a smaller model or lower effort can cost a retry, and a compaction summary can drop a detail you needed. Our shares come from OpenCode, Kilo, Roo and Cline traffic, so check your own sessions with /usage.
Where Standard Compute fits
Claude Code runs on a Standard Compute key with ANTHROPIC_BASE_URL set to https://api.stdcmpt.com. Plans start at $19/month with a fixed monthly budget and no overage charges, and every lever here makes it last longer. Tool search is off through a gateway, so trim MCP servers first.
FAQ
Why is Claude Code using so many tokens?
Every request re-sends the whole session: system prompt, CLAUDE.md, tool definitions, every earlier message and every file Claude read. Across all traffic on our gateway, the 100th request of a session carried 5.4 times the input of the first.
Does /compact save tokens?
Yes, on every request after it, because the history shrinks to a summary. The compaction itself is a request that reads the whole conversation: cheap while the cache is warm, expensive after a break. If you don't need the earlier context, /clear costs nothing.
Does .claudeignore work in Claude Code?
No. Anthropic's permissions docs say a .claudeignore file has no effect. Add Read deny rules such as Read(./dist/**) under permissions.deny in .claude/settings.json. Grep already skips gitignored files; Glob does not unless you set CLAUDE_CODE_GLOB_NO_IGNORE=false.
Do @imports in CLAUDE.md reduce tokens?
No. Imported files load at launch with the CLAUDE.md that imports them, so they organize the file without making it cheaper. To keep a document out until it's needed, mention its path in backticks, move the instructions into a skill, or use a .claude/rules file with paths: frontmatter.
How do I see what is using my context?
Run /context for a breakdown of the current window and /usage, also available as /cost, for session tokens, cost and cache hits. Outside Claude Code, npx github:henrikdukefoss/contexttax measures the part every request carries: instruction files, skill descriptions and MCP schemas.
Do these tips help on Claude Pro or Max?
Yes. Subscribers hit 5-hour and weekly windows instead of a bill, and the same tokens fill them. On a subscription the main conversation's cache lasts an hour, so short breaks don't force a full re-read, but a long session still re-sends its whole history with every message.