ModsCode / Claude Code Mods / Ranking / cache-keeper
cache-keeper
Keeps an idle session's prompt cache warm for as long as you choose, then compacts or hands off before it expires; holds a costly cold send with its price and your choices; /keepwarm opens a pane with the session's settings
What it does
- Draws a band above the prompt, a pane
- Hooks classic.SessionStart, prompt.submit, session.compact, session.end and 4 more
Good points
- No network calls
- Starts no processes
- Written in TypeScript
- Has a desktop-specific branch
Code to start from
A starter ModsCode writes from the drawing it read, and the mod's own lines that draw, where there are any.
Starter (register.tsx)
import type { Register } from 'claude-code'
// Drawn like cache-keeper by Brennen Barney (pane, band, status), as ModsCode read it from the mod's code:
// https://modscode.com/claude-mods/mods/bbarney7-cache-keeper/
// Written by ModsCode from that reading, not copied from the mod: use it as you like.
// Each value below stands for one the mod works out at run time; put in your own.
export const register: Register = on => {
// the band above the prompt; what else goes there is drawn under it
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
const { Box, Text, Button } = $.ui.resolve(e)
const state = '…'
const text = '…'
const reason = '…'
const preview = '…'
const note = '…'
const sendLabel = '…'
return (
<Box flexDirection="column">
<Box>
<Text>
●
</Text>
<Text dimColor>
{" cache "}
</Text>
<Text bold>
{state}
</Text>
<Text dimColor>
{` · ${text}`}
</Text>
</Box>
<Box flexDirection="column" width="100%" borderStyle="round" borderColor="warning" paddingX={1}>
<Text>
{reason}
</Text>
<Text dimColor wrap="truncate-end">
{`“${preview}”`}
</Text>
<Text color="error">
{note}
</Text>
<Box flexDirection="column">
<Box gap={1} flexWrap="wrap">
<Button hotkey="1" label={`${sendLabel}`} variant="primary" />
<Button hotkey="2" label="Compact, then send" />
<Button hotkey="3" label="Clear, keep draft" />
<Button hotkey="4" label="Discard" dimColor />
</Box>
</Box>
</Box>
{await next(e)}
</Box>
)
})
// the pane: open it with $.ui.open({ id: 'my-pane', title: "Cache keeper" })
on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
const { Box, Text, Button } = $.ui.resolve(e)
const text = '…'
const tokens = '…'
const model = '…'
const usd = '…'
const keepHint = '…'
const stopped = '…'
const label = '…'
const EXPIRY_LABELS = '…'
const GUARD_LABELS = '…'
const paneNote = '…'
const length = '…'
const spent = '…'
const breakEven = '…'
return (
<Box flexDirection="column">
<Box>
<Text>
●
</Text>
<Text dimColor>
{" cache "}
</Text>
<Text bold>
idle
</Text>
<Text dimColor>
{` · ${text}`}
</Text>
</Box>
<Text dimColor>
{`${tokens} tokens on ${model} · a cold send ${usd}, a warm one ${usd}`}
</Text>
<Text bold>
{"\nKeep warm for"}
</Text>
<Box gap={1} flexWrap="wrap">
<Button label="Off" variant="primary" />
<Button label="Off" variant="primary" />
<Button label="Off" variant="primary" />
</Box>
<Text dimColor>
{keepHint}
</Text>
<Text color="warning">
{`Stopped until your next message: ${stopped}.`}
</Text>
<Text bold>
{"\nBefore it expires"}
</Text>
<Box gap={1} flexWrap="wrap">
<Button label={`${label}`} variant="primary" />
<Button label={`${label}`} variant="primary" />
<Button label={`${label}`} variant="primary" />
</Box>
<Text dimColor>
{EXPIRY_LABELS}
</Text>
<Text bold>
{`
A cold send over ${tokens} tokens`}
</Text>
<Box gap={1} flexWrap="wrap">
<Button label={`${label}`} variant="primary" />
<Button label={`${label}`} variant="primary" />
<Button label={`${label}`} variant="primary" />
</Box>
<Text dimColor>
{GUARD_LABELS}
</Text>
<Box marginTop={1}>
<Text color="warning">
Keeping warm…
</Text>
</Box>
<Text dimColor>
{paneNote}
</Text>
<Text bold>
{"\nThis session"}
</Text>
<Text dimColor>
{`${length} keep-warm · read ${tokens}${spent}`}
</Text>
<Text dimColor>
{`${length} cold write paid · ${tokens} · ${usd}`}
</Text>
<Text dimColor>
{`${breakEven} keep-warms cost one cold write`}
</Text>
<Box marginTop={1} gap={1} alignItems="center">
<Text dimColor>
This session only · defaults in /config
</Text>
<Button label="Reset" variant="secondary" />
</Box>
</Box>
)
})
}
The mod's own code
Shown under the mod's licence (MIT); its text is below. Keep the notice if you copy these lines.
plugins/cache-keeper/hooks/register.tsx lines 796–844 · Band
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
const rest = await next(e)
const cfg = effective()
if (e.props.hasSurvey || (e.surface !== 'terminal' && e.surface !== 'desktop')) return rest
const now = await $.clock.now()
const last = keeps.at(-1)
const row = cfg.showRow
? rowParts(clock, cfg, now, { keeps: keeps.length, lastPing: last ? { read: last.read, usd: last.usd } : undefined, context, price: price(), outcome })
: undefined
const card = held ? heldCard(held, clock, cfg, now, context, price()) : undefined
if (!row && !card) return rest
const { Box, Text, Button } = $.ui.resolve(e)
const color = row?.state === 'warm' ? 'success' : row?.state === 'cold' ? 'warning' : 'subtle'
return (
<Box flexDirection="column">
{rest}
{row ? (
<Box>
<Text color={color}>●</Text>
<Text dimColor> cache </Text>
<Text color={color} bold>
{row.state}
</Text>
<Text dimColor>{` · ${row.text}`}</Text>
</Box>
) : null}
{card ? (
<Box flexDirection="column" width="100%" borderStyle="round" borderColor="warning" paddingX={1}>
<Text>{card.reason}</Text>
<Text dimColor wrap="truncate-end">{`“${card.preview}”`}</Text>
{card.note ? <Text color="error">{card.note}</Text> : null}
{card.doing ? (
<Text color="warning">{card.doing}</Text>
) : (
<Box flexDirection="column">
<Box gap={1} flexWrap="wrap">
<Button key="held-send" hotkey="1" label={card.sendLabel} variant="primary" onPress={() => chooseHeld($, 'send')} />
<Button key="held-compact" hotkey="2" label="Compact, then send" onPress={() => chooseHeld($, 'compact')} />
<Button key="held-clear" hotkey="3" label="Clear, keep draft" onPress={() => chooseHeld($, 'clear')} />
<Button key="held-discard" hotkey="4" label="Discard" dimColor onPress={() => chooseHeld($, 'discard')} />
</Box>
{e.surface === 'terminal' ? <Text dimColor>click one, or ctrl+x tab then 1–4</Text> : null}
</Box>
)}
</Box>
) : null}
</Box>
)
})plugins/cache-keeper/hooks/register.tsx lines 846–846 · Pane
on('ui.render', { component: 'Pane', requestId: PANE }, ($, e) => renderPane($, e))plugins/cache-keeper/hooks/register.tsx lines 525–612 · Pane
async function renderPane($: EngineInterface, e: RenderInput<'Pane'>) {
const { Box, Text, Button } = $.ui.resolve(e)
const cfg = effective()
const now = await $.clock.now()
const p = price()
const last = keeps.at(-1)
const row = rowParts(clock, cfg, now, { keeps: keeps.length, lastPing: last ? { read: last.read, usd: last.usd } : undefined, context, price: p, outcome })
const color = row?.state === 'warm' ? 'success' : row?.state === 'cold' ? 'warning' : 'subtle'
const hours = cfg.keepWarm ? cfg.keepWarmHours : 0
const changed = (Object.keys(overrides) as (keyof Patch)[]).some(k => overrides[k] !== config[k])
const chip = (key: string, label: string, on: boolean, patch: Patch) => (
<Button key={key} label={label} variant={on ? 'primary' : 'secondary'} onPress={() => void setFromPane($, patch)} />
)
const keepHint = [
hours > 0 ? "after Claude's last answer" : `the cache lapses ${duration(cfg.cacheTtlMinutes * 60_000)} after its last use`,
clock.holdUntil && clock.holdUntil > now && cfg.keepWarm ? `at least ${duration(clock.holdUntil - now)} more after a cold write` : undefined,
].filter(Boolean)
const read = keeps.reduce((sum, k) => sum + k.read, 0)
const spent = keeps.length && keeps.every(k => k.usd !== undefined) ? ` · ${usd(keeps.reduce((sum, k) => sum + (k.usd ?? 0), 0))}` : ''
const paid = coldWrites.reduce((sum, w) => sum + (w.usd ?? 0), 0)
return (
<Box flexDirection="column">
<Box>
<Text color={color}>●</Text>
<Text dimColor> cache </Text>
<Text color={color} bold>
{row?.state ?? 'idle'}
</Text>
<Text dimColor>{` · ${row?.text ?? "nothing cached yet; the clock starts at Claude's first answer"}`}</Text>
</Box>
{context > 0 ? (
<Text dimColor>
{`${tokens(context)} tokens${model ? ` on ${model}` : ''}${p ? ` · a cold send ${usd((context * p.write) / 1e6)}, a warm one ${usd((context * p.read) / 1e6)}` : ''}`}
</Text>
) : null}
<Text bold>{'\nKeep warm for'}</Text>
<Box gap={1} flexWrap="wrap">
{keepChoices(cfg).map(h => chip(`keep-${h}`, h === 0 ? 'Off' : duration(h * HOUR), h === hours, h === 0 ? { keepWarm: false } : { keepWarm: true, keepWarmHours: h }))}
</Box>
<Text dimColor>{keepHint.join(' · ')}</Text>
{clock.stopped ? <Text color="warning">{`Stopped until your next message: ${clock.stopped}.`}</Text> : null}
<Text bold>{'\nBefore it expires'}</Text>
<Box gap={1} flexWrap="wrap">
{(['nothing', 'compact', 'handoff'] as const).map(a => chip(`expiry-${a}`, EXPIRY_LABELS[a][0], cfg.atExpiry === a, { atExpiry: a }))}
</Box>
<Text dimColor>{EXPIRY_LABELS[cfg.atExpiry][1]}</Text>
<Text bold>{`\nA cold send over ${tokens(cfg.guardMinTokens)} tokens`}</Text>
<Box gap={1} flexWrap="wrap">
{(['refuse', 'warn', 'off'] as const).map(g => chip(`guard-${g}`, GUARD_LABELS[g][0], cfg.coldGuard === g, { coldGuard: g }))}
</Box>
<Text dimColor>{GUARD_LABELS[cfg.coldGuard][1]}</Text>
{row?.state === 'warm' || pinging ? (
<Box marginTop={1}>
{pinging ? <Text color="warning">Keeping warm…</Text> : <Button key="keep-now" label="Keep warm now" onPress={() => void keepWarmFromPane($)} />}
</Box>
) : null}
{paneNote ? <Text dimColor>{paneNote}</Text> : null}
<Text bold>{'\nThis session'}</Text>
<Text dimColor>{keeps.length ? `${keeps.length} keep-warm${keeps.length === 1 ? '' : 's'} · read ${tokens(read)}${spent}` : 'No keep-warms yet'}</Text>
<Text dimColor>
{coldWrites.length
? `${coldWrites.length} cold write${coldWrites.length === 1 ? '' : 's'} paid · ${tokens(coldWrites.reduce((sum, w) => sum + w.tokens, 0))} · ${usd(paid)}`
: 'No cold writes paid'}
</Text>
{p ? <Text dimColor>{`${breakEven(p)} keep-warms cost one cold write`}</Text> : null}
<Box marginTop={1} gap={1} alignItems="center">
<Text dimColor>This session only · defaults in /config</Text>
{changed ? (
<Button
key="reset"
label="Reset"
variant="secondary"
onPress={() => {
overrides = {}
void setFromPane($, {})
}}
/>
) : null}
</Box>
</Box>
)
}Licence text (MIT)
MIT License Copyright (c) 2026 Brennen Barney Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
How to build this: Pane (panel), Rewrite the prompt
What its code calls
drives Claudecalls tools
What its code shows
Read from the source at commit ef0c786ae7e7. The first group decides whether a mod is listed; the rest is for you to weigh. A later commit is not read until the next crawl.
| Decides the listing: code you can check | |
|---|---|
| Entry read | Every module hooks/hooks.json names was read.plugins/cache-keeper/hooks/register.tsx |
| Parses | Every file parses as TypeScript or JavaScript.1 files parsed |
| All its code is in the mod | Every import is a file of the mod or the engine's own module; no packages, no require.all its code is in the mod |
| Readable | No minified lines, no eval or new Function, no import of a computed path, no encoded blobs.no minified code, no eval, no encoded blobs |
| Calls in the open | Network and programs are reached as $.http.fetch and $.process.run in place, never passed around.every call outside goes through $ in the open |
| For you to weigh before installing | |
| Where it draws | The terminal, the desktop app, both, or nothing (hooks only: a guard or a prompt rewriter), as its code says. Shown, never a reason to leave a mod out.draws in the terminal and the desktop app; parts are terminal-only: AbovePrompt |
| Install line | Whether its repository's own .claude-plugin/marketplace.json lists it, so it installs from that marketplace with the lines on its page.listed in its repository's .claude-plugin/marketplace.json: installs from there |
| Programs on Windows | Whether every program it starts through $.process exists on Windows (tail, date, open, osascript, /usr/… do not).runs no program a Windows PC lacks |
| Network | Whether every fetch names its https host in the code.no network |
| Programs | Whether every program it starts is named in the code and is not a shell, an interpreter or a network tool.starts no programs |
| Reads and sends | Whether it both reads something of yours (files, environment variables, the transcript, settings) and reaches outside (the network, an MCP server, another session, telemetry).reads the prompt box, but reaches nothing outside |
| Keys in the source | Whether the source holds what looks like an API key or a private key.no keys in the source |
| Licence | An open licence (MIT, Apache-2.0, BSD, ISC, Unlicense, 0BSD, CC0) with its text lets ModsCode show its code; otherwise the code is linked.MIT |
| Settings hooks | Hooks declared in hooks/hooks.json or plugin.json beside the module: a command (a shell when it has no args), an HTTP request, an MCP tool or a model prompt at an event. They run outside $.no settings hooks: its function hooks alone |
| Servers it ships | MCP servers (a program, or a URL; a headersHelper is a shell command; a .mcpb bundle is unpacked at run time), LSP servers, monitors (a shell command for the whole session) and bin/ (on the PATH of the Bash tool).ships no MCP or LSP server, no monitor, no bin/ |
| Skills, commands, agents | What its Markdown declares beyond text: allowed-tools granted for the turn, hooks added when a skill is invoked, a command run before Claude reads the skill.1 command: text only |
| Tools and MCP | Whether every tool it calls through $.tool.call and $.mcp.call is named in the code, and none is a shell (Bash through the tool runs a shell without $.process).command.run: /compact; command.run: /clear |
| Asks of the model | Completions it runs ($.model.complete, fork, classify), subagents it spawns, prompts it submits as you, and the tools, commands and agents it adds.model.fork (sends its own transcript), prompt.submit (as the person) |
| Events it hooks | By what a hook there can do: gates (refuse a tool call, a prompt, a setting, another plugin), shapes (what the model reads: the system prompt, tool descriptions, each request), reads (your input, the events of the settings hooks, every event with *), and the rest.gates: prompt.submit, command.run · shapes: turn.step · reads: classic.SessionStart · also: session.start, session.end, turn.start, turn.complete (+2) · timers: clock.every |
| Reads, by name | The environment variables and files it names, and whether it reads the transcript, settings.json, the prompt box or the mouse selection.the prompt box |
| Writes, by name | The files and environment variables it names, and whether it changes settings, the prompt box, the clipboard, the conversation (a row the model reads) or another session.the conversation (a row the model reads); the prompt box |
This is a reading of the code text, not a security review: it does not run the mod, and it cannot see what a program the mod starts does. The check before installing is yours. How mods are chosen
Install it
Check it yourself before you install it. Mods run unsandboxed, with your permissions, and ModsCode does not vouch for what this code does. Read its code (or run claude plugin validate . in its folder), weigh what it reaches, and install the commit you read.
From its marketplace
Its repository is its marketplace. Add that marketplace (in the terminal with these commands, or in the desktop app's plugin settings) and install the mod from it:
/plugin marketplace add bbarney7/claude-code-mods/plugin install cache-keeper@claude-code-mods/reload-pluginsThis installs the marketplace's latest commit, which may not be the one read here (ef0c786ae7e7). Compare them before you install. /reload-plugins loads it into a session that is already open.
Try the commit ModsCode read
No marketplace needed. In a terminal, clone the repository, check out the commit read, validate the mod, and load it for one session:
git clone https://github.com/bbarney7/claude-code-modsgit -C claude-code-mods checkout ef0c786ae7e7382d952cd6dad0f01e7470f2259eclaude plugin validate claude-code-mods/plugins/cache-keeperclaude --plugin-dir claude-code-mods/plugins/cache-keeperThe validate line lists the events the mod hooks and what it asks Claude Code to do, without running it. The last line loads the mod for this session only and writes nothing to your settings. If the author has rewritten history, the commit may no longer exist.
Ask Claude or ChatGPT about it
With ModsCode added as a connector, Claude or ChatGPT can read this mod's code, what it reaches and how its controls are wired, and build on them. Ask it like this:
Read the ModsCode mod "bbarney7-cache-keeper" with its code and make me one like itAdd the ModsCode MCP to Claude or ChatGPT
Similar mods
- code-modernizationAnthropic★ 38,060
- seo-cockpitAgrici Daniel★ 18,364
- crit-tuiTomasz Tomczyk★ 1,205
- remctlFederico Viticci★ 595
- task-orchestrator-modJeff Picklyk★ 208
- localvoxtral-modlocalvoxtral★ 59
More from this repository
Badge for your README
If this is your mod, paste this into your README. It links to this page.
[](https://modscode.com/claude-mods/mods/bbarney7-cache-keeper/)