ModsCode / Claude Code Mods / Ranking / cachebeat
cachebeat
Keeps the prompt cache warm while a session sits idle: shortly before the cache would expire, a small background request re-reads it, without touching the transcript. A beating heart under the prompt shows it working, and Claude can read a…
What it does
- Draws a band above the prompt, a pane, toasts
- Adds /cachebeat
- Watches mcp__cachebeat__state, mcp__cachebeat__set calls and can refuse them
- Hooks classic.PostModelSwitch, session.compact, session.end, session.start and 5 more
- Keeps its own state between turns
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 cachebeat by Mayank (pane, band, toast), as ModsCode read it from the mod's code:
// https://modscode.com/claude-mods/mods/404mayank-cachebeat/
// 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 } = $.ui.resolve(e)
const text = '…'
const text2 = '…'
const text3 = '…'
const text4 = '…'
const text5 = '…'
const text6 = '…'
const text7 = '…'
const text8 = '…'
const text9 = '…'
const text10 = '…'
const text11 = '…'
const text12 = '…'
return (
<Box flexDirection="column">
<Box flexDirection="row">
<Box flexDirection="row" flexShrink={0} marginLeft={1} marginRight={1}>
<Box width={1} flexShrink={0} justifyContent="center">
<Text>
{text}
</Text>
<Text>
{text2}
</Text>
<Text>
{text3}
</Text>
</Box>
<Box width={1} flexShrink={0} justifyContent="center">
<Text>
{text4}
</Text>
<Text>
{text5}
</Text>
<Text>
{text6}
</Text>
</Box>
<Box width={1} flexShrink={0} justifyContent="center">
<Text>
{text7}
</Text>
<Text>
{text8}
</Text>
<Text>
{text9}
</Text>
</Box>
</Box>
<Text>
{text10}
</Text>
<Text>
{text11}
</Text>
<Text>
{text12}
</Text>
</Box>
{await next(e)}
</Box>
)
})
// the pane: open it with $.ui.open({ id: 'my-pane', title: "cachebeat" })
on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
const { Box, Button, Text, Input } = $.ui.resolve(e)
const label = '…'
const help = '…'
const shown = '…'
const text = '…'
const text2 = '…'
const text3 = '…'
const text4 = '…'
const text5 = '…'
const text6 = '…'
const text7 = '…'
const text8 = '…'
const text9 = '…'
const placeholder = '…'
const text10 = '…'
const text11 = '…'
const text12 = '…'
const text13 = '…'
const text14 = '…'
const text15 = '…'
const notice = '…'
return (
<Box flexDirection="column">
<Box gap={1}>
<Button plain>
{`‹`}
</Button>
<Text bold>
{label}
</Text>
</Box>
<Text dimColor>
{help}
</Text>
<Text dimColor>
────────
</Text>
<Box>
<Button plain>
{`● ${shown}`}
</Button>
<Text>
{" "}
</Text>
<Text>
{text}
</Text>
<Text>
{text2}
</Text>
<Text>
{text3}
</Text>
</Box>
<Box>
<Button plain>
{`● ${shown}`}
</Button>
<Text>
{" "}
</Text>
<Text>
{text4}
</Text>
<Text>
{text5}
</Text>
<Text>
{text6}
</Text>
</Box>
<Box>
<Button plain>
{`● ${shown}`}
</Button>
<Text>
{" "}
</Text>
<Text>
{text7}
</Text>
<Text>
{text8}
</Text>
<Text>
{text9}
</Text>
</Box>
<Input label="● custom " placeholder={`${placeholder}`} value={`${shown}`} submitLabel="set" />
<Text dimColor>
────────
</Text>
<Box flexDirection="column">
<Box>
<Text dimColor>
{"heart "}
</Text>
<Text>
{text10}
</Text>
<Text>
{text11}
</Text>
<Text>
{text12}
</Text>
<Text dimColor>
{" ×3"}
</Text>
</Box>
<Box>
<Text dimColor>
{"status "}
</Text>
<Box flexDirection="column">
<Text dimColor>
✻ Brewed for 2s
</Text>
<Box marginTop={1}>
<Text>
{text13}
</Text>
<Text>
{text14}
</Text>
<Text>
{text15}
</Text>
</Box>
</Box>
</Box>
</Box>
<Text dimColor>
{notice}
</Text>
<Text dimColor>
↑↓ move · enter picks · esc back
</Text>
</Box>
)
})
on('session.start', async ($, e, next) => {
const text = '…'
const tokens = '…'
await $.ui.toast(`cachebeat ${text}`)
await $.ui.toast(`♥ cache kept warm · ${tokens} read`)
return next(e)
})
}
The mod's own code
Shown under the mod's licence (MIT); its text is below. Keep the notice if you copy these lines.
hooks/register.tsx lines 748–782 · Band
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
if (e.surface !== 'desktop') return next(e)
const c = await read($, settingsAtom)
isStatusOnBand = c.statusLine !== 'off'
const line = await read($, lineAtom)
if (!isStatusOnBand || !line || e.props.hasSurvey || e.props.isWorking) return next(e)
const p = await read($, pulse)
if (p === 'armed' && c.lineAnimate) animateLine($)
const f = c.lineAnimate ? await read($, lineFrameAtom) : 0
const { Box, Text } = $.ui.resolve(e)
// the band's font is proportional: the heart's frames differ in width, so it gets a box of its own
// and the words after it never move
const { head, rest, width } = liveLine(line, c, p, f)
// one glyph keeps its width as it beats: the line is one run of text, spaced as written
if (width <= 1) return <Box>{paint(Text, joined([...head, ...rest]))}</Box>
// a wider animation, on this proportional font, would change width from frame to frame and carry
// the words after it along: each of its characters gets a cell of its own, centered in it, as the
// terminal's grid has them, so it is as wide as its frames' cells. A cell's margin, not the space,
// keeps the words off it: that space would collapse at the next box's start, as in HTML
if (rest[0]) rest[0] = { ...rest[0], text: rest[0].text.replace(/^ /, '') }
const slots = head.flatMap(sp => glyphs(sp.text).map(ch => ({ ...sp, text: ch })))
const widths = slotWidths(variant(c.statusHeart)) // a heart's slot is wider, wherever any frame has one
return (
<Box flexDirection="row">
<Box flexDirection="row" flexShrink={0} marginLeft={1} marginRight={1}>
{slots.map((sp, i) => (
<Box width={widths[i] ?? 1} flexShrink={0} justifyContent="center">
{paint(Text, [{ ...sp, text: slotText(sp.text, widths[i] ?? 1) }])}
</Box>
))}
</Box>
{paint(Text, rest)}
</Box>
)
})hooks/pane.tsx lines 46–48 · Band
export function paint(Text: Els['Text'], list: Span[]) {
return list.map(sp => (sp.color ? <Text color={sp.color} dimColor={sp.dim}>{sp.text}</Text> : <Text dimColor={sp.dim}>{sp.text}</Text>))
}hooks/register.tsx lines 784–832 · Pane
on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
const c = await read($, settingsAtom)
const page = await read($, pageAtom)
const tick = await read($, tickAtom)
const focus = await read($, focusAtom)
await read($, pulse) // redraws "This session" as it turns on or off
// the preview's clock runs only while there is a preview to move
const picked = page.picker ? rowOf(page.picker) : undefined
const isMoving = picked ? picked.row.key === 'variant' || !!picked.tab.preview : !!TABS.find(t => t.id === page.tab)?.preview
// at the speed of the part on show: the turn line's on its tab, the heart's elsewhere
const part = (picked?.tab.id ?? page.tab) === 'status' ? 'line' : 'heart'
if (!isMoving) stopPaneTicker()
else if (!paneTicker) paneTicker = $.clock.every(frameMs(lookOf(c, part)), () => void update($, tickAtom, () => ++paneTick))
const els = $.ui.resolve(e)
paneSurface = e.surface
if (!('Input' in els)) return <els.Text>Open cachebeat's settings in the terminal.</els.Text>
const view = {
page, tick, focus, columns: e.props.bodyColumns, isOn: s.enabled, sessionMinutes: s.idle === null ? null : s.idle / MIN,
autoMinutes: AUTO[s.isCacheShort ? '5m' : ttl], notice, isResetArmed, isTerminal: e.surface === 'terminal', customs,
}
const { tree, ring: walk } = settingsPane(els, c, view, {
set: patch => void setSettings($, patch),
// a press on a tab (Enter, 1-5, a click) shows it and goes into its settings
tab: id => void goTo($, { tab: id, picker: null }, firstOf(id, c)),
at: key => void focusOn($, key),
open: key => {
// the focus starts on the value set: one of the choices, or the custom field
const { row } = rowOf(key)!
const i = row.values.indexOf(c[key])
void goTo($, { ...page, picker: key }, i >= 0 ? `opt:${i}` : row.custom ? 'custom' : 'opt:0', true)
},
pick: (key, value) => void setSettings($, { [key]: value }).then(() => (say($, ''), goTo($, { ...page, picker: null }, `row:${key}`))),
refuse: text => say($, text),
resetRow: key => void setSettings($, { [key]: DEFAULTS[key] }).then(() => say($, `${rowOf(key)!.row.label.trim()} back to its default`)),
back: () => void goTo($, { ...page, picker: null }, `row:${page.picker}`),
toggleSession: () => void (s.enabled ? Promise.resolve(stop($)) : turnOn($, undefined).then(r => r.text)).then(t => say($, `this session: ${t}`)),
beatNow: () => void beatNow($).then(t => say($, t)),
reset: () => {
if (!isResetArmed) {
isResetArmed = true
return say($, '')
}
isResetArmed = false
void setSettings($, DEFAULTS).then(() => say($, 'settings reset to the defaults'))
},
})
ring = walk
return tree
})hooks/pane.tsx lines 66–103 · Pane
function preview(els: Els, s: BeatSettings, kind: Preview, tick: number) {
const { Box, Text } = els
const x = variant(s.variant)
const heartLook = lookOf(s, 'heart')
const lineLook = lookOf(s, 'line')
const frame = heartLook.animate ? previewFrame(x, tick, heartLook.timing) : x.loop[0]!
// the hint line takes text alone, drawn dim
const heart = s.heartPlacement === 'tail' ? [{ text: frame, dim: true }] : spans(frame, heartLook, tick, isLit(frame))
const sample = statusText(s, 3, 184_000, '42m')
const lead = lineLook.animate && s.statusHeart !== 'off' ? statusFrame(s.statusHeart, tick, lineLook.timing) : ''
const lineLit = isLit(lead || statusFrame('beat', tick, lineLook.timing))
const line = paint(Text, spans(lead ? sample.replace(/^[♥♡]/, lead) : sample, lineLook, tick, lineLit))
const turn = <Text dimColor>✻ Brewed for 2s</Text>
const status = s.statusLine === 'off' ? turn
: (
<Box flexDirection="column">
{turn}
<Box marginTop={s.statusLine === 'spaced' ? 1 : 0}>{line}</Box>
</Box>
)
return (
<Box flexDirection="column">
{kind !== 'status' && (
<Box>
<Text dimColor>{'heart'.padEnd(8)}</Text>
{paint(Text, heart)}
{s.showCount && <Text dimColor> ×3</Text>}
</Box>
)}
{kind !== 'heart' && (
<Box>
<Text dimColor>{'status'.padEnd(8)}</Text>
{status}
</Box>
)}
</Box>
)
}Licence text (MIT)
MIT License Copyright (c) 2026 Mayank 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), Deny a tool call
What its code calls
env varsdrives Claudetool callsremembers
What its code shows
Read from the source at commit 37b6d12b3012 on 2026-10-11. 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.hooks/register.tsx |
| Parses | Every file parses as TypeScript or JavaScript.5 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, with its own branch for the desktop |
| 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 environment variables, settings.json, 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.no skills, commands, agents or workflows |
| 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).calls no tool, MCP server or command |
| 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), adds command cachebeat, adds tool ? |
| 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: command.run (cachebeat), tool.call (mcp__cachebeat__state, mcp__cachebeat__set) · reads: classic.PostModelSwitch · also: session.start, session.end, ui.render (ToolUse, ToolResult, TurnDuration (+3)), session.compact (+5) · timers: clock.every, clock.after |
| 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.env: FORCE_PROMPT_CACHING_5M, CLAUDE_CODE_PROMPT_CACHE_TTL, ENABLE_PROMPT_CACHING_1H; settings.json |
| 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.writes no files, environment variables, settings or conversation rows |
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 404Mayank/cachebeat/plugin install cachebeat@cachebeat/reload-pluginsThis installs the marketplace's latest commit, which may not be the one read here (37b6d12b3012). 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/404Mayank/cachebeatgit -C cachebeat checkout 37b6d12b30123c9abe65004dd4c0e4ecb3b1f431claude plugin validate cachebeatclaude --plugin-dir cachebeatThe 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 about it
With the ModsCode connector added, Claude can read this mod's code and what it reaches, and build on them. Ask it like this:
Read the ModsCode mod "404mayank-cachebeat" with its code and make me one like itSearch them from Claude: the MCP connector
Similar mods
- code-modernizationAnthropic★ 37,653
- ai-maestro-secrets23blocks-OS★ 817
- hopeSaad Shahd★ 35
- agent-discoverkeshrath★ 7
- fanyijax★ 5
- glossary-browserFabrizio Duroni★ 5
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/404mayank-cachebeat/)