Where your Claude Code tokens go
Claude Code keeps a transcript of every chat on your machine, with the exact token counts of each request it sent. I wrote cachecanary claude-code to read them and put a dollar figure on each tool output, Bash command, MCP tool, skill and subagent. Then I ran it on my own last 30 days (November 18 2026): 2,022 sessions, 1,491 subagent runs and 135,477 requests.
The short version: you pay for a tool output more than once. It's written to the cache with the next request, then read again by every request after that until the chat is compacted. On my machine, Bash output was 52% of the cost, and pauses longer than the cache lifetime added $2,938.71 of cache rewrites.
The setup I'd use
pip install cachecanary cachecanary claude-code # only one table: tool, bash, mcp, skill, agent or item cachecanary claude-code --since 7d --by bash
It reads ~/.claude/projects, or $CLAUDE_CONFIG_DIR/projects if you set that, and only reads. Nothing is sent anywhere. The output has tool names, Bash command names (the program and its subcommand, like git diff), MCP tool names and numbers, and no prompts, outputs, commands or paths. Dollars are Anthropic's API list prices for the same tokens, not your subscription bill. Add --price if you pay a different rate, and --json for your own scripts.
What I found
Most of my sessions are scripted agents, so the mix isn't typical. At API list prices the 30 days came to $16,367.58. The biggest groups:
| What | Cost | Share |
|---|---|---|
| Bash (commands and their output) | $8,532.06 | 52.1% |
| Claude's thinking | $1,848.24 | 11.3% |
| CLAUDE.md and instructions | $703.18 | 4.3% |
| Write | $482.04 | 2.9% |
| Claude's replies | $449.84 | 2.7% |
Each row counts the cache write when an item arrived, every cache read after that, and the output tokens it took to produce.
1. Bash output was half the cost
Most of it came from four commands: python 11.6%, sed 10.7%, grep 8.6% and cat 6.6% of the total. These are the commands that print a lot. Two things decide what an output costs:
- Its size. The tokens go into the cache once, at the write price (1.25x the input price for 5 minutes, 2x for an hour).
- How long the chat goes on after it. Every later request reads it again, at a twentieth of the input price on Opus 5.5. In a long chat the reads add up to more than the write.
The command name is the first real command: cd repo && git diff counts as git diff, and date && python run.py counts as python, because date prints almost nothing.
The fix is to print less: head, tail, grep, quieter flags, or a PreToolUse hook that shortens long output.
2. Pauses past the cache lifetime rewrote the whole context
1,238 requests came after a pause longer than the cache lifetime (5 minutes or an hour) and wrote the cache again. That cost $2,938.71 more than reading it. The rewrite is the size of the whole chat, so long pauses in big chats cost the most.
The first request of each chat and subagent isn't counted as a rebuild, because there was nothing to read yet. Those 3,507 first requests wrote 80,394,463 tokens to the cache, $287.83.
3. The costliest single items
The costliest single item was a skill's instructions: 106,036 tokens, sent again by 676 later requests, $16.01. Next were four Read outputs inside subagents, 15,945 to 25,354 tokens each, sent again 456 to 633 times: $4.76 to $5.53 each.
Smaller things
- Claude's earlier thinking stays in the context and is billed as input. Most thinking blocks are logged with no text, so their size comes from the thinking token count of each request.
- Main chats read 99.1% of their prompt from the cache, subagents 95.7%. Subagents use the 5-minute cache on my setup.
- One MCP tool had 9.9% of the tokens added but 0.2% of the dollars, because 99% of its tokens went to Claude Haiku 5.5 requests.
- Web searches are billed per search. My 1,286 searches cost $12.86 in fees, on top of their tokens.
What Claude Code gets right
Its transcripts record the exact usage of every request, with the 5-minute and 1-hour cache writes split out, the parent of every line, and its own running cost. That is what makes a dollar figure per output possible. For 2,004 of my 2,007 sessions without subagents, CacheCanary's total was within 1% of the cost Claude Code records for itself.
Check your own machine
Run it on your own transcripts with the command above. These are lines from the top of the real output for my 30 days:
$ cachecanary claude-code
Claude Code since 2026-10-19 (30 days): 2,022 sessions, 1,491 subagent runs, 135,477 requests
Total $16,367.58 at Anthropic API list prices. This is an API list price equivalent, not your subscription bill.
Biggest cost: Bash, $8,532.06 (52.1% of $16,367.58); mostly 'python' 11.6%, 'sed' 10.7%, 'grep' 8.6%.
Spend: cache reads $9,805.84, 1h cache writes $2,332.12, 5m cache writes $2,655.71, uncached input $1.33, output $1,559.71, web search fees $12.86 (1,286 searches)
Cache hit rate: 98.2% overall, main chats 99.1%, subagents 95.7%
First calls: 3,507 chat or subagent runs wrote 80,394,463 tokens to the cache on their first request ($287.83)
Compactions: 122 (auto 111, manual 11); prompt 953,284 tokens before, 89,022 after on averageIn plain words: most of what I paid for was reading the cache, which is the cheap part. Writes cost $4,987.83 and output $1,559.71. Below this come the tables: by tool, Bash command, MCP server, skill and subagent, and the costliest single outputs.
--details adds a short label to the costliest outputs (the start of the command or the file path), with secrets and your home folder taken out. The flags are in the README.
How I tested this
The tests use synthetic transcripts that copy the shape of real ones, with dollar amounts worked out by hand: a 10,000-token Bash result followed by 5 more requests pays exactly one cache write and 5 cache reads. On my own 30 days (3,689 files, 134,175 requests), the token totals matched a separate recount exactly. I also ran small sessions with outputs of known size: the total matched my hand calculation to the cent, and a Bash output twice as long grew by 98% of the real change in tokens. The format isn't documented and changes, so it was checked on Claude Code 2.1.266 to 2.1.325, and --debug-shapes prints counts you can send me without any content. Calls Claude Code doesn't write to the transcript, like side calls to other models, aren't counted.
Framework guides: LiteLLM, Strands Agents and LangChain. More on why caching breaks on Bedrock: Five ways Claude prompt caching quietly breaks on Amazon Bedrock.
Want a quick number for your own app? Paste three totals from CloudWatch into the cache checker. It runs in your browser, nothing to install.
Using CacheCanary? I'd love to hear how it's going, good or bad, and whether you'd want the dashboard. Email me at hello@cachecanary.com. I read every message.
Want help with your own app? I also do this hands-on: finding out why your cache misses, fixing it, and checking that the bill comes down. Same address: hello@cachecanary.com.