The Claude Code Cost Playbook
Caching, model routing, context discipline, and team governance: a complete field manual for getting the same coding work from Claude Code while paying far less for it.
Where the money actually goes
Claude Code is Anthropic's coding assistant that lives in your terminal. It reads your files, runs your commands, writes code, and fixes bugs. Every time it does anything, it sends information to an AI model and your account is billed for the amount of information that travels in each direction. The bill is real, it climbs quietly, and the largest costs are almost always accidental rather than necessary.
Three forces drive nearly all of the spend. First, Claude Code re-sends the entire running conversation to the model on every single reply, so a session that starts cheap gets re-charged again and again as it grows. Second, teams reach for the most powerful (and most expensive) model when a cheaper one would have produced identical results. Third, the conversation fills up with material nobody needs: whole files when twenty lines would do, full test logs when only the failure matters, chatty answers, and tool connections that are never used. The good news is that each of these has a direct, well-documented lever, and most of the savings come from habits and configuration rather than clever wording.
The three forces in one line each
The sections below take each lever in turn. Every term is defined the first time it appears and highlighted so it is easy to find again. Every section ends with the concrete thing to do. Where a technique matters more at a particular team size, that is called out explicitly.
Contract platform baseline
A legal technology team builds a contract intake and obligations tracking platform with upload, parsing, clause extraction, obligations storage, review UI, audit, renewal workflow, and a legal-system connector.
Costly default
Every task runs in one Opus-heavy Claude Code session. Full requirements, complete sample contracts, parser files, UI notes, and connector questions accumulate in one growing context.
Optimized workflow
Sonnet is the default for implementation, Haiku handles exploration and log grouping, Opus is reserved for architecture, legal-risk decisions, security review, and final acceptance.
Savings note: The main reduction comes from fewer premium turns, smaller recurring context, and warmer prompt cache on stable platform rules See Appendix A.1.
1. What the meter measures
Before cutting cost, it helps to know exactly what the meter counts. The answer is simple: you pay for text, both the text that goes in and the text that comes back, measured in small chunks.
AI models do not read whole words. They read tokens, which are small pieces of text. A token is roughly three-quarters of a word, so "Please fix the login bug" is about six tokens. You never count tokens by hand. The rule of thumb is all you need: more text means more tokens means more money.
There are two kinds of token, priced very differently:
- Input tokens are everything sent to the model: your question, the files it reads, command output, and your standing rules. These are the cheaper kind.
- Output tokens are everything the model sends back: explanations, code, and summaries. These cost about five times as much as input tokens, so a chatty assistant is an expensive one.
Think of a taxi meter
You are not charged a flat fee for "a ride." The meter ticks the whole trip and depends on distance. With Claude Code the distance is the amount of text. A focused request is a short hop. A rambling session where the model re-reads huge files and writes long essays is a cross-town ride in traffic. Same destination, very different fare.
Prices are quoted per million tokens, written "per MTok." The table below lists the three models used throughout this report at the prices in effect when it was written. Treat these as planning numbers and confirm current pricing before any procurement decision.
| Model | Input (per MTok) | Output (per MTok) | Relative cost |
|---|---|---|---|
| Claude Haiku 4.5 | $1.00 | $5.00 | Cheapest |
| Claude Sonnet 4.6 | $3.00 | $15.00 | 3x Haiku |
| Claude Opus 4.8 | $5.00 | $25.00 | 5x Haiku |
A million tokens sounds like plenty, but a busy agentic coding session burns through them faster than expected, because the same context is re-sent on every turn. That single fact, explained next, is why the small habits in this report matter so much.
Contract upload API packet
The team writes the contract upload API, metadata validation, error types, tests, and OpenAPI notes.
Costly default
Developers paste the full requirements document, full OpenAPI draft, and several full contract examples into Opus, then keep asking follow-up questions in the same session.
Optimized workflow
They send a small packet: the endpoint fragment, relevant metadata schema, one representative contract excerpt, and the exact failing test or desired behavior.
Savings note: Fresh input falls sharply and the output can stay short because Claude receives the exact target instead of the whole project See Appendix A.2.
2. Why long sessions get expensive
This is the most important idea in the whole report. The model has no memory between replies. To stay coherent it re-reads the entire conversation every time you ask something new. The conversation does not just get longer; it gets re-billed, over and over.
The running pile of text that the model re-reads each turn is called the context, and the maximum it can hold is the context window, which for these models is around 200,000 tokens. Every message you send hands the model a stack of background before it even reaches your new question:
| In the stack | What it is |
|---|---|
| System instructions | The built-in rules that tell Claude Code how to behave. You do not write these; they ship with the tool. Roughly a few thousand tokens. |
| Project memory | The CLAUDE.md file where you keep standing instructions like "always run the tests" or "use this coding style." |
| Tool definitions | Descriptions of the external tools the session can use, loaded so the model knows what it can call. |
| Files it has read | Any code file shown to the model stays in the conversation and is re-read every turn. |
| Command output | Results of tests, builds, and commands, including every boring line that passed. |
| The whole exchange | Every question asked and every answer given so far in this session. |
Briefing a brilliant consultant with no memory
You hire a consultant who is dazzlingly smart but forgets everything the moment they leave the room. To get useful work you must re-hand them the entire case file at the start of every conversation: the contracts, the emails, yesterday's notes, all of it, and you pay them to re-read it each time. The bigger the folder, the more you pay, and you pay again on every question. That folder is your context, and keeping it tidy is most of the game.
This is why a session that starts cheap quietly becomes expensive. Turn one is small. By turn twelve the model is re-reading everything from turns one through eleven plus all the files and output that piled up, so the cost of each new reply keeps climbing even if the questions stay simple. A useful sense of scale: in the documented context view a single file read is around 2,400 tokens and a block of test output around 1,200 tokens. Read ten files and a few logs without trimming, and you have added tens of thousands of tokens that recur on every later turn.
The fixes split into two families that the rest of the report develops in depth. The first is the repeat discount (prompt caching), which makes the unchanged part of the stack cheap to re-read. The second is context discipline: not carrying material you do not need, and starting fresh when the topic changes.
Task boundaries across parser, UI, and connector work
A morning session moves from parser bugs to admin UI pagination to legal-system connector auth and deployment notes.
Costly default
The same conversation carries parser logs into UI work, UI component decisions into connector work, and connector notes into deployment prose.
Optimized workflow
Each unrelated task starts in a new session. Where continuity matters, a 200-token handoff states the decision, file paths, risks, and next action.
Savings note: Later turns stop paying to re-read old parser evidence and unrelated design decisions See Appendix A.3.