Guides · Updated October 24, 2026

Why Claude Code uses so many tokens, and how to use fewer

You asked for a few bug fixes and half your 5-hour window is gone, or the API bill for one afternoon is bigger than last week’s. Claude Code’s token use is driven less by what you type than by how much context gets re-sent and how many requests a task fans out into. Here is where the tokens actually go, how to see which one is hitting you, and the changes that cut usage the most.

Where the tokens go

From Anthropic’s Manage costs effectively page, plus what that means in practice:

Find out which one is hitting you

The changes that save the most

  1. /clear between unrelated tasks. Stale context is re-sent with every later message. /clear costs nothing; /compact has to read the whole conversation to summarize it, so compacting a huge context is itself a big request. Use /rename first if you want to /resume it later.
  2. Match the model to the job. Sonnet for routine edits, Opus for hard design problems. Switch with /model; set model: haiku for simple subagents.
  3. Turn thinking down for simple work. Lower the effort with /effort (or in /model). On models that allow it, thinking can be disabled in /config.
  4. Bound the fan-out. Say how many subagents you want (“use at most 2 subagents”) or ask it to fix issues one at a time. “Fix everything you flagged, be extra careful” on Opus is the most expensive sentence you can type.
  5. Trim what is always loaded. Keep CLAUDE.md under about 200 lines and move workflow-specific instructions into skills, which load only when used. Disable MCP servers you aren’t using with /mcp; a CLI like gh costs no context until it runs.
  6. Keep verbose output out of the main context. Ask for failures only (pytest -q, grep the log) or have a subagent read the 10,000-line log and return a summary. Anthropic’s docs include a PreToolUse hook that rewrites test commands to show only failures.
  7. Plan first, correct early. Plan mode (Shift+Tab) before a big change avoids paying for a wrong implementation. If it heads the wrong way, press Esc and /rewind instead of letting it finish.
  8. Watch idle features. Stop /loop tasks you no longer need, and remember a session left open over lunch will miss the cache on your next message.

Stop the expensive mistakes automatically

The habits above reduce normal usage. The spikes, the session that eats a whole window in 30 minutes, usually come from a loop or a fan-out nobody was watching. Claude Code’s native caps are coarse: plan windows, monthly usage-credit and Console workspace limits, and --max-budget-usd for headless claude -p runs only (see Claude Code spending limit). Nothing native stops an interactive session at $10, or notices the same test run with the same result for the eighth time.

LoopGuard is an open-source (MIT) CLI that adds those checks as Claude Code hooks. It needs no proxy and no API key, so it works on Pro and Max as well as API billing:

npm i -g loopguard-cli
loopguard init --agent claude      # PreToolUse, PostToolUse, PostToolUseFailure and Stop hooks
loopguard config set sessionCapUsd 10   # estimated $ per session (default 25)
loopguard config set dailyCapUsd 40     # estimated $ per local day (default 100)
loopguard report --by session           # what your recent sessions cost, estimated

Checks run at each tool call, so a single long response isn’t cut off mid-stream, and work outside Claude’s tool calls (a background process it started, another app calling the API) isn’t seen. Keep your billing-side limits set too.

Related

LoopGuard on GitHub · Pricing