Claude Code token cost: where the tokens actually go

Token cost in a chat is simple: you send some, you get some back. Token cost in an agent loop is not, because the loop re-sends everything it has accumulated on every request. That one property explains almost every surprising bill.

By the Continuum team. We build a workbench that runs Claude Code, Codex, and their peers, so the model rates quoted here are the ones our own cost analytics ship with.

The short version

A Claude Code session is typically 90 to 97 percent input tokens, because the agent reads far more than it writes and re-sends the accumulated context on every request, including one request per batch of tool results. Cost therefore grows closer to the square of turn count than linearly. Prompt caching cuts the repeated portion to 0.1x base input, which is what makes long sessions affordable, and a cache miss after a break undoes that for one request.

What you need to know
  • A coding session is overwhelmingly input tokens, usually 90 to 97 percent.
  • Every request re-sends the accumulated conversation, so cost scales with turns squared.
  • Cache reads cost 0.1x base input. A 5-minute write is 1.25x, a 1-hour write is 2x.
  • The cache lifetime is an hour on a subscription, five minutes on an API key.
  • Tool output is input. A command that prints 4,000 lines has bought 4,000 lines of context.
  • Claude 4.7-generation models use a newer tokenizer producing about 30 percent more tokens for the same text.

The four kinds of token you pay for

Token categories and their relative price, using Sonnet 5 standard rates as the reference.

KindWhat it isMultiplierRate / MShare of a session
Input (uncached)New content sent this request1x$3.005 to 20%
Cache write (5 min)Content stored for reuse1.25x$3.75small, recurring
Cache write (1 hour)Longer-lived store2x$6.00small, one-off
Cache readRepeated prefix re-read cheaply0.1x$0.3070 to 90%
OutputWhat the model generates5x$15.003 to 10%

The shape of that table is the whole story. The expensive per-token category is output, but it is a rounding error by volume. The category that decides your bill is cache read: cheap per token and enormous by volume.

A fifth category that bills as output

Extended thinking tokens are billed as output tokens, and the default budget can run to tens of thousands per request. On simple work that is money for nothing. Lower it with /effort, disable thinking in /config, or on models with a fixed thinking budget set MAX_THINKING_TOKENS, for example MAX_THINKING_TOKENS=8000. Adaptive-reasoning models ignore a nonzero budget, so use effort levels there.

Why loops multiply

A chat exchange sends context once. An agent loop sends it again on every request, because the model has to see the whole conversation to decide the next action, and every batch of tool results is itself another request carrying that whole history.

Worked example

Suppose a session starts with 20k tokens of system prompt and project context, and each turn adds about 5k tokens of file contents, command output, and reasoning.

Cumulative input tokens across a session. Uncached, to show the underlying growth.

TurnContext sizeSent this turnCumulative sent
120k20k20k
540k40k150k
1065k65k425k
20115k115k1.35M
30165k165k2.8M

Thirty turns of a session that only ever accumulated 165k tokens of actual content has sent 2.8 million tokens. That is the quadratic term, and it is why a session that felt short can produce a bill that does not.

The cache-miss cliff

The flattening depends on the cache still being warm. The lifetime is an hour on a subscription, five minutes by default on an API key or a cloud provider, and five minutes on a subscription once you are drawing on usage credits. The first message after a longer break reprocesses your full context at 1x, not 0.1x. On a 150k-token session at Sonnet 5 standard rates that is $0.45 for a question you assumed was nearly free, and on Opus 5 it is $0.75.

On a paid plan, /usage flags cache misses as a behavior when they account for 10 percent or more of your recent usage, so you do not have to infer it.

Columns growing across a session: each turn re-sends everything sent before it, so 165 thousand tokens of real content becomes 2.8 million tokens actually sentTOKENS SENT PER TURNnew this turnre-sent165k of content that existscumulative across 30 turns2.8M sentturn 1turn 30Caching prices the repeat at 0.1x. It does not stop it being sent.

What consumes tokens in a real session

Ranked by how much they typically add to a session.

SourceTypical sizeControllable?
File contents read by the agent1k to 20k tokens per fileYes, by naming files
Command and test output200 to 10,000+ tokens per runYes, by scoping commands and using hooks
Search and grep results500 to 5,000 tokensYes, by being specific
CLAUDE.md and project memoryLoaded at session start, present on every requestYes, by moving detail into skills
System promptA few thousand tokens, every requestNo
MCP tool definitionsNames only by default; full schemas on demandYes, by disabling unused servers
Model reasoning and replies200 to 3,000+ tokens per turnYes, via /effort
Agent teammatesA full context window eachYes; off by default

What the startup budget looks like

Anthropic publishes a representative breakdown of what loads before you type anything: the system prompt around 4,200 tokens, auto memory around 680, environment info around 280, deferred MCP tool names around 120, and the skill listing around 450. Roughly 6k tokens of floor, present on every request for the life of the session. Your CLAUDE.md sits on top of that.

The CLAUDE.md trap

A project memory file loads at session start and is present in context even when you are doing unrelated work. A tight file is excellent value: it stops the agent rediscovering conventions repeatedly. A sprawling one is a tax you pay on every request of every session forever, and it is one of the most common self-inflicted token costs.

Anthropic's guidance is to keep CLAUDE.md under 200 lines and move workflow-specific instructions into skills, which load on demand only when invoked. A PR-review procedure and a migration checklist do not need to be in context while you fix a CSS bug.

Token cost of common tasks

Rough token consumption by task, Sonnet 5 at standard rates, with caching in effect.

TaskInputOutputApprox cost
Explain a file you paste in8k1k$0.04
Fix a test you already located30k4k$0.15
Small feature, 3 files, known location120k15k$0.59
Same, agent has to find the files400k25k$1.58
Refactor across 12 files900k60k$3.60
Long autonomous run in a large repo4M200k$15.00
Idle session, background summarization onlyminimalminimalunder $0.04

The two rows worth studying are the middle pair. Identical work, different prompt precision, roughly three times the cost. Nothing else on this page has that leverage.

The last row is worth knowing for a different reason: Claude Code uses a small number of tokens for background work such as summarizing previous conversations for claude --resume, typically under $0.04 per session. It is real but it is not your problem.

Cutting the token bill

In order of leverage, which is not the order people usually try them in.

  1. Write specific prompts. "Add input validation to the login function in auth.ts" versus "improve this codebase". The second triggers broad scanning and pays for all of it.
  2. /clear between unrelated tasks. Free, instant, and it makes the answers better as well as cheaper. Use /rename first if you want to /resume later.
  3. Filter tool output with a hook. A PreToolUse hook on Bash that greps a test run for failures turns a 10,000-line log into a few hundred tokens before the model ever sees it.
  4. Delegate verbose reads to subagents. The log stays in the subagent context window; only a summary returns to yours.
  5. Match the model to the job. Sonnet for most work, Haiku for mechanical subagent tasks, Opus for genuinely hard reasoning.
  6. Move detail out of CLAUDE.md into skills. Under 200 lines in memory, everything else loaded on demand.
  7. Turn effort down when the task is easy. Thinking tokens bill as output.
  8. Prefer CLI tools to MCP servers where both exist. gh, aws, and gcloud add no per-tool listing at all. Run /mcp and disable servers you are not using.

Applied together these routinely halve a session without changing what gets built. The first three are worth more than the rest combined.

Questions people ask

Because a coding agent reads far more than it writes, and because every request re-sends the accumulated conversation so the model can decide the next action. Every batch of tool results triggers another request carrying that history again. A typical session is 90 to 97 percent input.

Cache reads cost 0.1x base input, a five-minute cache write costs 1.25x, and a one-hour write costs 2x. On a long session where most of each request is repeated prefix, that commonly takes 40 to 70 percent off the total.

An hour on a subscription, five minutes by default on an API key or a cloud provider, and five minutes on a subscription once you are drawing on usage credits. The first message after a longer break reprocesses your full context at full input price.

Yes. Anything a command prints comes back into the conversation and is input on the next request. Running a full test suite that prints thousands of lines is a direct and usually avoidable cost; a PreToolUse hook that filters to failures fixes it permanently.

Run /usage for per-session token counts by model plus, on a paid plan, an attribution breakdown across skills, subagents, plugins, and MCP servers. Run /context for what is occupying the window right now. Both read local session history on that machine only.

Less than you would think. They are five times the price but usually under a tenth of the volume, so input still dominates the bill in nearly every coding session. The exception is heavy extended thinking, which bills as output and can run to tens of thousands of tokens per request.

Yes, on every request of every session, because project memory loads at session start and stays in context. Anthropic recommends keeping it under 200 lines and moving workflow-specific instructions into skills, which load only when invoked.

Yes. Claude 4.7-generation models and later use a newer tokenizer that produces roughly 30 percent more tokens for the same text. The per-token rate can be unchanged and the per-file cost still goes up, so compare cost per task rather than cost per token when a model changes.

Sources

Every figure above was read from these pages on August 2026. Vendors reprice without notice; if you find a stale number, tell us.

  1. Anthropic API pricing
  2. Claude Code documentation
  3. ccusage on GitHub
Try it

Every token,
attributed.

Continuum splits input, cache write, cache read, and output per session and prices each at the rate that applied when it happened, across every agent you run.

free app · your subscriptions · local-first