modscode / Gallery / cache-caffeine
cache-caffeine
Keeps the prompt cache warm while you step away: a short poke before the cache expires, so the next turn reads the cache instead of writing it again. A row above the prompt turns it on and off and edits the message. Near the usage limit it…
What it does
- Draws a band above the prompt, the status line, toasts
- Adds /caffeine
- Hooks classic.StopFailure, prompt.submit, session.compact, session.end 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
Two kinds: a starter modscode writes from the design above, and the lines of the mod's own code that draw it.
Starter (register.tsx)
import type { Register } from 'claude-code'
// Drawn like cache-caffeine by Luis Perez Morales (band, status, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/lperezmo-cache-caffeine/
// 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 label = '…'
const percent = '…'
const clock = '…'
const span = '…'
const steam = '…'
const degrees = '…'
const text = '…'
return (
<Box flexDirection="column">
<Box flexDirection="row" columnGap={2}>
<Text color="red" wrap="truncate-end">
{`${label} limit ${percent}% · resets ${clock} (in ${span})`}
</Text>
<Button plain hotkey="u">
{`wake Claude at ${clock}`}
</Button>
<Button plain dimColor hotkey="n">
not now
</Button>
</Box>
<Box flexDirection="column">
<Text>
{` ${steam}`}
</Text>
<Box flexDirection="row" columnGap={2}>
<Box flexDirection="row" columnGap={1} flexShrink={0}>
<Text>
c[_]
</Text>
<Text>
{`${degrees}°F`}
</Text>
</Box>
<Box flexShrink={1} minWidth={0}>
<Text wrap="truncate-end">
{text}
</Text>
</Box>
<Box flexDirection="row" columnGap={2} flexShrink={0}>
<Button plain hotkey="t">
turn off
</Button>
<Button plain dimColor hotkey="e">
message
</Button>
</Box>
</Box>
</Box>
{await next(e)}
</Box>
)
})
on('session.start', async ($, e, next) => {
const degrees = '…'
const text = '…'
const label = '…'
const percent = '…'
const clock = '…'
await $.ui.status(`${degrees}°F ${text}`)
await $.ui.toast(`caffeine: ${text}`)
await $.ui.toast(`caffeine: ${label} limit at ${percent}%, resets ${clock}. /caffeine wake books a wake.`)
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.
plugins/cache-caffeine/hooks/register.tsx lines 844–965 · Band
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
if ((e.surface !== 'terminal' && e.surface !== 'desktop') || e.props.hasSurvey) {
return next(e)
}
const { Box, Button, Input, Text } = $.ui.resolve(e)
const now = await $.clock.now()
c.bandId = e.requestId
// the wake row: near the limit an offer, once booked a countdown
const block: Block | null = blocking(c.limits)
const isOffered = !c.armed && block !== null && (isNear(c.limits) || c.isHit) && c.dismissed !== block.resetsAt
const armed = c.armed
const wakeRow = armed ? (
<Box key="caffeine-wake-row" flexDirection="row" columnGap={2}>
<Text key="wake-text" color="cyan" wrap="truncate-end">
{`caffeine · Claude continues at ${clock(armed.at, now)} (in ${span(armed.at - now)})`}
</Text>
<Button key="caffeine-wake-cancel" plain dimColor hotkey="n" onPress={() => void disarm($, c).then(() => tell($, 'wake cancelled.'))}>
cancel
</Button>
</Box>
) : isOffered ? (
<Box key="caffeine-wake-row" flexDirection="row" columnGap={2}>
<Text key="wake-text" color={block!.percent >= 100 ? 'red' : 'yellow'} wrap="truncate-end">
{`${block!.label} limit ${block!.percent}% · resets ${clock(block!.resetsAt, now)} (in ${span(block!.resetsAt - now)})`}
</Text>
<Button key="caffeine-wake" plain hotkey="u" onPress={() => void armAtReset($, c)}>
{`wake Claude at ${clock(wakeAfter(block!.resetsAt), now)}`}
</Button>
<Button
key="caffeine-wake-dismiss"
plain
dimColor
hotkey="n"
onPress={() => {
c.dismissed = block!.resetsAt
$.ui.invalidate('ui.render')
}}
>
not now
</Button>
</Box>
) : null
// the switch row, under its cup
const line = describe(c, now)
const warm = cup(c, now)
const row = !c.isBanded ? null : c.isEditing ? (
<Box key="caffeine" flexDirection="row" columnGap={2}>
<Input
key="caffeine-message"
label="caffeine says: "
value={c.message}
placeholder={DEFAULT_MESSAGE}
submitLabel="save"
autoFocus
onSubmit={text => void setMessage($, c, text).then(saved => tell($, `the poke now says: ${saved}`))}
/>
<Button
key="caffeine-cancel"
plain
dimColor
hotkey="q"
onPress={() => {
c.isEditing = false
$.ui.invalidate('ui.render')
}}
>
cancel
</Button>
</Box>
) : (
<Box key="caffeine" flexDirection="column">
<Text key="steam" color={warm?.color} dimColor={!warm}>
{` ${warm?.steam ?? ' '}`}
</Text>
<Box key="caffeine-row" flexDirection="row" columnGap={2}>
<Box key="caffeine-cup" flexDirection="row" columnGap={1} flexShrink={0}>
<Text key="cup" color={warm?.color} dimColor={!warm}>
c[_]
</Text>
<Text key="degrees" color={warm?.color} dimColor={!warm}>
{warm ? `${warm.degrees}°F` : '--°F'}
</Text>
</Box>
<Box key="caffeine-line" flexShrink={1} minWidth={0}>
<Text key="text" color={line.color} dimColor={line.isDim} wrap="truncate-end">
{line.text}
</Text>
</Box>
<Box key="caffeine-buttons" flexDirection="row" columnGap={2} flexShrink={0}>
<Button
key="caffeine-toggle"
plain
hotkey="t"
onPress={() => {
if (c.isOn) c.isAutoDeclined = true
void switchOn($, c, !c.isOn)
}}
>
{c.isOn ? 'turn off' : 'turn on'}
</Button>
<Button key="caffeine-edit" plain dimColor hotkey="e" onPress={() => void editInBand($, c)}>
message
</Button>
</Box>
</Box>
</Box>
)
if (!wakeRow && !row) {
return next(e)
}
const below = await next(e)
return (
<Box flexDirection="column">
{wakeRow}
{row}
{below}
</Box>
)
})Licence text (MIT)
MIT License Copyright (c) 2026 Luis Perez Morales 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.
What its code calls
env varsdrives Clauderemembers
The design, read from code
Drawn from the mod's source at the commit read, not from a run: a list is drawn three times, a condition takes its first branch that draws in the desktop app, and a value only the run time knows is shown as a made-up sample (dotted underline) or left out. Colours and type are this site's.
What its code shows
Read from the source at commit 30969f759233 on 2026-10-06. 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-caffeine/hooks/register.tsx |
| Parses | Every file parses as TypeScript or JavaScript.3 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, the same in both |
| 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 files or environment variables and reaches the network.reaches no network |
| 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 |
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 the code below (or run claude plugin validate . in its folder), weigh what it reaches, and install the commit you read.
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 lperezmo/cache-caffeine/plugin install cache-caffeine@cache-caffeineThis installs the marketplace's latest commit, which may not be the one read here (30969f759233). Compare them before you install.
Ask Claude about it
With the modscode connector added, Claude can read this design, what its code reaches and its code, and build on them. Ask it like this:
Read the modscode design "lperezmo-cache-caffeine" with its code and make me a pane like itSearch them from Claude: the MCP connector
Similar designs
-
Ask Claude…2h 10m · █████░░░✓ build ✓ build ✓ buildJavaKotlin3 Python■ ok 3 ■ ok 3 ■ ok 3 Razor proven 3 Razor proven 3 Razor proven 3Phases ──────── 3/3build Pythonbuild Pythonbuild Python… 3 more phasesLua ──────── 3/Kotlin■ the whole upgrade Ruby■ build build Ruby■ build build Ruby■ build build Ruby … 3 moreNext ──────── PythonRuby (by hand)Podsclick a button, or ctrl+x tab then Tab, EnterAttention ──────── 3! Scala ! Scala ! Scala … 3 moreSession ──────── okJava
-
Auto compact%System tools Compact▲Context is already at 42%, past Weekly%. Auto compact:NowAfter my next compactOnly in new chatsUsage limits show after the first reply.Auto compactToolsbuild42%Toolsbuild42%Toolsbuild42%Context12.4 free of 12.4k42% usedbuild12.4kbuild12.4kbuild12.4kAsk Claude…claude-code-usage-quota: Compact
-
Ask Claude…agent-discoverbuildbuildbuildRefreshMCP Browse/3Tab / shift+Tab move · Enter presses · ↑↓ scroll · Esc back to the promptBrowse...Audit asks:DeclineAcceptDeclineCancelAudit asks:DeclineAcceptDeclineCancelAudit asks:DeclineAcceptDeclineCancel
-
Ask Claude…────────Clear doneClaude⋯└─ buildCancelCancelCancel└─ buildCancelCancelCancel└─ buildCancelCancelCancel
-
Ask Claude…AgentsNo subagents yetmain: 3 3 · 2h 10m ago────────Each subagent shows here the moment it starts, with what it is doing now.›● 3 build build 3›● 3 build build 3›● 3 build build 3buildAgentsbuild1-9 picks an agent · Tab walks the controls · Esc gives the keyboard back14:32 3 314:32 3 314:32 3 3No tool calls yet.Answer: StopMessage this agent… SendStopBack b
-
Ask Claude…GitHub inboxGitHubloading…Refresh rbuildbuildbuildClose xStealth IssuesNo open issues in this view.#3 Fix login · Pinned notice · 2h 10m · Top row commentsWork on itopen#3 Fix login · Pinned notice · 2h 10m · Top row commentsWork on itopen#3 Fix login · Pinned notice · 2h 10m · Top row commentsWork on itopenPull requestsNo open pull requests.#3 Fix login · main · draft · build · HiddenChecksReviewopen#3 Fix login · main · draft · build · HiddenChecksReviewopen#3 Fix login · main · draft · build · HiddenChecksReviewopenChecks for #3Plain