Claude is good at long-context work, which is exactly why the token bill can get away from you. The model will happily read a large prefix every turn, and you will pay for it every turn unless the prefix is cached and the session is structured.
These are the levers I use, in the order they matter.
1. Cache the stable prefix
Anthropic's prompt caching lets you mark a prefix as reusable. Cache reads bill at roughly 10% of base input, and cache writes carry a small premium, so the crossover comes after a couple of turns rather than immediately.
The mechanics are the same as any prefix cache: a byte-stable block at the start, volatile content at the end, and no mutation in the middle.
For Claude specifically:
- Put the system prompt, skills, tool definitions, and reference documents in the cached block.
- Put the user message, the current date, and the latest tool result after it.
- Set the cache breakpoint at the end of the stable block, not at the end of the whole prompt.
- Keep the block identical between turns. A reformatted JSON schema is a different prefix.
If the cache write premium worries you, do the math on your session length. A write premium that pays back after two turns is irrelevant in a 40-turn session and a loss in a one-shot call.
2. Stop switching models mid-session
Each model has its own cache namespace. Switching from Sonnet to Opus in the middle of a session forces a new prefix prefill, and the previous cache does nothing for the new model.
If a task needs a stronger model, start the session on the stronger model, or finish the cheap work and start a new session for the hard part. The second option is usually cheaper, because the hard part gets a clean, small context instead of inheriting the whole exploratory history.
3. Route by task, not by preference
A practical routing policy for a Claude-based stack:
| Task | Tier | Reason |
|---|---|---|
| Classification, tagging, routing | Small model | Narrow answer space |
| Extraction from a known format | Mid-tier | Pattern matching with a schema |
| Drafting from a template | Mid-tier | Human review catches the rest |
| Multi-document analysis | Frontier | Long-range reasoning |
| Architecture, board-level synthesis | Frontier | Ambiguity and stakes |
My own production chain reflects this. DeepSeek V4 Pro handles routine work, Claude Sonnet 4 is the fallback when DeepSeek degrades, and Claude Opus 4 is reserved for architecture and complex synthesis. Haiku is excluded by policy on this stack, because the quality bar for the work does not tolerate a small-model miss.
The specific names will age. The shape will not: a cheap default, a fallback that is good enough, and a frontier tier for the work that genuinely needs it.
4. Use subagents to isolate context
A subagent gets its own context window. That is a cost tool as much as an architecture tool.
The pattern: the main session holds the plan and the decisions. A subagent gets one bounded task, a small set of tools, and a clean context. It returns a summary, not its entire transcript.
Two rules make this work:
- Give the subagent a narrow brief and a defined output format.
- Do not let the subagent inherit the full parent history. The whole point is the smaller context.
A subagent that reads the same 100,000-token parent context has saved nothing.
5. Batch what can wait
Batch endpoints are commonly priced at about half the synchronous rate, because the work can be scheduled. Reports, backfills, classification runs, and bulk summaries belong there.
Interactive work does not. A person waiting on an answer is paying for latency with attention, and the discount is not worth it.
6. Keep the tool payload small
Claude is good at reading tool results, which is a risk. A tool that returns a 10,000-token JSON blob will be read in full, and every later turn resends it.
Filter at the server. Return the fields the task needs, paginate by default, and summarize long results before they enter the context. A tool that returns less is cheaper and usually more accurate, because the model is not distracted by noise.
7. Compress once, late
Context compression is useful and easy to overuse. One compression event near the context limit is a saving. Five in a session rewrite history repeatedly, and each rewrite invalidates the cache.
If a session is going to be long, plan the compression point. Keep the decisions, the current task, and the open questions. Drop the exploration.
What the bill looks like when it works
On a production Hermes deployment measured from June 9 to July 8, 2026, the system processed 9,691,748,399 tokens at a total cost of $210, with 96.61% served from cache. The primary model on that deployment is DeepSeek V4 Pro, with Claude as the fallback and strategy tier.
The lesson transfers to a Claude-only stack: the prefix is the cost driver, the cache is the lever, and the model choice is the second lever. A Claude deployment with an unstable prefix will cost more than a DeepSeek deployment with a stable one, because price per token is not the only variable.
A Claude cost checklist
- The system prompt and tool definitions are byte-stable between turns.
- The cache breakpoint sits at the end of the stable block.
- Volatile values are after the breakpoint, never before.
- The session does not switch models mid-conversation.
- Routine tasks route to a smaller tier.
- Subagents get a narrow brief and a small context.
- Tool results are filtered and paginated at the server.
- Batch work goes to the batch endpoint.
- Compression happens once, late, and deliberately.
- Token usage per model is logged and reviewed weekly.
Eight of ten is a cost program. Four of ten is a hope.
Where Claude cost programs fail
Caching is enabled but the prompt is dynamic. The feature is on and the hit rate is zero. Measure it.
The cache breakpoint is at the end of the prompt. Then the cached block includes the user message and changes every turn. Put it at the end of the stable block.
The model is downgraded everywhere. The bill drops and the quality drops with it. Route by task instead.
Subagents inherit everything. The isolation is nominal and the token cost is unchanged.
Nobody reads the usage report. The data exists. The review does not.
Sources and what they change
Two Anthropic documents carry most of the method on this page.
- Prompt caching. The cache is opt-in with
cache_control, defaults to five minutes, and can be extended to one hour. The breakpoint goes at the end of the stable block, not the end of the prompt. - Building effective agents. A useful distinction between workflows and agents. Most business work is a workflow with a model step, which is cheaper and easier to evaluate than an open-ended agent loop.
Related
- Prompt caching: the structural rules and the measurement.
- AI token cost: the four lines on the bill.
- Model routing: the routing table and fallback chain.
- Context window management: what to keep.
Questions owners ask
It depends on the tier and the caching. A frontier Claude session with an unstable prefix is expensive. A mid-tier model with a stable prefix can be cheaper than a small model with a bad one.
The feature depends on the provider and the API tier. Check the current documentation before designing around it.
Yes, if the tool definitions are part of the stable prefix and do not change between turns. Adding a tool mid-session changes the schema region and invalidates the cache.
It depends on how much context the parent would otherwise carry. A subagent that replaces a 50,000-token exploration with a 2,000-token summary saves the difference on every later turn.
No. A cheap model that misses the task costs more per successful outcome. Route by task and measure cost per successful task.

