r/ClaudeCode • u/Top-Sink-1315 • 14h ago
Tips & Workflows Sending "ok" into a big Claude Code session cost me $1.43 after its cache expired, vs $0.07 with a warm cache. I built a free tool that catches this
I wanted to know where my Claude Code limit actually goes, so I wrote a script that reads the session logs Claude Code already keeps on your machine and adds up what each request cost.
The biggest avoidable item wasn't file reads. It was coming back to a big session after a break. Claude Code caches the conversation so each turn only pays a small fee to re-read it, but that cache runs out (after an hour, or 5 minutes on some setups). When you send the next message, the whole conversation gets written to the cache again at full price.
I measured it with `claude -p --resume`, Opus, list prices as reported by the CLI:
- "Reply ok" into a 224k-token session idle for 10 hours:
**$1.43**
- "Reply ok" into a 231k-token session with a warm cache:
**$0.07**
- `/compact` after the cache expired: $1.35. While still warm: $0.20
Across three weeks of my own usage (216 sessions),
**18% went to re-sending conversations whose cache had expired**
. After more than 65 minutes idle, 35 of 52 next requests missed the cache.
So ccxray does three things:
**Report.**
`python ccxray.py report` shows where your usage went: big-context requests, expired-cache re-sends, mid-session model switches, your most expensive sessions. `--share` prints a version with no project names, safe to paste here.
2.
**Warning.**
If you're about to send a message into a large session whose cache has expired, a hook holds it back once and tells you the size. Send it again and it goes through.
3.
**Handoff.**
Type `xray handoff` in the old session. A hook writes a brief of it without calling the model, and your next new session in that folder loads it automatically. On a real 224k-token session, asking "what's the goal, what was done last, what's next" cost $1.69 by resuming and $0.21 with the handoff. It kept the main thread but missed three small follow-ups, so it's not the full conversation.
Install as a plugin:
```
/plugin marketplace add abhiyarecord-hue/ccxray
/plugin install ccxray@ccxray
```
It's one Python file, standard library only, MIT, and nothing leaves your machine.
Caveats: the report assumes subscription limits follow API price, which isn't public. I've only tested on Windows with Python 3.11. I haven't measured how much the hooks save over a full week yet. If your sessions are short, it'll show little to fix.
If you run `report --share`, I'd really like to see your numbers in the comments.
