Notes on working with AI
The mechanic behind every surprising Claude Code bill
We run enough scheduled Claude Code sessions now to actually watch the token bill, and the biggest driver of it has nothing to do with how much work got done. It's a caching mechanic almost nobody explains, and it can turn one word into a real charge.
Three moments running down a single conversation. The first, the opening message, is written to cache. That's the expensive operation. The second, any message that follows within the hour, is read back from cache at a cost an order of magnitude lower, and the clock resets on every message. The third is emphasised in gold: come back after more than an hour, the cache has expired, and the whole conversation is rewritten at full price before the model has even read what you typed.
The first message
Written to cache
There is no history to reference yet, so the whole context gets written. This is the expensive operation, and it is unavoidable once.
Every message within the hour
Read from cache
The history is read instead of resent, at roughly a twentieth of the cost. Every message resets the clock.
You come back ninety minutes later
Rewritten, at full price
The cache expired. The entire conversation is written again before the model reaches a word you typed, even if the word was “hi”.
Which is why a long conversation left open since yesterday is a liability rather than a convenience. Compacting it, or starting a fresh one, costs less than resuming it.
- claude-code
- token-costs
- prompt-caching
- workflow
The bill and the work rarely match
We run a fair number of Claude Code sessions on a schedule now, builder agents that pick up a task overnight, work through it, and hand it back by morning. Somewhere around the third month of that we started reading the token usage line the way we used to only read run time. The first thing that becomes obvious once you look is that the bill has almost nothing to do with how much work got done. It has to do with how the conversation was shaped.
Four numbers, not two
Everyone who's glanced at a pricing page knows there's an input rate and an output rate. What most people miss is that there are two more categories sitting behind them: a cache write and a cache hit. A cache write happens when a message goes to Claude for the first time and there's no history to reference yet, so the whole conversation gets written into a place Claude can read from cheaply later. A cache hit is exactly that, reading the history back instead of resending and reprocessing it. The gap between the two rates is roughly an order of magnitude, somewhere around twenty times, depending on the model and whatever the current pricing page says today (check it, it moves). That ratio is the whole story. Everything below is really about avoiding unnecessary cache writes.
The clock you don't know is running
Here's the part nobody tells you when you start. The cache doesn't live forever. It has a lifetime of about an hour, and every message you send resets that timer back to the top. So as long as you're in a conversation and sending messages reasonably often, you keep paying the cheap rate. Step away for ninety minutes, come back, and type one word, and the entire conversation gets rewritten to cache at the expensive rate before Claude even looks at your one word. A conversation you'd been building all afternoon doesn't disappear when you walk away. It just waits to become expensive again the next time you touch it.
This is the trap almost nobody sees coming, because it doesn't look like a mistake. You didn't ask for anything complicated. You said hi.
What actually changes the number
Once the cache mechanic clicks, the rest is mostly housekeeping. A conversation that's gone stale is worth compacting, or just clearing, before you pick it back up, rather than dragging an hour-old, half-relevant history forward at full price. On anything long-running, it's worth pointing a stronger model at the plan and letting a cheaper one do the actual execution, escalating back up only when it's stuck. The expensive model spends its time deciding, not typing. Config is worth auditing the way you'd audit a subscription: a CLAUDE.md that's grown past what anyone actually reads, or a folder of skills nobody's invoked in weeks, sits in the context window and gets paid for on every single turn, whether it did anything that turn or not. Output is billed too, so a model that explains itself at length before doing the thing costs more than one that's been told to just do the thing.
Cost is a design choice, not a quote
None of this required us to run anything exotic. It's mostly about not leaving conversations open past the hour, not carrying more context than we're using, and being honest with ourselves about what a quick check actually costs against what a five-word question deserves. The people who get surprised by the bill are, almost without exception, not doing anything unusual. They're just not treating cost as something they're shaping, and it is exactly that, every session, whether anyone's watching it or not.