Get the most from CoreCode
Spending less on Claude Code
Spending tens of dollars a day on Claude Code is common. Most of it does not go on writing code but on the context resent every turn. This page shows where the money goes, then ways to spend less without losing quality. Caching in detail is in Caching and billing.
- Most of the bill is the context resent every turn, the input side, not the output.
- At Anthropic's prices, a cache read on Opus 5.5 and Sonnet 5.5 is 0.05 times the input price (0.1 on Haiku 5.5), a 5-minute cache write 1.25 times and a 1-hour cache write 2 times.
- Use Sonnet for everyday work and Opus for hard problems, and pick the model at the start of a task.
/clearwhen you change tasks,/compactlong sessions in time, and keepCLAUDE.mdand MCP lean.- Auto mode's classifier request before each tool call barely hits the cache and can take a large share of the spend.
Where the money goes
Every turn, Claude Code resends the system prompt, tool definitions, the files it has read and the whole conversation. A session that has been going a while sends tens of thousands to hundreds of thousands of tokens per turn and gets back a few hundred to a few thousand. So:
- Input far exceeds output. Most of the bill is usually on the input side.
- Caching sets the input price. Cached input costs 5% of the input price on Opus 5.5 and Sonnet 5.5; a miss is written again at the write price, 25 to 40 times a cache read (multipliers in Anthropic's prompt caching pricing).
- The longer the context, the dearer every turn. The same "change it again" costs ten times more in a 300K-token session than in a 30K one.
Spending less comes down to three things: the right model, a cache that keeps hitting, and a context that does not grow for nothing.
1. Pick the right model
- Use Sonnet for everyday work. Fixing bugs, writing tests and docs, building a clearly specified feature: Sonnet is enough, at far less than Opus. Switch with
/model, or start withclaude --model claude-sonnet-5-5. - Save Opus for hard problems. Architecture, refactors across many files, and problems Sonnet keeps getting wrong are worth Opus.
- Choose the model when a session starts. The cache is per model, so switching mid-session rewrites the whole context at the write price on the next turn. Switch at the start of a task, or
/compactright after switching.
Unit prices are in the pricing table, and what each model suits is in Choosing a model.
2. Keep the cache hitting
- Finish a task in one session. Do not switch models or thinking effort, or connect and disconnect MCP servers, midway; each of these invalidates the cache.
- Turn on the 1-hour cache if you pause often. The default cache lasts five minutes, so the first turn after a meeting rewrites everything. Add
"CLAUDE_CODE_PROMPT_CACHE_TTL": "1h"toenvinsettings.json; see the 1-hour cache. - Pick a relay with session stickiness. If one session's requests hop between upstream accounts, the cache misses nearly every turn and the bill can multiply. CoreCode pins each session ID to one account; for other relays, the cache check in the checking script shows it.
3. Keep the context lean
/clearwhen you change tasks. The last task's files and conversation are no use to the next one, yet they are sent every turn./compactlong sessions in time. The first turn after compacting rewrites the cache; every turn after it is cheaper. Do not start a new session and lay out the context again to feel fresh; that costs more than compacting.- Consider turning off the 1M context. Add
"CLAUDE_CODE_DISABLE_1M_CONTEXT": "1"toenv. The limit becomes 200K, auto-compaction starts sooner, and each turn sends less. - Trim CLAUDE.md and MCP.
CLAUDE.mdis sent every turn; state the rules, do not paste whole documents. Disconnect MCP servers you do not use, and keep the default MCP tool search on (do not setENABLE_TOOL_SEARCH=false).
Do the sums on auto mode
Auto permission mode has to judge whether each action may run. CoreCode passes Claude Code's server-side review through, so normally there are no extra requests. If you set CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS, though, Claude Code sends a separate classifier request before every tool call instead: these barely hit the cache, in a real case they were a third of the requests and 60% of the spend, and on CoreCode they run on your session's model. CoreCode does not need that variable; remove it. From Claude Code v2.1.283 new sessions start in auto; when you do not need it to run unattended, press Shift+Tab to switch to Manual or "accept edits" mode. The full analysis is in The cost of auto mode.
Check where the money went
- Type
/usage(or/cost) in Claude Code for this session's usage and cost, and/contextfor what fills the context. - In the console's usage logs, read consecutive requests in time order: cache reads growing steadily with cache writes of a few hundred to a few thousand is normal; one request whose cache write is suddenly close to the whole context means the prefix changed.
- Many non-streaming requests, each writing tens of thousands of tokens, are most likely auto mode's checks.
- A model you never chose on the bill is usually background summaries, subagents or the auto classifier; see Other models on the bill.
Anthropic's own Claude Code costs guide lists more ways to manage spend. If the logs still do not explain it, send us the times of those requests and we can look up the upstream account and routing.
FAQ
Why does Claude Code use so many tokens?
Every turn it resends the system prompt, tool definitions, the files it has read and the whole conversation. The longer the session, the more each turn sends; on a cache hit that part costs 5% of the input price on Opus 5.5 and Sonnet 5.5.
How do I see what a session cost?
Type /usage (or /cost) in Claude Code, and /context for what fills the context; the console's usage logs list the usage and cost of every request.
Is the 1-hour cache always cheaper?
No. A 1-hour cache write costs 1.6 times a 5-minute one (2 against 1.25). It pays off only if you often pause for more than five minutes; with few pauses it costs more.
I only use Opus, so why is there Haiku or Sonnet on my bill?
Background summaries, subagents and auto mode's classifier use other models; see other models on the bill.