Claude Code Cost Optimization: Cut Token Spend

Claude Code is billed by tokens, not by the number of requests. Each turn charges for the input tokens the model reads plus the output tokens it writes, and because the whole conversation is replayed every turn, input usually dominates. That means a long session is expensive largely because of the history it keeps carrying, not just its final answer.
Reset the context window between unrelated tasks. Running /clear starts a fresh conversation so an hour of old history is no longer resent on every message, and /compact shrinks a long thread when you still need its gist. It is essentially free and is the single highest-return habit for controlling cost.
Not automatically. Subagents keep bulky file reads out of the main window, which protects context, but each one re-reads the context it needs, so a multi-agent run can use far more tokens overall. Anthropic has reported multi-agent systems can consume roughly fifteen times the tokens of a single chat, so delegate for breadth and isolation, not to save money by default.
Yes, when the task allows it. Route mechanical, well-scoped work such as renames and boilerplate to a small, fast model like Haiku, keep a mid-tier model like Sonnet as your everyday default, and reserve the strongest model for hard reasoning. Matching the model to the difficulty of the work cuts spend with little quality loss.
Use the /cost command inside a session to see token usage and spend for that conversation. For teams, export usage telemetry and set budget alerts so cost is visible per developer rather than discovered at the end of the month. A flat subscription plan also removes per-token anxiety when usage is heavy and steady.

Key Takeaway
Claude Code bills by tokens, so your cost tracks how much context flows through the model, not how many messages you send. The largest savings come from keeping the context window lean with regular resets, matching the model to each task, and delegating bulky reads to subagents. A handful of habits cuts spend without hurting output.
Claude Code is priced by tokens, and tokens behave differently from the request-based billing many developers expect. Every file the agent reads, every command output it sees, and every earlier turn of the conversation is re-sent to the model on the next turn. Cost, then, is mostly a function of how much context you keep in play, not how many prompts you type.
This explainer walks through where the spend concentrates and the handful of levers that move it. None of them require a different plan or a weaker model; they are habits and settings you already control inside a normal session.
A single turn costs the input tokens the model reads plus the output tokens it writes. In agentic coding the input side dominates, because the entire conversation so far, including every file and tool result, is replayed on each new turn. A long session is expensive less because of its final answer and more because of everything it is still carrying.
In practice, three drivers explain most of any bill:
The cheapest token is the one you never send. Because history is replayed each turn, the highest-leverage habit is simply resetting context when you move on. The /clear command wipes the conversation between unrelated tasks, and /compact summarizes a long thread into a shorter form when you want to keep the gist but drop the bulk.
Claude Code also applies prompt caching automatically, so the stable front of your context, such as system instructions and files that have not changed, is billed at a reduced rate on repeat turns. You benefit from it for free, but only if you avoid needlessly reshuffling early context, which invalidates the cache.
Running /clear between tasks is essentially free and is the single highest-return habit for controlling spend. Start each new task from a clean window instead of dragging an hour of unrelated history behind you.
Not every task deserves your most capable model. Routing routine work to a smaller, cheaper model and reserving the strongest one for genuinely hard reasoning can cut spend sharply with little quality loss.
Subagents run in their own context window and return only a summary, which keeps large file reads and tool output out of your main session. For breadth-first work like exploring a codebase, that isolation both protects the main window and stops it drifting as it fills.
The catch is that delegation is not automatically cheaper. Each subagent re-reads the context it needs, so a run that fans out across several agents can use far more tokens overall. Anthropic has reported that multi-agent systems can consume on the order of fifteen times the tokens of a single chat, so reserve them for work that genuinely benefits from parallel breadth.
Do not assume more agents means lower cost. A multi-agent run trades main-window context for total token volume, and used carelessly it produces a larger bill, not a smaller one. Delegate for isolation and breadth, not as a reflex.
You cannot optimize what you do not measure. Before tuning anything, get visibility into where tokens go, then set guardrails so a runaway session cannot surprise you.
Cost control in Claude Code is not about using it less; it is about carrying less. Reset context between tasks, match the model to the difficulty of the work, delegate bulky reads deliberately, and watch the numbers with /cost. Those four habits keep spend proportional to the value you are getting out.