# My 10 ways to save tokens in Claude Code

> Source: <https://hjerpbakk.com/blog/2026/11/17/top-10-ways-to-save-tokens>
> Published: 2026-11-17 18:00:00+00:00

**Recommendation:** Set model: sonnet or model: haiku on subagent definitions and run /clear between tasks; the author's logs show subagents used 55% of tokens and a Sonnet switch would have saved about $1,600.
More in the playbook "Controlling LLM cost": <https://wpnews.pro/playbooks/llm-cost>

# My 10 ways to save tokens in Claude Code

Tokens are expensive, and after repeatedly hitting my limits, I figured it was time to see where my tokens were going. Now I have, and these are my tips for saving tokens in November 2026.

I went through two months of my Claude Code logs. I was on a [Team plan](https://claude.com/pricing), so I used [Opus 5.5 API rates](https://platform.claude.com/docs/en/about-claude/pricing) to put a dollar figure on the tokens and compare what each part cost.

[RTK](https://github.com/rtk-ai/rtk) trims shell output and saved me about $122 at API rates. [context-mode](https://github.com/mksglu/context-mode) lets the agent search large tool results without loading them in full. That saved about $36. Cache misses after breaks came to about $270, and one 55-hour session came to $93. And I could have saved about $1,600 just by running my subagents on Sonnet.

## How a coding agent spends tokens

Claude Code [sends the whole conversation with every request](https://code.claude.com/docs/en/costs), and every tool call is another request. A session that has read ten files and run the tests carries all of it into every message that follows. Most of that history comes from the [prompt cache](https://code.claude.com/docs/en/prompt-caching). On Opus 5.5 a cache read costs $0.20 per million tokens against $4 for fresh input, [twenty times cheaper](https://platform.claude.com/docs/en/about-claude/pricing), but the rereads add up.

For me in October and November, 97.4 % of 14.9 billion tokens were cache reads. Every token that was initially sent a conversation was read 44 more times on average before the session ended.

Subagents get a conversation of their own, and they can run on a cheaper model. Mine used 55 % of all my tokens, and 89 % of that ran on Opus.

So the bill grows with the length of the conversation and the price of the model reading it. The tips are written for Claude Code, but most of them work the same way in Codex and other coding agents.

## The top 10

### 1. Clear between tasks

[`/clear` costs nothing](https://code.claude.com/docs/en/costs) and empties the conversation, so the next task starts without the history of the last one. Use `/rename` before you clear if you want to come back with `/resume`. I typed `/clear` 56 times in 560 sessions. My most expensive session stayed open for 55 hours on my [marble maze game](https://hjerpbakk.com/apps/kulebane/), grew to 844 000 tokens of context and cost about $93 by itself.

### 2. Mind the breaks

The cache only lives for a while, an hour for the main conversation according to [the prompt caching docs](https://code.claude.com/docs/en/prompt-caching). After a longer pause, the next message pays to write the whole context again, [$8 per million tokens for a one-hour cache write](https://platform.claude.com/docs/en/about-claude/pricing). Finish the task, or clear before you leave. [Scheduled tasks and loops](https://code.claude.com/docs/en/costs) send the full context too, even while the session is idle. Rebuilding the cache after long pauses came to about $270 at API rates over those two months.

### 3. Put a cheaper model on the subagents

Subagents are good for noisy work, since [test output and logs stay in their context](https://code.claude.com/docs/en/costs) and only a summary comes back. Set [`model: sonnet` or `model: haiku`](https://code.claude.com/docs/en/sub-agents) in the subagent definition, and keep Opus for the steps that need it. Sonnet costs [half as much](https://platform.claude.com/docs/en/about-claude/pricing). This was my most expensive mistake. I ran 1 237 subagents, almost all on Opus, many of them doing routine review work Sonnet could have handled. On Sonnet the two months would have been about $1,600 cheaper.

### 4. Turn the effort dial before you switch model

Addy Osmani’s [model guide for Claude](https://claude.dev/blog/which-claude-model-should-you-build-with) has the numbers for Opus 5.5 on SWE-bench Pro. Medium effort scores 2.5 points below high at 70 % of the price. Low scores 8 points below at a third of the price, and xhigh 1.4 points above at 2.5 times the price. Medium is the default in Claude Code. And when you can check the results automatically, running everything on low and only the failures again on high solved 97 % of the tasks at $0.17 each, against 95.3 % at $0.29 with everything on high. Better and cheaper.

### 5. Start over with a better prompt

When an answer goes wrong, the correction drags the wrong answer along for the rest of the session. Anthropic’s [best practices](https://code.claude.com/docs/en/best-practices) say to press Esc as soon as it drifts, use `/rewind` to go back, and after two failed corrections clear and write a better prompt. One good prompt is cheap and good. A long conversation is expensive and worse.

### 6. Give the agent a check

A test, a build or a script that passes or fails is the cheapest way to avoid rounds of “that didn’t work either”. My projects start every change with a failing test, and the agent isn’t done until the build is green. A specific prompt helps the same way. Anthropic’s [cost page](https://code.claude.com/docs/en/costs) uses the example “add input validation to the login function in auth.ts”, which reads a handful of files, while “improve this codebase” reads all of them.

### 7. Keep CLAUDE.md short

Everything in CLAUDE.md or AGENTS.md is [loaded in every session](https://code.claude.com/docs/en/memory) and reread on every request. Anthropic [removed over 80 % of Claude Code’s own system prompt](https://claude.com/blog/the-new-rules-of-context-engineering-for-claude-5-generation-models) for the Claude 5 models without any measurable loss on their coding evaluations. [Their docs](https://code.claude.com/docs/en/memory) say to keep the file under 200 lines and move workflows into skills, which only load when they are needed. For every line, ask whether a strong model would do worse without it. If not, delete it.

### 8. Trim what comes back

Tool output is the part of the context you control most directly. [Prefer CLIs like `gh` over MCP servers](https://code.claude.com/docs/en/costs), turn off servers you don’t use, and run `/context` to see what fills the window.

Tools can do some of the trimming. [RTK](https://github.com/rtk-ai/rtk) rewrites shell commands like `ls`, `grep`, `git` and test runners so they print less. [context-mode](https://github.com/mksglu/context-mode) keeps large results like logs, web pages and big files out of the conversation and lets the agent search them instead. In my two months RTK saved about $122, most of it on `ls`, `grep` and file reads. context-mode saved about $36, and blocked a few reads I needed, so the agent had to fetch the same thing another way. Small numbers next to the habits above, but RTK is free and needs no attention, so I keep it.

### 9. Measure your own usage

Look at your own numbers before you change anything. [`/usage` in Claude Code](https://code.claude.com/docs/en/costs) breaks it down and recommends a change for anything behind 10 % or more of your recent usage. The transcripts in [`~/.claude/projects`](https://code.claude.com/docs/en/claude-directory) have the token counts for every single request. The counters in token savers are no help here. RTK counts output Claude Code would have cut anyway, and context-mode counts screenshots by file size, so both claim far more than they save.

### 10. Write the plan to disk

For bigger jobs, ask the agent to write the plan as a markdown file in the repo and tick off the steps as they land. When you hit the limit, nothing is lost. A fresh session reads the plan and continues, without the history of the old one. It also makes tip 1 painless, since there is nothing in the conversation you need to keep. This one I got right.

## Bonus: a second vendor

On bigger jobs I ask Opus to write the plan, then have Codex review it with GPT-6.1 Sol. The two models tend to spot different mistakes. I send the comments to Opus, which goes through them and runs the plan with Opus subagents on the harder tasks and Sonnet on the simpler ones.

Sol costs the same as Sonnet at [API rates](https://developers.openai.com/api/docs/pricing), $2 per million input tokens and $10 per million output tokens. And when I hit my Claude Code limit, I carry on in Codex.
