Ranking|Claude Code Mods

ModsCode / Claude Code Mods / Ranking / cache-countdown

cache-countdown

Prompt-cache meter above the input box: hit %, read/wrote/new tokens, a TTL countdown and advice; cache-expiry toasts and context-window alerts. /cache opens a detail pane; /cache setup walks through every setting.

Code you can checkTerminal + desktopPaneBandStatus lineToastBoxButtonInputText
env vars, draws

What it does

  • Draws a band above the prompt, a pane, toasts
  • Adds /cache
  • Hooks session.end, session.start, turn.step, ui.close
  • 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)

register.tsx
import type { Register } from 'claude-code'

// Drawn like cache-countdown by jmac122 (pane, band, status, toast), as ModsCode read it from the mod's code:
// https://modscode.com/claude-mods/mods/jmac122-cache-countdown/
// 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 hit = '…'
    const formatCount = '…'
    const countdownText = '…'
    const text = '…'
    return (
      <Box flexDirection="column">
        <Box flexDirection="row" columnGap={1}>
          <Box flexDirection="row" columnGap={1} flexShrink={0}>
            <Text>
              ●
            </Text>
            <Text bold color="cyan">
              cache
            </Text>
            <Text>
              ████████░░░░░░░░
            </Text>
            <Text bold>
              {`${hit}%`}
            </Text>
            <Text color="green">
              {`read ${formatCount}`}
            </Text>
            <Text color="yellow">
              {`wrote ${formatCount}`}
            </Text>
            <Text color="blue">
              {`new ${formatCount}`}
            </Text>
            <Text bold>
              {`⏱ ${countdownText}`}
            </Text>
          </Box>
          <Text dimColor wrap="truncate-end">
            {text}
          </Text>
        </Box>
        {await next(e)}
      </Box>
    )
  })

  // the pane: open it with $.ui.open({ id: 'my-pane', title: "cache" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button } = $.ui.resolve(e)
    const off = '…'
    const countdownText = '…'
    const value = '…'
    const text = '…'
    const model = '…'
    const formatCount = '…'
    const hit = '…'
    const v = '…'
    const v2 = '…'
    const v3 = '…'
    const v4 = '…'
    const v5 = '…'
    const v6 = '…'
    const v7 = '…'
    const v8 = '…'
    const v9 = '…'
    const v10 = '…'
    const v11 = '…'
    const v12 = '…'
    const v13 = '…'
    const v14 = '…'
    const v15 = '…'
    return (
      <Box flexDirection="column">
        <Box flexDirection="column">
          <Text bold color="cyan">
            PROMPT CACHE
          </Text>
          <Text dimColor wrap="wrap">
            {`off · ${off}`}
          </Text>
        </Box>
        <Box flexDirection="row" columnGap={1} marginTop={1}>
          <Text>
            {`⏱ ${countdownText} left`}
          </Text>
          <Text>
            ████████░░░░░░░░
          </Text>
          <Text>
            {`${value}%`}
          </Text>
        </Box>
        <Box flexDirection="column" marginTop={0}>
          <Text wrap="wrap">
            {text}
          </Text>
          <Text dimColor>
            {`${model} · prompt ${formatCount} tokens`}
          </Text>
        </Box>
        <Box flexDirection="column" marginTop={1}>
          <Box flexDirection="row" justifyContent="space-between">
            <Text bold>
              last request
            </Text>
            <Text>
              {`${hit}% hit`}
            </Text>
          </Box>
          <Box flexDirection="row">
            <Box height={1} backgroundColor="gray" />
            <Box height={1} backgroundColor="gray" />
            <Box height={1} backgroundColor="gray" />
          </Box>
          <Box flexDirection="row" columnGap={2}>
            <Text color="green">
              {`■ read ${formatCount}`}
            </Text>
            <Text color="yellow">
              {`■ wrote ${formatCount}`}
            </Text>
            <Text color="blue">
              {`■ new ${formatCount}`}
            </Text>
          </Box>
        </Box>
        <Box flexDirection="column" marginTop={1}>
          <Box flexDirection="row">
            <Box width={8} justifyContent="flex-start">
              <Text>
                {v}
              </Text>
            </Box>
            <Box width={8} justifyContent="flex-start">
              <Text>
                {v2}
              </Text>
            </Box>
            <Box width={8} justifyContent="flex-start">
              <Text>
                {v3}
              </Text>
            </Box>
          </Box>
          <Box flexDirection="row">
            <Box width={8} justifyContent="flex-start">
              <Text>
                {v4}
              </Text>
            </Box>
            <Box width={8} justifyContent="flex-start">
              <Text>
                {v5}
              </Text>
            </Box>
            <Box width={8} justifyContent="flex-start">
              <Text>
                {v6}
              </Text>
            </Box>
          </Box>
          <Box flexDirection="row">
            <Box width={8} justifyContent="flex-start">
              <Text>
                {v7}
              </Text>
            </Box>
            <Box width={8} justifyContent="flex-start">
              <Text>
                {v8}
              </Text>
            </Box>
            <Box width={8} justifyContent="flex-start">
              <Text>
                {v9}
              </Text>
            </Box>
          </Box>
          <Box flexDirection="row">
            <Box width={8} justifyContent="flex-start">
              <Text>
                {v10}
              </Text>
            </Box>
            <Box width={8} justifyContent="flex-start">
              <Text>
                {v11}
              </Text>
            </Box>
            <Box width={8} justifyContent="flex-start">
              <Text>
                {v12}
              </Text>
            </Box>
          </Box>
          <Box flexDirection="row">
            <Box width={8} justifyContent="flex-start">
              <Text>
                {v13}
              </Text>
            </Box>
            <Box width={8} justifyContent="flex-start">
              <Text>
                {v14}
              </Text>
            </Box>
            <Box width={8} justifyContent="flex-start">
              <Text>
                {v15}
              </Text>
            </Box>
          </Box>
        </Box>
        <Box flexDirection="row" columnGap={2} marginTop={1}>
          <Button label="close" role="dismiss" />
          <Text dimColor>
            Esc or /cache stop closes
          </Text>
        </Box>
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    const read = '…'
    await $.ui.toast(`cache-countdown is on: /cache setup walks through its settings`)
    await $.ui.toast(`cache-countdown settings: ${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/cache-countdown.tsx lines 484–519 · Band
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    if (!cfg.band || e.props.hasSurvey) return next(e)
    const view = await read($, viewAtom)
    if (!view) return next(e)
    const { Box, Text } = $.ui.resolve(e)
    if (view.off && !view.last) {
      return (
        <Box flexDirection="row">
          <Text dimColor wrap="truncate-end">{`cache · ${advise(view, 0, cfg).text}`}</Text>
        </Box>
      )
    }
    if (await read($, paneAtom)) return next(e)
    const last = view.last
    if (!last) return next(e)
    const left = await read($, tickAtom)
    const advice = advise(view, left, cfg)
    const wide = e.props.bodyColumns >= 90
    const timed = advice.state !== 'off' && advice.state !== 'uncached'
    // the figures never shrink or wrap; only the advice tail gives way on a narrow body
    return (
      <Box flexDirection="row" columnGap={1}>
        <Box flexDirection="row" columnGap={1} flexShrink={0}>
          <Text color={STATE_COLOR[advice.state]}>●</Text>
          <Text bold color="cyan">cache</Text>
          <Text color={STATE_COLOR[advice.state]}>{textBar(last.hit / 100, wide ? 10 : 6)}</Text>
          <Text bold>{`${last.hit}%`}</Text>
          {wide ? <Text color="green">{`read ${formatCount(last.read)}`}</Text> : <Text dimColor>{`prompt ${formatCount(last.prompt)}`}</Text>}
          {wide ? <Text color="yellow">{`wrote ${formatCount(last.write)}`}</Text> : null}
          {wide ? <Text color="blue">{`new ${formatCount(last.fresh)}`}</Text> : null}
          {timed ? <Text bold color={clockColor(left, view.ttl)}>{`⏱ ${countdownText(left, cfg)}`}</Text> : null}
        </Box>
        <Text dimColor wrap="truncate-end">{view.off ? advice.text : `${view.ttlLabel} · ${advice.text}`}</Text>
      </Box>
    )
  })
hooks/cache-countdown.tsx lines 522–606 · Pane
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    const view = await read($, viewAtom)
    const left = await read($, tickAtom)
    const { Box, Text, Button } = $.ui.resolve(e)
    // remote surfaces collapse runs of spaces; no-break spaces keep aligned text aligned
    const aligned = (text: string) => (e.surface === 'terminal' ? text : text.replace(/ /g, ' '))
    const width = Math.max(32, Math.min(e.props.bodyColumns || 64, 80))
    const close = <Button key="close" label="close" role="dismiss" onPress={() => void closePane($)} />
    if (!view) {
      return (
        <Box flexDirection="column">
          <Text bold color="cyan">PROMPT CACHE</Text>
          <Text dimColor>not read yet</Text>
          {close}
        </Box>
      )
    }
    const advice = advise(view, left, cfg)
    const last = view.last
    const ttlMs = view.ttl * 1000
    const lifeCells = Math.max(10, width - 24)
    const barCells = Math.max(10, width - 2)
    const parts = last ? splitCells([last.read, last.write, last.fresh], barCells) : []
    const colors = ['green', 'yellow', 'blue']
    const room = Math.max(1, (e.props.scroll?.bodyRows ?? 24) - 15)
    const rows = view.rows.slice(-room)
    const COLS = [6, 7, 9, 9, 9, 6]
    const cells = (key: string, values: string[], bold?: boolean) => (
      <Box key={key} flexDirection="row">
        {values.map((v, i) => (
          <Box key={`${key}:${i}`} width={COLS[i] ?? 8} justifyContent={i === 0 ? 'flex-start' : 'flex-end'}>
            <Text bold={bold}>{v}</Text>
          </Box>
        ))}
      </Box>
    )
    return (
      <Box flexDirection="column">
        <Box key="title" flexDirection="column">
          <Text bold color="cyan">PROMPT CACHE</Text>
          <Text dimColor wrap="wrap">{view.off ? `off · ${view.off}` : `${view.ttlLabel} lifetime · ${view.source}`}</Text>
        </Box>
        {isLive(view) ? (
          <Box key="life" flexDirection="row" columnGap={1} marginTop={1}>
            <Text color={clockColor(left, view.ttl)}>{left > 0 ? `⏱ ${countdownText(left, cfg)} left` : '⏱ expired'}</Text>
            <Text color={clockColor(left, view.ttl)}>{textBar(left / ttlMs, lifeCells)}</Text>
            <Text>{`${Math.round((100 * left) / ttlMs)}%`}</Text>
          </Box>
        ) : null}
        <Box key="advice" flexDirection="column" marginTop={isLive(view) ? 0 : 1}>
          <Text color={STATE_COLOR[advice.state]} wrap="wrap">{advice.text}</Text>
          <Text dimColor>{last ? `${last.model} · prompt ${formatCount(last.prompt)} tokens` : 'no request yet'}</Text>
        </Box>
        {last ? (
          <Box key="last" flexDirection="column" marginTop={1}>
            <Box flexDirection="row" justifyContent="space-between" width={barCells}>
              <Text bold>last request</Text>
              <Text>{`${last.hit}% hit`}</Text>
            </Box>
            <Box flexDirection="row">
              {parts.map((n, i) => (n > 0 ? <Box key={`seg:${i}`} width={n} height={1} backgroundColor={colors[i] ?? 'gray'} /> : null))}
            </Box>
            <Box flexDirection="row" columnGap={2}>
              <Text color="green">{`■ read ${formatCount(last.read)}`}</Text>
              <Text color="yellow">{`■ wrote ${formatCount(last.write)}`}</Text>
              <Text color="blue">{`■ new ${formatCount(last.fresh)}`}</Text>
            </Box>
          </Box>
        ) : null}
        {view.rows.length ? (
          <Box key="turns" flexDirection="column" marginTop={1}>
            {cells('head', ['turn', 'steps', 'read', 'wrote', 'new', 'hit'], true)}
            {rows.map(r =>
              cells(`turn:${r.label}`, [r.label, String(r.steps), formatCount(r.read), formatCount(r.write), formatCount(r.fresh), `${r.hit}%`]),
            )}
            {cells('all', [view.total.label, String(view.total.steps), formatCount(view.total.read), formatCount(view.total.write), formatCount(view.total.fresh), `${view.total.hit}%`], true)}
          </Box>
        ) : null}
        <Box key="foot" flexDirection="row" columnGap={2} marginTop={1}>
          {close}
          <Text dimColor>{aligned('Esc or /cache stop closes')}</Text>
        </Box>
      </Box>
    )
  })
Licence text (MIT)
MIT License

Copyright (c) 2026 Jared (github.com/jmac122)

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), Add a slash command

What its code calls

env varsremembers

What its code shows

Read from the source at commit 3387a016f95a 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 readEvery module hooks/hooks.json names was read.hooks/cache-countdown.tsx
ParsesEvery file parses as TypeScript or JavaScript.3 files parsed
All its code is in the modEvery import is a file of the mod or the engine's own module; no packages, no require.all its code is in the mod
ReadableNo 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 openNetwork 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 drawsThe 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 lineWhether 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 WindowsWhether every program it starts through $.process exists on Windows (tail, date, open, osascript, /usr/… do not).runs no program a Windows PC lacks
NetworkWhether every fetch names its https host in the code.no network
ProgramsWhether 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 sendsWhether 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 sourceWhether the source holds what looks like an API key or a private key.no keys in the source
LicenceAn 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 hooksHooks 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 shipsMCP 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, agentsWhat 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 MCPWhether 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 modelCompletions it runs ($.model.complete, fork, classify), subagents it spawns, prompts it submits as you, and the tools, commands and agents it adds.adds command cache
Events it hooksBy 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 (cache) · shapes: turn.step · also: session.start, session.end, ui.close, ui.render (AbovePrompt, Pane) · timers: clock.after
Reads, by nameThe environment variables and files it names, and whether it reads the transcript, settings.json, the prompt box or the mouse selection.env: CLAUDE_CODE_PROMPT_CACHE_TTL, FORCE_PROMPT_CACHING_5M, ENABLE_PROMPT_CACHING_1H, DISABLE_PROMPT_CACHING, DISABLE_PROMPT_CACHING_HAIKU (+2); settings.json
Writes, by nameThe 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.settings (config.set)

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 jmac122/cache-countdown
/plugin install cache-countdown@cache-countdown
/reload-plugins

This installs the marketplace's latest commit, which may not be the one read here (3387a016f95a). 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/jmac122/cache-countdown
git -C cache-countdown checkout 3387a016f95a74185272f0656b27623d4770000b
claude plugin validate cache-countdown
claude --plugin-dir cache-countdown

The 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 "jmac122-cache-countdown" with its code and make me one like it

Search them from Claude: the MCP connector

Similar mods

Badge for your README

If this is your mod, paste this into your README. It links to this page.

README.md
[![ModsCode](https://modscode.com/badge/jmac122-cache-countdown.svg)](https://modscode.com/claude-mods/mods/jmac122-cache-countdown/)