DEV Community

Cover image for My Claude Code bill is mostly rereading
Developer at Fortitude Omnis Group
Developer at Fortitude Omnis Group

Posted on Edited on Originally published at six502.substack.com

My Claude Code bill is mostly rereading

Last Wednesday I put a heavy Claude Code day through the API price list and got $97.20, of which $18 was output. Under a fifth. The rest was rereading. Someone asked (quite reasonably) whether that was real or just my spreadsheet being dramatic.

It was a worked example. Made-up developer, made-up day, honest prices. So this week I did it properly, on my own logs.

21 to 27 Nov, every request my Claude Code sessions made, priced at API rates: $786.39. Here's where it went.

  • Output, the code and the words: $159 (20%)
  • Cache reads, the conversation being read again: $284 (36%)
  • Cache writes, the conversation being stored so it can be read again: $343 (44%)
  • Plain uncached input: 8 cents

So the made-up day was right. Scarily right. 20% is the actual writing, and 80% is Claude rereading what it already knows.

(I'm on a subscription, so I didn't pay $786. I paid the flat fee. This is what the same work costs on an API key, which is what anyone running agents for a team is on.)

Why it rereads

Every turn sends the whole conversation again. The system prompt, the tools, every file it opened, every test run it read, all of it, every time. The prompt cache is what stops that being ruinous. Once a prefix is cached, reading it costs a twentieth of the input price on Opus 5.5.

A twentieth of not much is still something when you do it 8,000 times. My main sessions read 1.02 BILLION tokens from the cache last week. Subagents read another 446 million. That's the $284.

And the writes cost more than the reads, which surprised me. A write to the 5-minute cache is 1.25x the input price. A write to the 1-hour cache is 2x. My main sessions go to the 1-hour cache, my subagents to the 5-minute one, and between them they wrote $343 of it.

Questions, questions, questions

So when does it write? Mostly when the cache has gone cold and the whole lot has to go in again. How often does that happen? And what does it cost?

I counted. A cold rebuild here means a request that wrote over 20K tokens and read less than a fifth of its prompt from the cache.

  • Main sessions: 40 cold rebuilds after a gap of over an hour. $56.58, about $1.41 each. That's lunch. And meetings. And me going "I'll just check something" and coming back 3 hours later.
  • Subagents: 28 cold rebuilds after a gap of 5 to 60 minutes. $38.09. That's a subagent waiting on a slow build or a test run while the 5-minute cache quietly expires.

Neither is huge on its own. Together it's $95 in a week, 12% of the bill, spent writing down things Claude already knew an hour ago.

Should subagents get the 1-hour cache then?

Last week I said measure before you flip it. So I measured.

You can choose the TTL yourself these days: CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL (or subagentPromptCacheTtl in settings) takes 5m or 1h, from Claude Code v2.1.242. My subagents wrote $119 to the 5-minute cache last week. The same tokens at the 1-hour price come to about $191. That's $71 MORE, to save at most the $38 of rebuilds, and only if the 1-hour cache would have caught every one of them.

Nope. Not for my traffic. It's the same answer sindrehenriksen got on four weeks of theirs in #110403 (it pays when lots of your writes follow a 5 to 60 minute pause, and mine mostly don't). Your mileage will vary, which is exactly why you count it.

The lunch problem has a better fix

The main session's $56 is a different story, and this one came out of my replies. Jim Hammond's point on Substack: compact before you walk away. /compact reads the conversation once, writes a summary, and you come back to a much smaller context to rebuild. My rough sums say a 300K context squashed to 30K turns a $2.40 rebuild into about 50 cents. Rough, because I haven't measured it yet.

Then they spotted the catch straight away. Compacting is lossy. Except you don't have to hope it keeps the right things, because /compact takes instructions:

/compact keep the files touched, the open decisions and the next step

Or put a # Compact instructions section in CLAUDE.md and it's there every time. Both are in the Claude Code docs. And /clear between unrelated jobs is cheaper still, because there's nothing left to rebuild.

So that's next week's experiment. Compact before every break and count the rebuilds again.

Caps, and why one number isn't enough

The other thing that came up all week was caps. Two things I learnt answering people in the Claude Code issue tracker.

First, claude -p --max-budget-usd 5 stops a scripted run at a ceiling. But it only works with --print, and it checks against Claude Code's own estimate, not your invoice. The docs say total_cost_usd is a client-side estimate from a bundled price table. Good as an early stop, not as a guarantee.

Second, someone set a $200 monthly limit in the Console, auto-reload off, and got charged $222.69 (#112086). One cap, checked on someone else's side, after the fact. That's what worries me. A loop at 2am doesn't wait for the monthly sums.

Which is the thing I actually sell, so here's the plug. OmnisVigil reads the receipts OmnisRouter writes and shows what your agents spend by project, repo, model and commit. The cap is checked on YOUR side, before each request goes out, and there's a kill switch for when an agent loop goes feral. It only sees API-key traffic, so it does nothing for a flat-rate plan. It's free for one person (sign up here and it hands you OmnisRouter), and paid for teams.

Confession: still nobody

Last week I promised to put the signup link where a human can see it and find out if anyone clicks. OmnisRouter 1.3.1 went out on 23 Nov with the link in the tray menu, on the receipt page and in the setup screen, all tagged.

Clicks from any of them since: 0.

The signup page did get 16 clicks last week. 2 came from last week's article. 14 came with no tag at all, so I've no idea where from. Sign-ins: 0. Downloads went up by 72 to 443 all-time. So people download the router, and they don't come back for the dashboard. Hmm.

I'll keep counting. What I won't do is pretend 16 untagged clicks are a funnel.

And the subagent recount

The other promise: pin the subagents and count again. From 23 to 25 Nov, 21 of 33 subagents ran on Sonnet. The week before it was 9 of 55. Before anyone claps, 15 of those 21 had model: sonnet written into the call by hand. The real question is whether Sonnet is cheaper per FINISHED job once you count the retries, and Explore is on 3 runs. I said I wouldn't call it under 20. I'm not calling it.

The numbers

  • Agent work at API prices, 21 to 27 Nov: $786 (Opus 5.5 $533, Fable 5.2 $228, Sonnet 5.5 $26). What I paid: the flat subscription.
  • Output 20%, cache reads 36%, cache writes 44%.
  • Cold rebuilds: 40 main after an hour away ($56.58), 28 subagent after 5 to 60 minutes ($38.09).
  • OmnisRouter downloads: +72 (443 all-time). Signup clicks: 16 (2 from Substack, 0 from the router). Sign-ins: 0.

Next week: compact before every break and count the rebuilds again, and find where those 14 untagged clicks come from.

(Everything I've built, the free stuff and the paid stuff, is on fortitude-omnis.group.)

First published on my Substack.

Top comments (1)

Collapse
 
crisstiank profile image
Cristian K •

Good breakdown. One thing that affects the cold-rebuild number beyond the idle gap: the cache is prefix-based, so anything that changes early in the prompt (editing CLAUDE.md mid-session, adding or removing an MCP server or tool, switching model) invalidates everything after it, not just the next turn. Those rebuilds look the same in the logs as a lunch break but they happen while you're at the keyboard. If you can tag each cold rebuild with the gap before it, you can tell the two causes apart, and the second kind is fixable by keeping the prefix stable during a session.