Why Claude Code feels expensive (the token mechanics)
Last verified
The short answer: you pay to re-read the conversation on every turn, and the conversation contains your codebase.
Here is the actual shape of the bill, measured from a real 178-request Claude Code session on Claude Opus 5:
| Tokens | Share of tokens | Cost | Share of cost | |
|---|---|---|---|---|
| Fresh input | 331 | 0.0% | $0.00 | 0% |
| Output | 308,900 | 0.5% | $7.72 | 16% |
| Cache writes (1h) | 1,130,223 | 1.9% | $11.30 | 24% |
| Cache reads | 57,690,000 | 97.6% | $28.85 | 60% |
| Total | 59.1M | $47.88 |
Note what is _not_ there. Fresh input tokens — the things you actually typed — cost essentially nothing. 331 tokens across the whole session.
The mechanism
An agent loop is stateless underneath. Each turn sends the entire conversation so far:
- your instructions
- every file that has been read
- every tool call and its complete output
- every prior reasoning step
Turn 1 sends a few thousand tokens. Turn 50 sends everything from turns 1–49. Cost per turn rises as the session continues — a long session is superlinear, not linear.
Three amplifiers on top:
Files are enormous compared to prose. Reading one 800-line source file puts ~10,000 tokens into context permanently. A chat conversation of the same wall-clock length might total 2,000.
Tool output is uncontrolled. A search that returns 200 matches, a test suite that dumps a long failure, a large JSON response — all of it enters the context and stays.
Reasoning tokens are billed output you never see. They appear in the usage numbers, not in the text on your screen.
Why the total isn't ten times worse
Prompt caching. Cache reads cost 0.1× the base input rate.
In that measured session, 57.7M cache-read tokens cost $28.85. At the uncached input rate the same tokens would have been roughly $288. Caching cut the bill by about 85%.
So the honest framing is not "Claude Code is expensive because of caching" — it is "Claude Code would be unusable without it." What caching does _not_ do is make the underlying dynamic go away: context still grows, and 10% of a very large number is still a number.
What this means practically
Long sessions cost more per turn than short ones. The 50th message in a session is more expensive than the 5th, for identical work. Starting a fresh session for an unrelated task is a genuine saving, not superstition.
Reading files is the expensive operation, not writing them. Output is 16% of cost. Pulling half a codebase into context is what moves the number.
Cache writes have a break-even. The 1-hour cache costs 2× base input and pays back after two reads. In a working session that's immediate. In a session that writes a large cache and then ends, you paid the premium for nothing — another argument against opening a long session for a one-line question.
Subagents are separate spend. Sidechain turns carry their own context. They're often worth it — a subagent that reads twenty files and returns a summary keeps those twenty files out of your main context — but they are not free.
Seeing it for yourself
npx @tknapp/cli agents --days 30 --by session
Reads the local logs, prices them, and breaks the total down. No API key, no network call. Group by model, project, session or branch to find where it actually goes.
Then: how to reduce Claude Code costs — the changes that measurably move this, in order of effect.
Sources
- Anthropic — Pricing and prompt caching multipliers (verified 2026-08-05)
- Claude Code — Manage costs effectively