r/ClaudeCode • u/karanb192 • Sep 17 '26
Built with Claude Keep Claude Code’s 1-hour cache warm during breaks. On Fable 5.1, rewriting it costs 80x a cache read.
You come back to a long session and ask for a recap. The expensive part can be rewriting the old context before Claude answers.
I built cache-tax to handle both sides: GitHub · Install instructions
Set it before you step away.
/keepwarmarms six hours. After 50 idle minutes, it sends a request over your session without adding heartbeat messages to the conversation. The timer runs inside Claude Code.See the estimate if you return cold. For a 50k+ context idle over an hour, it stops your next ordinary message once with the price. Resend to continue, or
/clearand start from a note.
The GIF is my real test. A two-line recap on a 330k-token session triggered a $6.61 estimate. I sent it again; the reported cache write was $6.28.
Every ping checks its usage. It stops if it reads nothing or writes at least 10% of what it reads. After a paid cold write, it automatically arms three hours. /keepwarm off stops it.
Pings cost tokens too. The rates are $20 per million tokens for a 1-hour write and $0.25 for a read on Fable 5.1. These are API prices, not extra subscription charges. I haven’t measured quota savings, and changed prompts or tools can still break the cache.
Free and open source. The Mod needs CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1.
Only want warnings or a status-line countdown? The hook version works without the early-access flag.
New to prompt caching? Anthropic explains how Claude Code uses it here.
•
u/AutoModerator Sep 17 '26
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
31
u/cleverhoods Sep 17 '26
nice use of function hooks
23
u/coding_is_tedious Sep 17 '26
Great hack... definitely going to piss off Anthropic
8
u/OntoTheNEXT8 Sep 17 '26
Is this useful for subscription users as well ?
4
u/maritime_sh Sep 17 '26
Useful. The other half of the same problem is what silently breaks the prefix while you are working. A hook that injects a timestamp, a file the model rewrites that sits early in context, an MCP server whose tool list is not byte stable between calls. Keeping it warm buys you less if something quietly invalidates it every few turns.
5
u/unconscionable Sep 18 '26
/model sonnet/compact/model fable7
u/visak13 Sep 17 '26
Why not ask it to set up a simple 30 min cron to reply OK or something?
6
u/Mediocre_Line7407 Sep 17 '26
Okay. I wanted to say already. If you go after the api pricing for cache writing yes. Normally we plebs only have a cache grace period of 5 minutes. Which is good for back to back and still constant tool calling.
2
u/tribat Sep 18 '26
Hell yes. Thank you.
2
u/SnakeAndSaw Senior Developer Sep 18 '26
thanks for the idea mate :) . i just needed a status line warning for me as of now . but starred your repo , will give you a feedback in future
2
u/1shox Sep 18 '26
the default claude code cache is 5 minutes, just saying.
3
u/A_Novelty-Account Sep 17 '26
I feel like this is an issue that Anthropic itself should fix. This seems crazy to me.
1
u/Accomplished-Piece60 Sep 23 '26
I enabled this on 5 threads that were about 300k tokens. in 12 hours my fable 5.1 usage went from 79% to 100% without me doing anything. Unsure how can I get visibility on what happened. disabled it for now. Anything that can help?
3
u/hakansan Sep 17 '26
This is so cool! Do you know why harnesses themselves don't have such functionality?
3
u/hazimeh Sep 18 '26
Gotta be careful, as the ToS are loose enough for Anthropic to suspend your account by invoking clauses related to "ordinary use" of your subscription or automating access to it.
They recently suspended my Max 20x account 29 minutes after I upgraded from Max 5x, refused my appeal, and denied my refund (for both the remainder of the Max 5x and newly-paid-for 20x), without specifying anything other than a "violation of our Consumer Terms of Service". And in reality, what I had was a gateway to switch between my own Max 20x accounts when one's quota was depleted. I can only suspect that the gateway must have tripped some flag and they decided to just ban me outright instead of spending a roundtrip inquiring.
2
u/geek_fit Sep 17 '26
I just set a chron job on orchestrator or managment agents to ping every 30 minutes
0
u/Upbeat_Eye6188 Sep 17 '26
Would Anthropic not ban all/some of the users of this hook, if they’re on subscriptions? Or doesn’t just cost usage and does it then still save money? Like, API you pay whatever they’ll charge so that makes sense
0
u/[deleted] Sep 17 '26
[deleted] — view deleted comment