CH 44 / 86Chapter 5: Claude Code (The Core of Development)

Cost Control and Saving Tokens

On this page10 items

In 10 seconds

The longer the conversation, the more even a one-line question costs. That’s because the full conversation is sent every time.
The most effective fix is to /clear when you move on to unrelated work.

Chapter 1, #03 and #08, covered units and pricing. This page covers where costs actually arise in Claude Code.

Look first#

/usage shows the usage for the current session. On a paid plan, it also shows a breakdown of consumption against your plan’s limit.

Two things in the breakdown are useful.

What is using it. It shows the share for each skill, subagent, plugin, and MCP server. You will find things eating more than you expected.

Behavior warnings. When behaviors like “long context” or “cache misses” account for 10% or more of recent usage, they are flagged. It names the spots that need attention, so it is worth checking.

/context shows what is currently occupying the context: CLAUDE.md, MCP tool definitions, conversation history. Before trimming anything, look here first.

Why long sessions are expensive#

Once you understand the mechanism, you can tell which measures work and which don’t.

Claude Code sends the full conversation every time. Each time a tool is used, it sends everything again, including the result. So even a one-line question in a session that has been open all day draws usage for the entire conversation.

Thanks to prompt caching, the resent portion is processed at a discounted rate. But discounted is not free.

And here is a pitfall the official docs spell out: the cache has a lifetime. On a subscription it is one hour; once you start using usage credits it is 5 minutes; via an API key or the cloud it is 5 minutes by default. The first message after a break misses the cache and reprocesses the whole thing.

In order of effectiveness#

Cut the conversation with /clear. This works best. When you move on to unrelated work, don’t carry the old context along. If you /rename before /clear, you can come back later with /resume.

Match the model to the task. Sonnet is enough for most coding. Save Opus for intricate design decisions and multi-step reasoning. You can switch mid-session with /model. Subagents can be given model: haiku.

Offload output-heavy work to subagents. Running tests, processing logs, fetching documentation. The bulk of the output stays inside the subagent, and only a summary comes back to the main session (#23, #24).

Trim output with hooks. This is the pattern from #41. Instead of having Claude read 10,000 lines of logs, a hook returns only the ERROR lines. Tens of thousands of tokens become a few hundred.

Move things from CLAUDE.md into skills. CLAUDE.md is read every time. If you write your PR review procedure there, you keep paying for it during unrelated work. Aim for about 200 lines (#38, #40).

Clean up MCP servers. Check with /mcp and disable the ones you aren’t using. If a CLI tool exists, it uses less context. Tools like gh, aws, and gcloud don’t bring tool definitions in with them.

Write specific instructions. “Improve this codebase” sends it searching widely. “Add input validation to the login function in auth.ts” keeps the files it reads to a minimum.

Lower the thinking depth. Extended thinking is on by default, and thinking tokens are billed as output. For simple work you can lower it with /effort.

Plan mode also saves money#

It may seem surprising, but plan mode is one of the most effective cost measures.

If implementation goes ahead in the wrong direction, you throw away what was written and write it again. If you approve the plan first, that rework doesn’t happen. The practice described in #37 pays off directly in cost.

For the same reason, pressing Esc early also saves money.

Usage while idle#

This is easy to overlook. Here is what the official docs list.

  • Scheduled tasks fire at each interval even while the session is idle, sending the full context each time (#43)
  • Each member of an agent team keeps using tokens until it finishes
  • /compact itself is a large request. If you just want a clean slate, /clear costs nothing

The last point is worth remembering. If you don’t need to continue, clear instead of compacting.

Ballpark figures#

The official docs say the average in enterprise deployments is around $13 per person per working day, or $150–250 per month. 90% of users stay under $30 per working day.

If you are estimating for your own team, the reliable approach is to start small, measure, and then expand.

Try it: see what’s eating your context right now (3 minutes)

Run this in a Claude Code session.

/context

Then look at /usage as well. After that, ask:

Prompt
Look at the current /context breakdown and list what could be trimmed. For each one, also write what would be lost by trimming it.

Expected result: Unused MCP servers, an overly long CLAUDE.md, and old conversation history come up as candidates.

If it doesn’t work: If there is nothing to trim, that is a healthy state. Just carry on.

Common pitfalls#

Trying to save without looking at usage. You can’t tell what’s heavy without measuring. Start with /context and /usage.

Locking in a cheap model. It works for simple tasks, but if it keeps failing on hard tasks, the retries end up costing more.

Running /compact over and over. Compaction itself is a large request. If you don’t need to continue, use /clear.

Leaving long sessions open. Even a one-line question draws usage for the entire conversation.

Where to go from here#

That’s the end of Chapter 5. You now have the full picture of Claude Code.

The quote-processing work has now reached the point where it “runs automatically every week.” In Chapter 6, we move on to connecting Claude to internal systems and external services.

Summary#

  • The full conversation is sent every time. In a long session, even one line is expensive
  • The most effective measure is /clear when moving on to unrelated work
  • Offload output-heavy work to subagents or hooks
  • Plan mode also saves money. It prevents rework

Read next#

What Is MCP?