Stop paying full price to say "I'm back" to your own Claude Code session.
A tiny Claude Code skill that keeps your prompt cache warm while a session sits idle — so your next message reads the conversation from cache instead of re-billing it from scratch. Anthropic bills cache reads at 0.1× the input rate (published ratio, every model) — an uncached return costs ~10× more.
This is not just an API-billing thing. On Pro/Max subscriptions the same accounting drains your 5-hour window and weekly usage limit: come back to a long session cold, and one "how's it going?" can eat a visible chunk of your quota that a warm cache would barely have touched.
Why this exists
It was born in a real session: a multi-day model fine-tune babysat by Claude — training runs that took hours, checkpoints landing overnight, a human who occasionally sleeps. Every time the session went quiet for longer than the cache window, the next "how's it going?" re-billed the entire conversation history at full input price. On a long, tool-heavy session that's hundreds of thousands of tokens, re-billed every single time you stepped away too long.
One inactivity-triggered heartbeat later, it didn't.
The problem, concretely
Claude is stateless: your whole conversation is re-sent to the API on every turn. Anthropic's prompt caching makes this affordable — cached input costs ~10 % of the normal rate — but the cache expires after a TTL (up to 1 hour on long-TTL sessions). The failure mode:
- You run something long (training, CI, a big download) or just step away.
- The session is silent past the TTL. The cache dies.
- You come back, type one line — and the entire history is re-processed uncached: ~10× the tokens a cached read would have counted. On the API that's money; on a subscription that's your 5-hour window and weekly limit draining for nothing.
Do that a few times a day on a long-running session and the "idle tax" quietly becomes the biggest line in your bill — or the reason you hit your usage limit by mid-week.
The fix
/cachebeat arms a single silent background watcher inside your session. It's an inactivity
timer, not a metronome: it fires only when the session has been truly silent for N minutes — any
message, reply, or answered background event already refreshed the cache and resets the clock.
On firing, Claude wakes, quietly re-arms the watcher, and the cache TTL restarts.
Break-even math: going cold once costs as much as ten heartbeats. Come back to the session even once and the heartbeat has paid for itself many times over — and the bigger the session, the bigger the absolute savings (the 10× ratio is flat; the token count isn't).
It also kills itself after a deadline (default 8 h), so an abandoned session doesn't drip-bill forever.
Note (Sept 2026): cachebeat used to run as one persistent background monitor. A Claude Code update capped monitors at 30 minutes with no persistent option — which would force a wake-up every ~28 min, idle or not. cachebeat now runs as a background shell task instead, which has no such cap: it stays silent for the full idle threshold (50 min by default), exits to deliver the beat, and Claude re-arms it. Same inactivity timer, different plumbing. Upgrading? The watcher now lives in a second file — copy
beat.shnext toSKILL.md(see Install). Details in How it works.
Install
User-level (all projects):
mkdir -p ~/.claude/skills/cachebeat
cp SKILL.md beat.sh ~/.claude/skills/cachebeat/
Or project-level: copy both files into <your-project>/.claude/skills/cachebeat/.
That's the whole setup — two small files: the skill, and the watcher script it runs. Then in any
Claude Code session, type /cachebeat and you're done. (It just needs a Claude Code that runs
background tasks, which is the default.)
No comments yet.