Optimize
How to Reduce Token Usage in Claude Code
Looking for how to reduce token usage in Claude Code without slowing the coding loop? Context hygiene, file-read discipline, session resets, subagent budgets, and claude code prompt caching — stepwise habits that move the bar, not filler tips.
This page is part of the Optimize hub, which covers the whole topic end to end.
Last updated 19 September 2026. Session commands, caching behaviour, agent-team multipliers, and model guidance below were checked against Anthropic’s Claude Code costs documentation, Claude API pricing, and Help Center usage guidance on that date. Product UI and rates change; confirm with /usage, Settings → Usage, and Anthropic’s own docs before you budget. [VERIFY: 2026-09-19]
Not affiliated with Anthropic. Claude Token Optimization is an independent site and audit service. Claude® and related product names are trademarks of Anthropic PBC. Plan prices, model rates, and usage limits change; always confirm on Anthropic’s own docs. [VERIFY: 2026-09-19]
If you searched how to reduce token usage in claude code, how to reduce claude code token usage, or claude code reduce token usage, you are not looking for a chat tip about shorter sentences. You are looking for coding-loop fixes: what Claude Code re-sends every turn, how files get into context, when a session should die, whether subagents help or multiply burn, and how claude code prompt caching actually behaves while you iterate.
This page is the companion to the general 11 ways to cut Claude token usage playbook. That list covers chat, Projects, and API habits. Here the audience is different: engineers living in the terminal or the IDE extension, watching /usage climb after a morning of agentic edits. The levers below are ordered the way a coding day usually fails — context first, then file reads, then session lifetime, then parallelism, then caching.
For how tokens are counted at all, start with how Claude tokens work. To estimate cost before you send, open the calculator once you know your model mix. For monthly spend bands by team size, see what teams spend on Claude Code.
Who this page is for: solo Max users who empty a session bar on one monorepo ticket; Team leads whose Claude Code afternoon starves chat; API-authenticated fleets where Anthropic’s published ~$150–250 per developer per month band is the planning floor and habits decide which end you land on. [VERIFY: 2026-09-19] No invented case studies — illustrative before/after counts only, labeled as method demos.
Why Claude Code burns differently than chat
Chat waste is often re-pasted handbooks and living threads. Claude Code waste is structural to the agent loop:
- Every turn carries history — prior tool results, failed patches, and exploration stay in the window unless you clear or compact.
- File reads are the default research tool — vague prompts trigger wide greps and multi-file dumps.
- Tools and MCP schemas sit in context — unused servers still cost listing overhead; see tool use costs for the full rounds × tokens model.
- Subagents and agent teams multiply windows — each worker has its own context.
- Thinking and retries bill as real work — wrong-direction loops are expensive even when you abort late.
Anthropic’s own costs guidance says token costs scale with context size, and that Claude Code already applies prompt caching for repeated prefixes plus auto-compaction near limits. Your job is not to reinvent those systems — it is to stop feeding them garbage. [VERIFY: 2026-09-19]
If you need the surface comparison (Code vs Cowork vs chat), see Cowork vs Claude Code. Shared pool behaviour and lockouts live on usage limits.
Quick map: Claude Code reduce token usage best practices
| # | Habit | What it fixes | Typical conceptual impact |
|---|---|---|---|
| 1 | Scope the ask before tools run | Broad “improve the codebase” scans | Large cut in exploratory reads |
| 2 | File-read discipline | Whole-file / whole-repo dumps | 15–45% of tool-result tokens |
| 3 | Trim CLAUDE.md + skills | Always-on instruction tax | 5–20% of base context |
| 4 | /clear or /compact on task change | Stale history on every turn | 20–60% cumulative input exposure |
| 5 | Model match (Sonnet / Haiku / Opus) | Opus-as-default vanity | Often large $ when Opus was blanket |
| 6 | Subagent budgets | Parallel windows without slices | Save wall-clock or ~7× waste |
| 7 | MCP / tool surface | Listing + unused tool noise | 10–25% when servers piled up |
| 8 | Prompt caching hygiene | Cache misses in long loops | Order-of-magnitude on stable prefixes |
[VERIFY: 2026-09-19]
1. Context management: write the task so Claude does not explore the repo
Vague prompts are the most expensive habit in Claude Code. “Improve auth” or “fix the flaky tests” invites broad scanning. Specific prompts pin the path, the function, the failure, and the Definition of Done.
Before (illustrative): “Clean up the payment module.” → Claude greps three packages, opens eight files (~12,000 tokens of tool results), then asks what you meant.
After: “In src/billing/charge.ts, add null-checks to createCharge only. Return a unified diff. Do not touch webhooks.” → one targeted read (~200–400 tokens) + a small patch.
Context management is not “be concise.” It is pre-deciding the slice. Plan mode (Shift+Tab in Claude Code) helps on multi-step work: Claude explores and proposes an approach before spending an implementation loop on the wrong design. [VERIFY: 2026-09-19]
Course-correct early: Escape stops a wrong direction; /rewind or double-Escape restores a checkpoint. Fixing a bad path after three tool rounds is cheaper than letting it finish — but cheaper still is stating the path in the first message.
For how the window fills with tools, history, and files, see Claude’s context window.
2. File-reading discipline: the function, not the repository
Claude Code’s tools make it easy to cat entire files “just in case.” That habit turns every edit into a context tax that sits in the thread for the rest of the session.
Rules that clear a real savings bar:
- Prefer go-to-definition / symbol navigation (and code-intelligence plugins on typed languages) over grep-then-open-five-candidates. [VERIFY: 2026-09-19]
- Ask for regions: “read lines 80–140 of
auth.ts” or “only thevalidateSessionfunction.” - Prefer diffs and patches over “rewrite the whole file.”
- When debugging tests, feed failure slices, not full suite logs — hooks that grep
FAIL|ERRORbefore Claude sees the log are exactly for this. [VERIFY: 2026-09-19]
Before: six full files (~14,000 tokens of tool results) to change one constant.
After: one 40-line region (~120 tokens) + edit.
This is the coding-loop version of “source cards instead of PDFs” from the general cut-usage list — same economics, different surface.
3. CLAUDE.md, skills, and standing instructions
CLAUDE.md loads at session start. Detailed PR-review rituals, migration runbooks, and “how we ship” novels tax every turn — including “rename this variable.” Anthropic’s guidance: keep CLAUDE.md under ~200 lines of essentials; move specialized workflows into skills that load on demand. [VERIFY: 2026-09-19]
Before: 900-token always-on shipping novel × 50 turns of mixed work.
After: 180-token essentials in CLAUDE.md + a /ship skill that injects a 220-token checklist only when invoked.
Same rule for project instructions and MCP server instructions: if it is not needed for most turns, do not keep it in the hot path.
4. When to start a fresh session (/clear, /compact, /rename)
Conversation history is re-sent (or re-held) as the agent works. A session open all morning for “Monday tickets” is how people empty a five-hour bar and still feel like they barely typed. Anthropic’s costs page is explicit: clear between unrelated tasks; stale context wastes tokens on every subsequent message. [VERIFY: 2026-09-19]
Use /clear when: the task identity changed (new ticket, new package, new incident); the thread contains failed explorations you no longer need; /usage shows long-context as a dominant behaviour flag.
Use /compact when: you need continuity but the window is fat — add focus instructions (/compact Focus on the auth.ts diff and failing test names). Compaction itself reads the conversation it summarizes, so compacting a huge thread is a large request; when you want a true fresh start, /clear is free by comparison. [VERIFY: 2026-09-19]
Use /rename before clearing so you can /resume later without losing the old thread’s identity.
Before (illustrative): turns 20–28 of a mixed Monday thread each see ~22,000 tokens of prior context → ~198,000 cumulative input-side exposure across those nine turns.
After: new session per ticket with an 8–12 line handoff (goal, decisions, paths, next ask) → ~2,500–4,000 tokens of relevant context.
Carry a summary, not a history. Check the effect with how to check your Claude usage — Settings → Usage on seats, /usage in the CLI, Console for keys.
5. Subagents: when they save vs when they waste
Subagents and agent teams are not free parallelism. Each worker owns a context window. Anthropic notes agent teams can use on the order of ~7× tokens versus a standard session when teammates run in plan mode. [VERIFY: 2026-09-19]
They save when:
- Each worker gets a distinct slice (directory A vs B; question 1 vs 2).
- The parent brief is sharp and mergeable (“return three bullets + file paths”).
- Scouts run on Haiku; merge/implement on Sonnet.
- Step caps and kill switches exist; finished teammates shut down.
They waste when:
- The same ambiguous brief is copied to every worker.
- Every worker loads the same repo dump or CLAUDE.md monster.
- Assignments overlap (“everyone research auth”).
- Fan-out substitutes for writing a better single prompt.
- Teammates stay alive after their work is done.
Deep checklist: Claude subagents — when they save vs double tokens. For Claude Code specifically: keep spawn prompts focused, prefer Sonnet for teammates unless the task is trivial (then Haiku), and keep teams small. [VERIFY: 2026-09-19]
Before: five teammates × overlapping monorepo survey in plan mode → order-of-magnitude token multiplier with redundant findings.
After: two workers on disjoint directories, report-only, Haiku scouts → parent merges a short plan, then one Sonnet implementation session.
6. Claude Code prompt caching in a coding loop
Claude Code already uses prompt caching for repeated content such as system prompts and stable prefixes. Your job is to stop invalidating the cache and to understand what a miss costs in a long session. [VERIFY: 2026-09-19]
On Anthropic’s published API multipliers, a cache write is typically 1.25× (5-minute TTL) or 2× (1-hour TTL) versus base input; a cache read is typically 0.1× base input on most models. Exact product TTL on seats vs usage credits can differ — confirm in current docs and in /usage prompt-cache stats when available. [VERIFY: 2026-09-19]
What causes expensive misses in a coding loop:
- Editing tool definitions / MCP server set mid-session.
- Shuffling “static” instructions above the cache breakpoint every turn.
- Idle gaps longer than the cache lifetime, then resuming a huge thread (full reprocess).
- Injecting timestamps, random IDs, or unsorted tool JSON into the stable prefix.
What keeps hits healthy:
- Stable CLAUDE.md + tools for the duration of a task.
/clearbetween unrelated tasks instead of dragging Monday into Tuesday’s prefix.- Watching cache-read vs cache-write lines in
/usage(and status-lineprompt_cachewhere supported). [VERIFY: 2026-09-19]
Illustrative API-style math (method demo): 40,000-token tools+system prefix × 20 uncached Sonnet-class calls at $3/MTok input → 800,000 input tokens ≈ $2.40 for that prefix alone. One 5m write (1.25×) + 19 reads (0.1×) → roughly $0.38 for the same prefix once hits are steady. [VERIFY: 2026-09-19]
Full write/read mechanics and break-even: Anthropic prompt caching pricing — the plan anchor for caching in a coding loop. Caching does not shrink output tokens and does nothing if your “static” prefix changes every request.
7. Model, thinking, and MCP — three secondary levers that still clear ~5%
Model match. Sonnet handles most coding. Reserve Opus for hard architecture or ambiguous multi-step reasoning. Specify Haiku for simple subagent tasks. Use /model mid-session; set a default in /config. [VERIFY: 2026-09-19]
Extended thinking. Thinking tokens bill as output. Leave deep reasoning on for hard plans; lower effort or disable thinking for simple edits where the product allows. [VERIFY: 2026-09-19]
MCP surface. Prefer CLI tools (gh, aws, gcloud) when they exist — they add no per-tool listing. Disable unused MCP servers via /mcp. Deferred tool definitions still contribute names and server instructions. [VERIFY: 2026-09-19]
These three rarely beat context + file discipline + /clear, but they compound — especially on API-authenticated fleets sitting inside Anthropic’s $150–250/dev/month coding band. [VERIFY: 2026-09-19]
A practical morning checklist (stepwise)
- Open
/usage(or Settings → Usage). Note session bar and any behaviour flags (long context, cache misses). - Write the ticket ask with path + Done definition before the first tool call.
- Confirm CLAUDE.md is essentials-only; park runbooks in skills.
- Disable MCP servers you will not use today.
- Default model: Sonnet (Haiku for scout subagents; Opus only when stuck).
- When the ticket identity changes:
/rename, then/clear(or/compactwith focus if you must keep continuity). - Before spawning subagents: distinct slices, caps, and a merge plan — or don’t fan out.
- If you are on API keys with a stable agent prefix, treat cache stability as a first-class habit (see caching section).
- End of block: glance at
/usageagain. If nothing moved, you optimized the wrong lever.
Measure twice: once with current habits, once after two changes. If the meter did not move, you probably polished wording while a fat session or overlapping subagents did the real damage.
What not to bother with
Skip deleting “please.” Skip rewriting one comment to save three tokens. Skip “always Opus” and “never Opus” without an acceptance check. Skip caching theatre when every prompt is unique. Skip five subagents on one fuzzy brief. Skip buying a higher Max tier before you try /clear and scoped file reads — seat depth does not fix a context-hygiene problem.
FAQ
How do I reduce Claude Code token usage without slowing down?
Scope the ask, read regions not repos, and /clear between unrelated tickets. Those three usually recover more capacity than typing faster into a fat session.
What are Claude Code reduce token usage best practices?
Treat context like a budget: specific prompts, thin CLAUDE.md, disciplined file reads, session resets on task change, Haiku for simple subagents, and cache-stable prefixes on API loops. [VERIFY: 2026-09-19]
Does Claude Code prompt caching happen automatically?
Claude Code applies prompt caching for repeated content such as system prompts. You still cause misses by changing tools/instructions mid-loop or resuming huge cold sessions. Details: prompt caching pricing. [VERIFY: 2026-09-19]
When should I use subagents to save tokens?
When slices are independent and mergeable. If the brief is fuzzy or every worker needs the full monorepo, subagents multiply spend — see subagents. Agent teams in plan mode can run ~7× a standard session. [VERIFY: 2026-09-19]
How is this different from the general “cut token usage” page?
11 ways to cut usage covers chat, Projects, and cross-surface habits. This page is the coding-loop companion: /clear, file tools, CLAUDE.md, subagents, and caching while you iterate on a repo.
Next steps
- Run today’s next ticket with a scoped ask and a region read — no whole-repo “just in case.”
- When you switch tickets,
/clearwith a short handoff summary. - If API agents share a stable tools+system prefix, implement and monitor caching in a coding loop.
- If the same waste shows up across the team — fat sessions, overlapping subagents, Opus defaults — get a written review via the audit. See an example report. For the pattern list an audit typically names, see what a token audit finds. No dollar price on this page.
For monthly planning numbers, keep Claude Code costs open. For the general checklist outside the terminal, use cut token usage.
If you only do one thing after reading: /clear at the next unrelated task, with an eight-line summary instead of the old thread — then stop opening whole files when a 40-line region would do. Those two moves alone clear a real savings bar for most people who arrived here angry at a Claude Code usage limit.