August 15, 2026, (Inside AI) — Anthropic has published a detailed technical guide on how users can cut costs and extend session limits when working with Claude Code, its terminal-based coding assistant. The company explains that every request passes through a GPU in two distinct phases, and understanding this split is the key to controlling spending.
The first phase, called prefill, involves the model reading the entire conversation context: the system prompt, user instructions, files Claude has opened, and outputs from commands it has executed. Those are input tokens. The second phase, decode, generates output tokens one at a time. A 200-token response means the model runs 200 separate decode steps. Because decode keeps the GPU busy much longer per token, output is priced at roughly five times input.
This asymmetry matters because a large share of output tokens in any Claude Code session are thinking tokens, which the model uses to plan before responding. The effort level setting controls how much thinking occurs per turn, and like the model choice, the effort level persists as a default across sessions. Anthropic advises users to run /model
and /effort
once in a fresh session to see current settings. For low-stakes grunt work, the command claude
can disable thinking entirely for one session, except on Fable 5, where it is not available.
The guide’s central cost mechanism is prompt caching. When a request begins with the exact same tokens as a previous one, the server reuses the computed state for that shared prefix instead of recomputing it. Cache reads cost 0.1 times the input price, while cache writes cost up to 2 times normal input. But the write happens once per token, and every subsequent turn benefits from the 0.1x read rate.
Claude Code manages prompt caching automatically, but users can inadvertently break it. For example, typing “fix the failing test in” triggers five separate requests, each containing the entire conversation history. Only new tokens in each turn are prefilled at full price; the rest are cache reads. Anthropic notes this applies to subscription users too, since the same requests draw down usage limits.
Cache invalidation occurs when anything changes toward the front of the request prefix. Switching models forces a full re-prefill at full price, including transitions in and out of plan mode with opusplan. Changing the effort level has the same effect. Fast mode is also part of the cache key, so users should enable it at the start of a session. Compacting the conversation replaces it with a shorter one, invalidating the cache, though writing the summary is cheap if the old conversation is still cached. Time is another factor: the cache expires after one hour on a subscription or five minutes on an API key, though the --cache-ttl
flag can extend it to one hour. Resuming an old session almost always triggers a full re-prefill.
Anthropic recommends rewinding to just before unwanted turns instead of compacting, because rewinding only cuts turns off the end and preserves the cache for everything before them. Compacting always costs something.
Context bloat is the real budget killer #
The guide emphasizes that nothing gets sent just once. Every file Claude reads or command output it sees is resent on every subsequent turn for the rest of the session. Cache reads make this cheap, but cheap is not free, and bloated context forces the model to think around irrelevant data.
Several factors determine how many tokens end up in context. Tool definitions, the system prompt, and CLAUDE.md load at startup. Users should keep CLAUDE.md specific and move workflow instructions into skills, which load only when used. Unneeded MCP servers can be disabled with /mcp
.
Most context growth comes from tool results. If a user says “the tests are failing,” Claude must grep for relevant files and read several candidates, all of which stay in context. A more specific instruction like “Fix the failing test in
Command output is another major source. Outputs under 30,000 characters are appended to the conversation in full. A test runner printing 400 passing lines stays under the limit and becomes part of every remaining turn. Anthropic suggests adding quiet flags to frequently used commands or using a hook to rewrite noisy commands before they run.
Subagents and session hygiene limit token drag #
Long sessions cost more than the same work spread over several short ones, because turn 40 re-reads the previous 39 turns. Anthropic advises starting a new session when beginning a new task and compacting when the earlier part of a task is done. Users should run /export
before clearing if they want to restore the session later, and can add a “Compact instructions” section to CLAUDE.md. For 1M-token models, the --auto-compact
flag restores the auto-compact safety net in Claude Code v2.1.221 or later.
Background tasks also consume turns. A cron job fires as a full turn in the session where it was set up, carrying the entire conversation each time. If more than an hour has passed, it is also a cache miss. Anthropic recommends running loops from a fresh session in another terminal.
Subagents offer a way to keep noisy work out of the main context. Each subagent gets its own context window, system prompt, tools, and permissions, but not the main conversation. It runs its own turns and returns only its final answer. This is ideal for jobs that produce lots of disposable output, like log analysis. Users can assign a subagent definition with model: haiku
or sonnet
for repetitive noisy tasks, keeping the main session lean. Anthropic’s guide concludes with four monitoring priorities, roughly ordered by cost impact: model choice, effort level, context size, and session length. The company frames the entire cost model as a function of how many tokens enter the context, how many turns they persist, and how many contexts run simultaneously.