On Monday I told the internet that editing CLAUDE.md makes Claude Code throw its prompt cache away. Confidently. With numbers.
Wrong. Claude Code reads CLAUDE.md once, when the session starts, and holds it. Edit it halfway through and nothing changes until you restart or compact. It's in the docs. Someone on Bluesky pointed it out within hours, and they were right.
So here's the corrected story, and it's a better one. Because it turns out Claude Code writes down, every single time, what it saw change when the cache broke. I just hadn't looked.
The problem
Quick recap for anyone who missed last week. Every turn, Claude Code sends the whole conversation again. The prompt cache makes that cheap: a cache read costs a tenth of the normal input price. But if anything in the conversation changes, the cache from that point on is useless and the lot gets written again, at 1.25 times the input price (or 2 times on the 1-hour cache).
Walk away for lunch and that's expected. The cache expires, you pay to rebuild it. Fine.
What bugged me was the rebuilds that happened while I was sat right there. Last week, 12 of my 82 cold rebuilds came with the cache still warm. $15.74 out of $113. Not a fortune, but it shouldn't be happening AT ALL, and if it happens to me it happens to everyone running agents all day.
Questions, questions, questions
Was it CLAUDE.md? No, see above. Embarrassing.
Was it me switching model? One of them, yes. /model rewrites the whole thing. That one's on me.
Was it an MCP server dropping out and changing the tool list? That was my next guess, and mohith808 on Bluesky suggested diffing the tool names at the start and end of each session to check. Good idea. Except Claude Code already logs tool-list changes, and none of them landed before any of my warm rebuilds.
So mohith came back with: what about a hook, or the skill listing, changing size between turns? That wouldn't show up as a tool change. Capture two requests and diff them.
And that's where it got interesting.
The diary
Claude Code's session logs (the .jsonl files under ~/.claude/projects) contain a record called thinking_drop. It fires when the conversation Claude Code is about to send doesn't match what it sent last time. Inside it is a field called clientChange that says what changed: the message history, the system prompt, the tool schemas, the model. And the index of the first message that's different.
I have 252 of them since 12 October. Here's what they say.
- 224 changed the message history and nothing else
- 16 changed the tool schemas (so MCP and friends are real, just rare)
- 15 changed the system prompt
- 1 changed the model (hello, /model)
So it's overwhelmingly the conversation itself being rewritten. Not the tools, not the instructions.
Then I misread it
This morning I posted that 176 of those changes started at the very FIRST message. Something rewriting the start of the chat! Mystery!
Nope. I checked when they happened. 175 of the 176 came straight after a compaction. Which is what compaction does. It replaces the whole conversation with a summary, so of course everything from message one is different. That's the cost of compacting, and it's expected.
Twice in one week. Good going.
The real mystery is the other lot: 67 records where the history changed partway through a conversation, with no compaction anywhere near it. Those are the ones that shouldn't happen.
What they cost
Of those 67, 28 forced a full rebuild inside the hour, while the cache should have been warm. 13 of them came less than five minutes after the previous request.
Total: $47.41 at API prices, since 12 October. Call it seven dollars a week.
Honestly? That's small. My week of agent work was $786 at API prices. The big money is still in the rereading and the lunch breaks, like last week's post said.
But the WAY it costs is nasty. Here's why.
Every request Claude Code sends marks two places to cache: the system prompt and tools at the top, and the end of the conversation. Nothing in between. I checked this in the logged requests, the markers are right there. So when message 71 of 94 changes, the cache can't keep messages 1 to 70. It falls all the way back to the system prompt and tools, and everything after gets written again.
Which matches what I saw. Every one of those warm rebuilds read exactly the same number of tokens, 44,661 in one session and 35,787 in another. The system prompt and tools, and not one token more. A change in message 71 costs you messages 1 to 70 as well.
So what changed?
The logs also keep a copy of each message, stored by hash, and each request records how many messages it kept from the one before. So you can rebuild both versions of the conversation and diff them.
For three of my four warm rebuilds the old copy wasn't stored, so I can only say when they happened. Two came straight after Claude Code's "while you were away" summary, after I'd come back to the keyboard. One came just after I'd queued a message while it was still working.
The fourth had both copies. And the change was...
My own plugin.
I build OmnisSwarm, which coordinates agent teams in Claude Code. When a swarm finishes, it posts a one-line report into the session: "Swarm report: 4 agents, 47 min, about $9.10". In the old copy of the conversation, that line sat at the end of a message. In the new copy, it had moved to the start. Same words, different order, cache gone.
You're kidding me, right? I spent three days hunting this and the first culprit I could actually prove was something I wrote :/
The fix on my side was to stop putting that line into the conversation at all. The report's still written to a file, and /omnis report hands you the pointer whenever you ask, so the chat copy added nothing. Fixed in OmnisSwarm 0.8.1, out today.
Check your own
You don't need my scripts for this. Search your session files for thinking_drop and read the clientChange field. Look at two things:
-
kinds: what changed. If it saystoolSchemasChangeda lot, look at your MCP servers. If it'smessagesHistoryChanged, keep going. -
firstChangedMessageIndex: where. 0 just after a compaction is normal. A number partway through a long conversation, with no compaction, is the kind worth chasing.
Then look at what's in the log just before it. Hooks that add context, plugins that post notes, queued messages, the away summary. That's where mine were.
Where this leaves the money
The cache rebuild I can't explain costs me about seven dollars a week. The ones I can explain (lunch, compaction, switching model) cost a lot more, and the fix for those is habits: compact before a break, with instructions on what to keep, and don't switch model in a long session.
And the 1-hour versus 5-minute choice matters more than any of it. Someone on GitHub this week had an agent-made cron job firing every 10 minutes into a 570K-token session. Their plan's usage ran out and Claude Code dropped the main conversation to the 5-minute cache, which it does on usage credits, by design. Every firing missed. About $630 overnight, mostly spent rereading a session to report that nothing had changed. Setting promptCacheTtl to 1h would have kept it warm.
None of this is visible on a flat-rate plan until you hit the limit. On an API key you see it on the invoice, a month later.
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, as it happens. 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 (like a cron job at 3am). 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.
The numbers
- 252
thinking_droprecords in my Claude Code logs, 12 Oct to 3 Dec - 224 message history only, 16 tool schemas, 15 system prompt, 1 model
- 176 changed from the first message, 175 of them straight after a compaction
- 67 changed partway through with no compaction
- 28 of those forced a full rebuild inside the hour: $47.41 at API prices
- Last week (21 to 27 Nov): 12 of 82 cold rebuilds with the cache warm, $15.74 of $113.24
- Culprits I can prove: 1 (my own plugin). Culprits I can point at: the away summary (2), a queued message (1), /model (1)
All measured on my own machine, my own logs, priced with the same script as last week. One developer's sessions. Yours will differ, which is why I've told you where to look.
(Everything I've built, the free stuff and the paid stuff, is on fortitude-omnis.group. OmnisSwarm, the plugin that broke my cache, is on GitHub.)
First published on my Substack.


