Cache Keeper Claude Code mod: keep the prompt cache warm, no cold restarts
Shows if your Claude Code prompt cache is warm or cold, keeps big chats warm and asks before a costly cold send.
Permissions
- Reads filesCan read files and list directories on your machine ($.fs.read / list / stat / exists).
- Writes filesCan create or overwrite files on your machine ($.fs.write).
- Calls the model (uses your quota)Can send its own requests to Claude, which count against your plan's usage ($.model.* / $.agent.spawn).
- Intercepts tool callsSees every tool call Claude makes (tool.call / tool.check) and could block or change it.
- Reads your promptsCan see what you type and the conversation transcript (prompt.* / session.append / session.messages).
- Changes the UIDraws into the Claude Code interface: bands, panes, status text, toasts (ui.render / $.ui.*).
- Adds commands/toolsRegisters new slash commands or tools that you or Claude can invoke ($.command.register / $.tool.register).
- Stores dataKeeps data between sessions in the plugin's private store ($.store.*).
- tested with
- v2.1.310
- last tested
- requires
- Claude Code ≥ 2.1.287
- surfaces
- above-prompt, pane, toast
- source
- Nate Herk (nateherkai) (MIT)
Install inside Claude Code:
/plugin install cache-keeper --marketplace nateherkai/claude-code-modsWhat does this mod do?
The Claude Code cache keeper mod, Cache Keeper, is a community mod by Nate Herk (nateherkai), one of four plugins in his claude-code-mods collection. It is about one cost problem. Every Claude Code request re-reads the whole chat, and from the prompt cache that is much cheaper than normal input. Once the cache expires, the next message writes the entire context again. The mod's code puts that rewrite at 1.25x to 2x the input price. To keep Claude Code cache warm, it adds a band above the prompt, a keep-warm switch and a guard.
The band reads like ● cache warm 60m │ ctx 43.7k │ rewrite ≈ $0.09 │ session <$0.01, plus your 5-hour and weekly plan usage when Claude Code reports them. It turns yellow when the cache is within 5 minutes of expiring and shows a keep warm button for big chats. The mod adds four commands: /cache (status and settings), /keepwarm (ping the cache before it expires, 4 hours by default), /board (every local session in one pane) and /handoff (summarise the chat, then clear and continue from the summary). It also asks before you send a message into a big chat whose cache has gone cold. The author's README says it needs Claude Code 2.1.287 or later.
It overlaps with Cache Clock but does more: Cache Clock only displays the prompt_cache data Claude Code passes to the status line, while Cache Keeper sends keep-alive requests to keep the cache warm and asks before a cold send. Another mod in the same keep-warm space is karanb192/cache-tax (255 stars), which also keeps the cache warm during breaks and shows the estimated cost before a cold send.
Demo
The recording starts Claude Code with the mod loaded in the small demo project and asks Claude to read README.md and describe the project in one sentence. When the turn ends, a band appears above the prompt: cache warm 60m, ctx 43.7k, rewrite ≈ $0.09, the plan usage and the session cost, with an h: handoff button on the right. The clip then types /cache, and the status text prints below the prompt: tokens in context, the 60-minute cache window, how long the cache stays warm, session cost, cold restarts so far and the guard settings.
Install
Use any of the methods in the install block; they install straight from the author's own marketplace, nateherk-mods. The band shows up after your first request in a session.
$ install cache-keeper
Requires Claude Code ≥ 2.1.287
Installs from the author's own marketplace: nateherkai/claude-code-mods
1.One line, inside Claude Code
/plugin install cache-keeper --marketplace nateherkai/claude-code-modsPaste into a running session (v2.1.275+). Claude Code asks to add the marketplace first.
2.From your shell
claude plugin marketplace add nateherkai/claude-code-mods claude plugin install cache-keeper@nateherk-modsThen run /reload-plugins in any session that is already open.
3.Try it without installing
git clone https://github.com/nateherkai/claude-code-mods claude --plugin-dir ./claude-code-mods/cache-keeperLoads the mod for one session only. Nothing is added to your settings.
How it works
The mod listens to each main-loop request on turn.step and checks whether it read the cache or rewrote it. From the gap between requests it works out the cache window, 5 or 60 minutes, and sets it once it has measured one. Heartbeats for every session go into the plugin's $.store, which is how /board sees other chats. The keep-warm step, from hooks/register.mjs:
let reply = null
try {
reply = await $.model.fork({ prompt: 'cache-keeper keep-alive ping. Reply with only: ok' })
} catch {
reply = null
}
// A ping that writes instead of reading did not hit the cache: stop paying for it
if ((u.cache_creation_input_tokens || 0) > 0.1 * Math.max(1, u.cache_read_input_tokens || 0)) {
return stopKeepWarm($, `the ping wrote ${tokens(u.cache_creation_input_tokens)} tokens instead of reading the cache`)
}A tick runs every 30 seconds. When keep warm is on and the chat is idle, a ping goes out about 8 minutes before a 60-minute cache would expire, or 90 seconds before a 5-minute one. Prices come from a table in hooks/pricing.mjs that was cached on 2026-09-25, so treat the dollar figures as estimates.
Customize it
Everything goes through /cache, and the settings are saved in the plugin's store: /cache ttl 5|60|auto sets the cache window, /cache guard on|off toggles the cold-send guard, /cache big 150k changes what counts as a big chat, and /cache alerts on|off controls the cool-down toasts. /keepwarm 2 keeps the cache warm for 2 hours (at most 24), and /keepwarm off stops it. If a command name is taken by another plugin, the mod registers it again with a ck- prefix, for example /ck-cache.
Permissions & safety
We read every file the plugin can execute before running it: .claude-plugin/plugin.json, hooks/hooks.json, hooks/register.mjs and its three helpers (fmt.mjs, pricing.mjs, privacy.mjs), and the session-handoff skill. There is no package.json, install script, binary or minified code. The repository has an MIT LICENSE file.
- Network: none in the code. No
fetch, sockets or hosts. - Processes: none. It does not run shell commands.
- Model traffic: the keep-warm ping uses
$.model.forkand costs real tokens, but only after you turn/keepwarmon, and it stops itself after the time limit or when a ping misses the cache. - File writes: only
/handoffwrites a file, a backup of the handoff text under~/.claude/mods-data/cache-keeper/handoffs/. It reads~/.claude/mods-data/recording.json, a flag written by the author's separate Recording Mode plugin, to mask labels and dollar figures. It does not touchsettings.json, shell files or LaunchAgents. - Shared state: session heartbeats (id, project folder name, a label made from the first 40 characters of your first prompt, context size, cost) live in the plugin's
$.store, so every session of this mod on the machine can see them. A board button in one session can send a keep-warm command to another through the same store. - Daemons: none. A 30-second timer runs inside Claude Code and ends with it.
- Gating: it can drop a message you typed (the cold-send guard, with a dialog) and it adds a hook on
tool.checkandtool.callthat only observes. After a handoff,/clearplus a new prompt carrying the summary are run, but only after you pick "Clear and continue" or press the button. - Environment: it reads
HOMEandUSERPROFILEto find~/.claude. No secrets are read. - Telemetry: none. Injected text: the continuation prompt contains the saved handoff, and no hidden text was found.
claude plugin validate reported no errors, only a missing-icon warning and notes that 11 gating hooks have no .catch. claude plugin test found no *.test.ts files, so there were no author tests to run. We checked it by loading it on Claude Code 2.1.310 and recording the demo.
- Reads files
- Can read files and list directories on your machine ($.fs.read / list / stat / exists).
- Writes files
- Can create or overwrite files on your machine ($.fs.write).
- Calls the model (uses your quota)
- Can send its own requests to Claude, which count against your plan's usage ($.model.* / $.agent.spawn).
- Intercepts tool calls
- Sees every tool call Claude makes (tool.call / tool.check) and could block or change it.
- Reads your prompts
- Can see what you type and the conversation transcript (prompt.* / session.append / session.messages).
- Changes the UI
- Draws into the Claude Code interface: bands, panes, status text, toasts (ui.render / $.ui.*).
- Adds commands/tools
- Registers new slash commands or tools that you or Claude can invoke ($.command.register / $.tool.register).
- Stores data
- Keeps data between sessions in the plugin's private store ($.store.*).
Compatibility & troubleshooting
Checked with Claude Code 2.1.310 on macOS. If something looks wrong:
- Run
/cache. It says whether a request has been seen yet; before the first request the cache state is unknown and no band is drawn. - Run
claude --versionand check you have 2.1.287 or later. - If
/cacheis missing, another plugin may own the name. Try/ck-cache. - The band is terminal-only; the Desktop app gets a short footer label instead.
- Dollar figures are estimates, and on a subscription they stand for plan usage, not a bill.
FAQ
- Does Cache Keeper make network requests?
- Not by itself. The code has no fetch, socket or shell call. The only extra model traffic is the keep-warm ping, a small request made through Claude Code's own fork call, and only while /keepwarm is on.
- What does a keep-warm ping cost?
- It reads the cached context, which the mod's price table puts at roughly a tenth of normal input, instead of rewriting it at 1.25x to 2x. The band and /cache show the number of pings and their estimated cost. If a ping writes to the cache instead of reading it, keep warm turns itself off.
- Which chats does the cold-send guard ask about?
- Only messages you type yourself, in a chat whose context is over 150k tokens (adjustable with /cache big) and whose cache has already expired. It offers Send anyway, Compact first then send, or Cancel. If no dialog can be shown, as in a -p run, the message is sent as typed.
- Where does the handoff file go?
- Into ~/.claude/mods-data/cache-keeper/handoffs/ as a Markdown file named with the date, project folder and session id. The bundled skill text says chat-only, but the mod saves the answer to that file as a backup.
- How is it different from cache-clock?
- cache-clock adds a status-line segment fed by the prompt_cache data Claude Code reports. Cache Keeper draws its own band above the prompt, estimates the cache window itself, and adds keep-warm, the cold-send guard, a board of sessions and a handoff.
# Related mods
FeaturedCache Clock
A prompt-cache line under your Claude Code status line: time left while warm, hit rate, and tokens re-cached once cold.
- status
- Reads files
- Writes files
- Runs commands
- Adds commands/tools
tested with v2.1.296
FeaturedCompact Adviser
Suggests running /compact when your Claude Code session reaches a finished checkpoint, judged by TypeSafe's Jev model.
- status
- pane
- toast
- Reads files
- Writes files
- Network
- Reads your prompts
- Changes the UI
- Adds commands/tools
- Stores data
tested with v2.1.291
FeaturedContext Meter
Context-window fill, 5-hour and 7-day plan usage and session cost in the status line, plus a warning near the limit.
- status
- toast
- Changes the UI
tested with v2.1.310
More in Context, quota, cost, Timers, todos, standups, Slash commands.