Keep Claude Code's prompt cache warm across idle pauses. A Stop/UserPromptSubmit hook stamps activity; a background Monitor pings the session only once it has been idle long enough (default 50 min), which triggers a cache read and refreshes the prompt-cache TTL. Built for a 1h cache TTL; on request-quota subscriptions every ping eats quota, so disable it there.
Keep Claude Code's prompt cache warm across idle pauses — without freezing your terminal.
A Stop hook stamps "the session was active just now"; a background
Monitor watches that timestamp and, only once the session has been idle
long enough (default 50 min), emits one line. That line is delivered to
Claude as a notification, which starts a fresh turn → a cache read →
the prompt-cache TTL is refreshed. One cheap read instead of an expensive
full cache rewrite.
Built for a 1 hour cache TTL. On a 5-minute TTL you would set
CCKA_IDLE_SECONDS=240.
Cost at a glance
10 warm pings (cache reads) vs. one cold start (a 1-hour cache rewrite), USD:
Model
100K ctx
1M ctx
Savings
Opus 5 / 4.8 / 4.7 / 4.6
$0.50 → $1.00
$5.00 → $10.00
2×
Sonnet 5
$0.20 → $0.40
$2.00 → $4.00
2×
Sonnet 4.6 / 4.5
$0.30 → $0.60
$3.00 → $6.00
2×
Haiku 4.5
$0.10 → $0.20
$1.00 → $2.00
2×
Fable 5.1
$0.25 → $2.00
$2.50 → $20.00
8×
warm ×10 → cold ×1. 10 pings ≈ 8 hours of warmth; pinging stops after
12 h idle, which keeps it under the 20-ping break-even for a 1-hour rewrite.
Full table (20K–1M, all models, break-even) and the generator:
docs/COST.md.
Who this is for
✅ For: Claude Code on official Anthropic — both a Claude Pro/Max
subscription and a Console API key. On a subscription the main
conversation gets a 1-hour prompt-cache TTL (within your plan's included
usage); leave a session idle longer than that and your next message
re-processes the whole prefix — slower, and far more usage than a cache read.
This keeps the prefix warm so you come back to a cheap cache read. The
defaults (50 min) are tuned for that 1-hour TTL.
On an API key the default TTL is 5 minutes, so lower the numbers or set a
1-hour TTL yourself — see Timing rule.
🔌 Other APIs / gateways? The plugin never inspects your provider, so
any endpoint works — DeepSeek, GLM, OpenRouter, a self-hosted proxy, any
Anthropic-compatible gateway — as long as the Monitor tool starts normally.
Whether it starts is decided entirely by Claude Code, not by this plugin: the
Monitor tool is first-party only and is skipped when the telemetry-disable
env vars below are set or on Bedrock / Vertex / Foundry. If your setup can
start a monitor, the keepalive runs on it unchanged — just keep in mind that
other services may have different cache semantics (a cache read may not
refresh the TTL the same way), so the cost math below may not hold.
How it works
turn ends (Stop) ─────────────► stamp hook: last_stop = now (instant, non-blocking)
you submit (UserPromptSubmit) ─► stamp hook: last_stop = now
background Monitor loop (dies with the session):
every TICK (default 300s):
idle = now - last_stop
if idle < IDLE_SECONDS: do nothing
else: echo "<ping>" ─► Claude Code delivers it as a notification
└► new turn → cache READ → TTL refreshed
└► turn ends → Stop → last_stop = now → ↻
Because the timer is now - last_stop, it is a resettable idle timer:
every Stop restarts the 50-minute window. An actively used session is never
pinged; only a genuinely idle one is.