modscode EN

modscode / 図鑑 / cache-keeper

cache-keeper

Context, quota and prompt-cache meters above the prompt; while the session is idle on a 1-hour cache, keeps it alive and compacts before it lapses, holding off system sleep meanwhile (Linux, Windows, macOS).

確かめやすいコードターミナル+デスクトップペインバンドステータスラインBoxButtonText

何をするか

  • プロンプトの上の帯・欄を描く
  • prompt.submit・session.compact・session.end・session.measure ほか 4 個にフックする
  • ターンをまたいで自分の状態を持つ
  • プロセスを起こす

良いところ

  • ネットワークに出ない
  • TypeScript で書かれている
  • デスクトップ専用の分岐がある
  • エラーを扱う

作り始めるためのコード

2 種類あります。上のデザインから modscode が書いた雛形と、その Mod 自身のコードのうち描いている部分です。

雛形(register.tsx)

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

// Drawn like cache-keeper by oioi555 (pane, band, status), as modscode read it from the mod's code:
// https://modscode.com/gallery/oioi555-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 } = $.ui.resolve(e)
    const pct = '…'
    const fmtTokens = '…'
    const limitLabel = '…'
    const percentUsed = '…'
    const resetsIn = '…'
    const modelLabel = '…'
    const icon = '…'
    const hitRatio = '…'
    const fmtClock = '…'
    const ttl = '…'
    const label = '…'
    const effort = '…'
    return (
      <Box flexDirection="column">
        <Box flexDirection="column">
          <Box flexDirection="row" columnGap={1}>
            <Box flexDirection="row" flexGrow={1} columnGap={1}>
              <Text bold color="cyan">
                ctx
              </Text>
              <Box flexDirection="row" columnGap={1}>
                <Text>
                  ████████░░░░░░░░
                </Text>
                <Text bold>
                  {`${pct}%`}
                </Text>
                <Text dimColor>
                  {`${fmtTokens}/${fmtTokens}`}
                </Text>
              </Box>
              <Text dimColor>
                {`▸auto ${fmtTokens}`}
              </Text>
              <Text>
                {`· ${limitLabel} ${percentUsed}% ↻${resetsIn}`}
              </Text>
              <Text>
                {`· ${limitLabel} ${percentUsed}% ↻${resetsIn}`}
              </Text>
              <Text>
                {`· ${limitLabel} ${percentUsed}% ↻${resetsIn}`}
              </Text>
            </Box>
            <Box flexShrink={0}>
              <Text bold color="magenta">
                {modelLabel}
              </Text>
            </Box>
          </Box>
          <Box flexDirection="row" columnGap={1}>
            <Box flexDirection="row" flexGrow={1} flexShrink={1} columnGap={1}>
              <Text bold>
                {icon}
              </Text>
              <Text bold color="cyan">
                cache
              </Text>
              <Box flexDirection="row" columnGap={1}>
                <Text bold>
                  {`${hitRatio}%`}
                </Text>
                <Text bold>
                  {`⏱ ${fmtClock}`}
                </Text>
              </Box>
              <Text dimColor>
                {ttl}
              </Text>
              <Text wrap="truncate-end">
                {`· ${label} · sleep held`}
              </Text>
            </Box>
            <Box flexShrink={0}>
              <Text bold color="yellow">
                {effort}
              </Text>
            </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 ttl = '…'
    const ttlSource = '…'
    const bar = '…'
    const hitRatio = '…'
    const fmtTokens = '…'
    const sp = '…'
    const percentUsed = '…'
    const resetsIn = '…'
    const sp2 = '…'
    const sp3 = '…'
    const sp4 = '…'
    const value = '…'
    const fmtClock = '…'
    const done = '…'
    const planned = '…'
    const platform = '…'
    const sp5 = '…'
    const sp6 = '…'
    const sp7 = '…'
    const sp8 = '…'
    const sp9 = '…'
    const hit = '…'
    const sp10 = '…'
    const sp11 = '…'
    const sp12 = '…'
    const sp13 = '…'
    const sp14 = '…'
    const sp15 = '…'
    const sp16 = '…'
    const sp17 = '…'
    return (
      <Box flexDirection="column">
        <Text bold color="cyan">
          {`CACHE KEEPER · ${ttl} lifetime (${ttlSource})`}
        </Text>
        <Box flexDirection="column" marginTop={1}>
          <Text bold>
            cache
          </Text>
          <Box flexDirection="column">
            <Box flexDirection="row" columnGap={1}>
              <Box width={10} flexShrink={0}>
                <Text dimColor>
                  left
                </Text>
              </Box>
              <Text color="red">
                {`${bar} expired`}
              </Text>
            </Box>
            <Box flexDirection="row" columnGap={1}>
              <Box width={10} flexShrink={0}>
                <Text dimColor>
                  last req
                </Text>
              </Box>
              <Text>
                {`${hitRatio}% hit · read ${fmtTokens} · wrote ${fmtTokens} · new ${fmtTokens} · ${fmtTokens} prompt`}
              </Text>
            </Box>
          </Box>
        </Box>
        <Box flexDirection="column" marginTop={1}>
          <Text bold>
            context
          </Text>
          <Box flexDirection="row" columnGap={1}>
            <Box width={10} flexShrink={0}>
              <Text dimColor>
                window
              </Text>
            </Box>
            <Text>
              {`${bar} ${fmtTokens}/${fmtTokens}`}
            </Text>
          </Box>
          <Box flexDirection="row" columnGap={1}>
            <Box width={10} flexShrink={0}>
              <Text dimColor>
                auto
              </Text>
            </Box>
            <Text>
              {`Claude Code compacts at ${fmtTokens} (${fmtTokens} left)`}
            </Text>
          </Box>
          <Box flexDirection="row" columnGap={1}>
            <Box width={10} flexShrink={0}>
              <Text dimColor>
                {sp}
              </Text>
            </Box>
            <Text>
              {`${bar} ${percentUsed}% · resets in ${resetsIn}`}
            </Text>
          </Box>
          <Box flexDirection="row" columnGap={1}>
            <Box width={10} flexShrink={0}>
              <Text dimColor>
                {sp2}
              </Text>
            </Box>
            <Text>
              {`${bar} ${percentUsed}% · resets in ${resetsIn}`}
            </Text>
          </Box>
          <Box flexDirection="row" columnGap={1}>
            <Box width={10} flexShrink={0}>
              <Text dimColor>
                {sp3}
              </Text>
            </Box>
            <Text>
              {`${bar} ${percentUsed}% · resets in ${resetsIn}`}
            </Text>
          </Box>
        </Box>
        <Box flexDirection="column" marginTop={1}>
          <Text bold>
            keeper
          </Text>
          <Box flexDirection="row" columnGap={1}>
            <Box width={10} flexShrink={0}>
              <Text dimColor>
                state
              </Text>
            </Box>
            <Text>
              {sp4}
            </Text>
          </Box>
          <Box flexDirection="row" columnGap={1}>
            <Box width={10} flexShrink={0}>
              <Text dimColor>
                next
              </Text>
            </Box>
            <Text>
              {`${value} in ${fmtClock}`}
            </Text>
          </Box>
          <Box flexDirection="row" columnGap={1}>
            <Box width={10} flexShrink={0}>
              <Text dimColor>
                compact
              </Text>
            </Box>
            <Text>
              {`in ${fmtClock}`}
            </Text>
          </Box>
          <Box flexDirection="row" columnGap={1}>
            <Box width={10} flexShrink={0}>
              <Text dimColor>
                keep-alive
              </Text>
            </Box>
            <Text>
              {`${done}/${planned} this idle · last read ${fmtTokens}, wrote ${fmtTokens}`}
            </Text>
          </Box>
          <Box flexDirection="row" columnGap={1}>
            <Box width={10} flexShrink={0}>
              <Text dimColor>
                sleep
              </Text>
            </Box>
            <Text color="green">
              {`held (${platform})`}
            </Text>
          </Box>
          <Box flexDirection="row" columnGap={1}>
            <Box width={10} flexShrink={0}>
              <Text dimColor>
                error
              </Text>
            </Box>
            <Text color="red">
              {sp5}
            </Text>
          </Box>
          <Box flexDirection="row" columnGap={1} marginTop={1}>
            <Button label="keep-alive now" hotkey="k" />
            <Button label="compact now" hotkey="c" />
            <Button label="resume" hotkey="p" />
            <Button label="close" role="dismiss" />
          </Box>
        </Box>
        <Box flexDirection="column" marginTop={1}>
          <Box flexDirection="row" columnGap={1}>
            <Box width="4" flexShrink={0} justifyContent="flex-end">
              <Text color="cyan">
                turn
              </Text>
            </Box>
            <Box width="5" flexShrink={0} justifyContent="flex-end">
              <Text color="cyan">
                steps
              </Text>
            </Box>
            <Box width="7" flexShrink={0} justifyContent="flex-end">
              <Text color="green">
                read
              </Text>
            </Box>
            <Box width="7" flexShrink={0} justifyContent="flex-end">
              <Text color="yellow">
                wrote
              </Text>
            </Box>
            <Box width="6" flexShrink={0} justifyContent="flex-end">
              <Text color="cyan">
                new
              </Text>
            </Box>
            <Box width="5" flexShrink={0} justifyContent="flex-end">
              <Text color="magenta">
                hit
              </Text>
            </Box>
          </Box>
          <Text dimColor>
            no requests yet
          </Text>
          <Box flexDirection="row" columnGap={1}>
            <Box width="4" flexShrink={0} justifyContent="flex-end">
              <Text>
                ka
              </Text>
            </Box>
            <Box width="5" flexShrink={0} justifyContent="flex-end">
              <Text>
                {sp6}
              </Text>
            </Box>
            <Box width="7" flexShrink={0} justifyContent="flex-end">
              <Text color="green">
                {sp7}
              </Text>
            </Box>
            <Box width="7" flexShrink={0} justifyContent="flex-end">
              <Text color="yellow">
                {sp8}
              </Text>
            </Box>
            <Box width="6" flexShrink={0} justifyContent="flex-end">
              <Text color="cyan">
                {sp9}
              </Text>
            </Box>
            <Box width="5" flexShrink={0} justifyContent="flex-end">
              <Text>
                {`${hit}%`}
              </Text>
            </Box>
          </Box>
          <Box flexDirection="row" columnGap={1}>
            <Box width="4" flexShrink={0} justifyContent="flex-end">
              <Text>
                ka
              </Text>
            </Box>
            <Box width="5" flexShrink={0} justifyContent="flex-end">
              <Text>
                {sp10}
              </Text>
            </Box>
            <Box width="7" flexShrink={0} justifyContent="flex-end">
              <Text color="green">
                {sp11}
              </Text>
            </Box>
            <Box width="7" flexShrink={0} justifyContent="flex-end">
              <Text color="yellow">
                {sp12}
              </Text>
            </Box>
            <Box width="6" flexShrink={0} justifyContent="flex-end">
              <Text color="cyan">
                {sp13}
              </Text>
            </Box>
            <Box width="5" flexShrink={0} justifyContent="flex-end">
              <Text>
                {`${hit}%`}
              </Text>
            </Box>
          </Box>
          <Box flexDirection="row" columnGap={1}>
            <Box width="4" flexShrink={0} justifyContent="flex-end">
              <Text>
                ka
              </Text>
            </Box>
            <Box width="5" flexShrink={0} justifyContent="flex-end">
              <Text>
                {sp14}
              </Text>
            </Box>
            <Box width="7" flexShrink={0} justifyContent="flex-end">
              <Text color="green">
                {sp15}
              </Text>
            </Box>
            <Box width="7" flexShrink={0} justifyContent="flex-end">
              <Text color="yellow">
                {sp16}
              </Text>
            </Box>
            <Box width="6" flexShrink={0} justifyContent="flex-end">
              <Text color="cyan">
                {sp17}
              </Text>
            </Box>
            <Box width="5" flexShrink={0} justifyContent="flex-end">
              <Text>
                {`${hit}%`}
              </Text>
            </Box>
          </Box>
        </Box>
      </Box>
    )
  })
}

Mod 自身のコード

Mod のライセンス(MIT)に従って載せています。全文は下にあります。写すときは著作権表示を残してください。

plugins/cache-keeper/hooks/register.tsx 679〜766 行 · バンド
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    await ensureTicking($, rt)
    if (!showBand || e.props.hasSurvey) return next(e)
    const view = await read($, viewAtom)
    if (!view) return next(e)
    const { Box, Text } = $.ui.resolve(e)
    const columns = e.props.bodyColumns ?? e.viewport?.columns ?? 100
    const isWide = columns >= 100
    const now = view.now

    const c = view.context
    const pct = c?.tokens !== undefined ? (c.percent ?? Math.round((c.tokens / c.window) * 100)) : undefined
    const ctxTone = c ? contextTone(c.tokens, c.window, c.autoAt) : 'green'
    const ctxRow = (
      <Box key="ctx" flexDirection="row" columnGap={1}>
        <Box flexDirection="row" flexGrow={1} columnGap={1}>
          <Text bold color="cyan">ctx</Text>
          {c && pct !== undefined ? (
            <Box flexDirection="row" columnGap={1}>
              <Text color={ctxTone}>{bar(pct / 100, isWide ? 10 : 6)}</Text>
              <Text bold color={ctxTone}>{`${pct}%`}</Text>
              {isWide ? <Text dimColor>{`${fmtTokens(c.tokens ?? 0)}/${fmtTokens(c.window)}`}</Text> : null}
            </Box>
          ) : (
            <Text dimColor>{view.last?.kind === 'compact' && fmtShrink(view.last.before, view.last.after) ? `-- (compacted ${fmtShrink(view.last.before, view.last.after)})` : '--'}</Text>
          )}
          {c?.autoAt !== undefined ? <Text dimColor>{`▸auto ${fmtTokens(c.autoAt)}`}</Text> : c?.isAutoOn === false ? <Text dimColor>auto off</Text> : null}
          {showQuota
            ? view.limits.map(l => (
                <Text key={`q:${l.kind}`} color={percentTone(l.percentUsed)}>
                  {`· ${limitLabel(l.kind)} ${Math.round(l.percentUsed)}%${isWide && resetsIn(l.resetsAt, now) ? ` ↻${resetsIn(l.resetsAt, now)}` : ''}`}
                </Text>
              ))
            : null}
        </Box>
        {view.model ? (
          <Box flexShrink={0}>
            <Text bold color="magenta">{modelLabel(view.model)}</Text>
          </Box>
        ) : null}
      </Box>
    )

    const last = view.last
    const left = remainingMs(last, view.ttl, now)
    const cacheColor = left > 0 ? lifeTone(left, view.ttl) : 'red'
    const icon = !isCached(last) ? '○' : left > 0 ? '●' : '✖'
    const k = view.keeper
    const cacheRow = (
      <Box key="cache" flexDirection="row" columnGap={1}>
        <Box flexDirection="row" flexGrow={1} flexShrink={1} columnGap={1}>
          <Text bold color={isCached(last) ? cacheColor : undefined}>{icon}</Text>
          <Text bold color="cyan">cache</Text>
          {last && isCached(last) ? (
            <Box flexDirection="row" columnGap={1}>
              {isWide ? <Text bold>{`${Math.round(hitRatio(last) * 100)}%`}</Text> : null}
              <Text bold color={cacheColor}>{left > 0 ? `⏱ ${fmtClock(left)}` : 'expired'}</Text>
            </Box>
          ) : (
            <Text dimColor>--</Text>
          )}
          <Text dimColor>{view.ttl}</Text>
          <Text color={TONE[k.tone]} dimColor={k.tone === 'dim'} wrap="truncate-end">{`· ${k.label}${view.sleep.isActive ? ' · sleep held' : ''}`}</Text>
        </Box>
        {view.effort ? (
          <Box flexShrink={0}>
            <Text bold color={view.effort === 'xhigh' || view.effort === 'max' ? 'yellow' : undefined}>{view.effort}</Text>
          </Box>
        ) : null}
      </Box>
    )

    const mine = (
      <Box key="cache-keeper" flexDirection="column" width={columns}>
        {ctxRow}
        {cacheRow}
      </Box>
    )
    // Keep what the mods after this one draw in the band
    const rest = await next(e)
    if (!rest) return mine
    return (
      <Box flexDirection="column">
        {mine}
        {rest}
      </Box>
    )
  })
plugins/cache-keeper/hooks/register.tsx 770〜876 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
    const { Box, Text, Button } = $.ui.resolve(e)
    const view = await read($, viewAtom)
    // HTML collapses runs of spaces; a no-break space keeps the columns
    const sp = (t: string) => (e.surface === 'terminal' ? t : t.replace(/ /g, ' '))
    if (!view) return <Text dimColor>no data yet</Text>
    const width = Math.max(30, (e.props.bodyColumns ?? 60) - 1)
    const barW = Math.min(width - 24, 30)
    const now = view.now
    const last = view.last
    const left = remainingMs(last, view.ttl, now)
    const k = view.keeper
    const c = view.context
    const row = (key: string, label: string, value: string, color?: string) => (
      <Box key={key} flexDirection="row" columnGap={1}>
        <Box width={10} flexShrink={0}>
          <Text dimColor>{sp(label)}</Text>
        </Box>
        <Text color={color}>{sp(value)}</Text>
      </Box>
    )
    const cell = (key: string, w: number, text: string, color?: string) => (
      <Box key={key} width={w} flexShrink={0} justifyContent="flex-end">
        <Text color={color} dimColor={!color}>{sp(text)}</Text>
      </Box>
    )
    const rows = view.turns.slice(-Math.max(3, (e.viewport?.rows ?? 30) - 24))

    return (
      <Box flexDirection="column">
        <Text bold color="cyan">{sp(`CACHE KEEPER · ${view.ttl} lifetime (${view.ttlSource})`)}</Text>

        <Box key="cache" flexDirection="column" marginTop={1}>
          <Text bold>cache</Text>
          {last && isCached(last) ? (
            <Box flexDirection="column">
              {row('left', 'left', `${bar(left / TTL_MS[view.ttl], barW)} ${left > 0 ? fmtClock(left) : 'expired'}`, left > 0 ? lifeTone(left, view.ttl) : 'red')}
              {row('last', 'last req', `${Math.round(hitRatio(last) * 100)}% hit · read ${fmtTokens(last.read)} · wrote ${fmtTokens(last.write)} · new ${fmtTokens(last.fresh)} · ${fmtTokens(promptTokens(last))} prompt`)}
            </Box>
          ) : (
            <Text dimColor>{last?.kind === 'compact' ? 'compacted: the next request writes a new cache' : 'no cached request yet'}</Text>
          )}
        </Box>

        <Box key="context" flexDirection="column" marginTop={1}>
          <Text bold>context</Text>
          {c && c.tokens !== undefined
            ? row('ctx', 'window', `${bar(c.tokens / c.window, barW)} ${fmtTokens(c.tokens)}/${fmtTokens(c.window)}`, contextTone(c.tokens, c.window, c.autoAt))
            : row('ctx', 'window', c ? `-- of ${fmtTokens(c.window)} (until the next response)` : '--')}
          {row('auto', 'auto', c?.autoAt !== undefined ? `Claude Code compacts at ${fmtTokens(c.autoAt)}${c.tokens !== undefined ? ` (${fmtTokens(Math.max(0, c.autoAt - c.tokens))} left)` : ''}` : c?.isAutoOn === false ? 'off' : 'unknown')}
          {view.limits.map(l =>
            row(`q:${l.kind}`, limitLabel(l.kind), `${bar(l.percentUsed / 100, barW)} ${Math.round(l.percentUsed)}%${resetsIn(l.resetsAt, now) ? ` · resets in ${resetsIn(l.resetsAt, now)}` : ''}`, percentTone(l.percentUsed)),
          )}
        </Box>

        <Box key="keeper" flexDirection="column" marginTop={1}>
          <Text bold>keeper</Text>
          {row('state', 'state', k.label, TONE[k.tone])}
          {k.dueAt !== undefined ? row('next', 'next', `${k.next} in ${fmtClock(k.dueAt - now)}`) : null}
          {k.compactAt !== undefined ? row('compact', 'compact', `in ${fmtClock(k.compactAt - now)}`) : null}
          {row('done', 'keep-alive', `${k.done}/${k.planned} this idle${view.lastKeepAlive ? ` · last read ${fmtTokens(view.lastKeepAlive.read)}, wrote ${fmtTokens(view.lastKeepAlive.write)}` : ''}`)}
          {row('sleep', 'sleep', view.sleep.isActive ? `held (${view.sleep.platform})` : view.sleep.error ? `not held: ${view.sleep.error}` : `not held (${view.sleep.platform})`, view.sleep.isActive ? 'green' : undefined)}
          {rt.keeperError ? row('error', 'error', rt.keeperError, 'red') : null}
          <Box key="buttons" flexDirection="row" columnGap={1} marginTop={1}>
            <Button key="now" label="keep-alive now" hotkey="k" onPress={() => void keepAlive($, rt, false)} />
            <Button key="compact" label="compact now" hotkey="c" onPress={() => laterCompact($, rt)} />
            <Button key="pause" label={k.isPaused ? 'resume' : 'pause'} hotkey="p" onPress={() => togglePause($, rt)} />
            <Button key="close" label="close" role="dismiss" onPress={() => void $.ui.close({ id: PANE })} />
          </Box>
        </Box>

        <Box key="table" flexDirection="column" marginTop={1}>
          <Box key="head" flexDirection="row" columnGap={1}>
            {cell('h:n', 4, 'turn', 'cyan')}
            {cell('h:steps', 5, 'steps', 'cyan')}
            {cell('h:read', 7, 'read', 'green')}
            {cell('h:wrote', 7, 'wrote', 'yellow')}
            {cell('h:new', 6, 'new', 'cyan')}
            {cell('h:hit', 5, 'hit', 'magenta')}
          </Box>
          {rows.length === 0 ? <Text dimColor>no requests yet</Text> : null}
          {rows.map((t, i) => {
            if (t.kind === 'compact') {
              return (
                <Box key={`t:${t.turnId}`} flexDirection="row" columnGap={1}>
                  {cell(`n:${t.turnId}`, 4, 'cmp')}
                  <Text dimColor>{sp(`compacted ${fmtShrink(t.before, t.after)}`.trim())}</Text>
                </Box>
              )
            }
            const total = t.read + t.write + t.fresh
            const hit = total > 0 ? Math.round((t.read / total) * 100) : 0
            return (
              <Box key={`t:${t.turnId}`} flexDirection="row" columnGap={1}>
                {cell(`n:${t.turnId}`, 4, t.kind === 'keep-alive' ? 'ka' : String(view.turns.length - rows.length + i + 1))}
                {cell(`s:${t.turnId}`, 5, String(t.steps))}
                {cell(`r:${t.turnId}`, 7, fmtTokens(t.read), 'green')}
                {cell(`w:${t.turnId}`, 7, fmtTokens(t.write), 'yellow')}
                {cell(`f:${t.turnId}`, 6, fmtTokens(t.fresh), 'cyan')}
                {cell(`h:${t.turnId}`, 5, `${hit}%`, percentTone(100 - hit))}
              </Box>
            )
          })}
        </Box>
      </Box>
    )
  })
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 oioi555

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.

コードが呼ぶもの

プログラム起動環境変数Claude を動かす保存

コードから読み取ったデザイン

読み取ったコミットのソースから描いたもので、動かした結果ではありません。一覧は 3 回描き、条件はデスクトップアプリで描く最初の分岐を取り、動かしたときにだけ決まる値は仮の例(点線の下線)にするか省きます。色と書体はこのサイトのものです。

コードから読めること

2026-10-06 に読んだコミット 4c285053da49 のソースから。最初のまとまりが載せる条件で、残りは自分で判断するための材料です。後のコミットは、次に読むまで見ていません。

載せる条件: 確かめやすいコード
入口を読んだhooks/hooks.json が名指すモジュールをすべて読んだ。plugins/cache-keeper/hooks/register.tsx
解析できるすべてのファイルが TypeScript か JavaScript として解析できる。3 ファイルを解析
コードが Mod の中で完結import は Mod 自身のファイルかエンジンのモジュールだけ。パッケージも require もない。コードはすべて Mod の中
読める圧縮した行・eval・new Function・計算した道の import()・符号化した塊がない。圧縮・eval・符号化した塊なし
呼び出しが見える通信とプログラム起動はその場で $.http.fetch・$.process.run と書き、他へ渡さない。外への呼び出しはすべてその場の $ で
入れる前に自分で判断する材料
描く場所コードから読んだ、描く先。ターミナル・デスクトップアプリ・両方・何も描かない(フックだけ: 見張りやプロンプトの書き換え)のどれか。出すだけで、外す理由にはしない。ターミナルとデスクトップアプリに同じように描く
入れる手順リポジトリ自身の .claude-plugin/marketplace.json にこの Mod が載っていて、ページに書いた手順でそのマーケットプレイスから入れられるか。リポジトリの .claude-plugin/marketplace.json に載っており、そこから入れられる
Windows のプログラム$.process で起動するプログラムが Windows にあるか(tail・date・open・osascript・/usr/… などは無い)。Windows にないプログラムを使わない
通信fetch の送り先(https のホスト)がコードに書いてあるか。通信なし
プログラム起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。plugins/cache-keeper/hooks/register.tsx:277 実行時に決まるプログラム
読んで送るファイルや環境変数を読み、かつ通信するか。通信しない
ソースの鍵ソースに API キーや秘密鍵らしきものがあるか。ソースに鍵なし
ライセンスオープンなライセンス(MIT・Apache-2.0・BSD・ISC・Unlicense・0BSD・CC0)で全文があれば、modscode にコードを載せる。違えばリンクだけ。MIT

コードの文面を読んだだけで、安全の審査ではありません。動かしてはおらず、起動するプログラムの中で何が起きるかも見えません。入れる前の確認はあなたの役目です。 載せる条件

入れる

入れる前に、必ず自分で確かめてください。Mod はサンドボックスなしで、あなたの権限で動きます。modscode はこのコードの安全を保証しません。下のコードを読み(またはフォルダーで claude plugin validate .)、触るものを見て、読んだコミットを入れてください。

リポジトリがそのままマーケットプレイスです。このマーケットプレイスを足し(ターミナルでは次のコマンド、デスクトップアプリではプラグインの設定)、そこから Mod を入れます。

/plugin marketplace add oioi555/claude-code-mods
/plugin install cache-keeper@oioi555

入るのはマーケットプレイスの最新のコミットで、ここで読んだもの(4c285053da49)と違うことがあります。入れる前に見比べてください。

Claude に聞く

modscode のコネクタを入れると、Claude がこのデザイン・コードが触るもの・コードを読んで、それをもとに作れます。たとえば:

modscode のデザイン「oioi555-cache-keeper」をコードごと読んで、同じようなペインを作って

Claude から探す: MCP コネクタ

似たデザイン