modscode EN

modscode / 図鑑 / deck

deck

A cockpit for Claude Code: plan bars and subagent strips, context, usage limits with reset countdowns and burn rates, spend, the model route and a pet. Six bar styles, three collapsed looks. CLI and Desktop.

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

何をするか

  • 欄・プロンプトの上の帯を描く
  • /deck を足す
  • ツールの呼び出しを見張る
  • agent.spawn・classic.Stop・classic.SubagentStop・classic.TaskCompleted ほか 10 個にフックする
  • ターンをまたいで自分の状態を持つ

良いところ

  • プロセスを起こさない
  • デスクトップ専用の分岐がある
  • エラーを扱う
  • ファイルを書かない

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like deck by nvr0x5 (pane, band), as modscode read it from the mod's code:
// https://modscode.com/gallery/nvr0x5-deck/
// 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 pane: open it with $.ui.open({ id: 'my-pane', title: "Deck style" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Button, Svg, Text } = $.ui.resolve(e)
    const names = '…'
    const i = '…'
    const pw = '…'
    const desktopTrack = '…'
    const map = '…'
    return (
      <Box flexDirection="column" gap={1}>
        <Box flexDirection="row" columnGap={2} alignItems="center">
          <Box width={14} flexShrink={0}>
            <Button label={`${names}`} plain hotkey={`${i}`} />
          </Box>
          <Svg alt={`${names} style`} height={22} source={`<svg xmlns="http://www.w3.org/2000/svg" width="${pw}" height="22">${desktopTrack}</svg>`} />
          <Text color="#5DCAA5">
            ← now
          </Text>
        </Box>
        <Box flexDirection="row" columnGap={2} alignItems="center">
          <Box width={14} flexShrink={0}>
            <Button label={`${names}`} plain hotkey={`${i}`} />
          </Box>
          <Svg alt={`${names} style`} height={22} source={`<svg xmlns="http://www.w3.org/2000/svg" width="${pw}" height="22">${desktopTrack}</svg>`} />
          <Text color="#5DCAA5">
            ← now
          </Text>
        </Box>
        <Box flexDirection="row" columnGap={2} alignItems="center">
          <Box width={14} flexShrink={0}>
            <Button label={`${names}`} plain hotkey={`${i}`} />
          </Box>
          <Svg alt={`${names} style`} height={22} source={`<svg xmlns="http://www.w3.org/2000/svg" width="${pw}" height="22">${desktopTrack}</svg>`} />
          <Text color="#5DCAA5">
            ← now
          </Text>
        </Box>
        <Text color="#77756f">
          {`Press ${map} to choose · Esc to close`}
        </Text>
      </Box>
    )
  })

  // the band above the prompt; what else goes there is drawn under it
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    const { Box, Button, Text, Svg } = $.ui.resolve(e)
    const length = '…'
    const extras = '…'
    const title = '…'
    const source = '…'
    const alt = '…'
    const title2 = '…'
    const title3 = '…'
    return (
      <Box flexDirection="column" gap={1}>
        <Box flexDirection="row" columnGap={1}>
          <Button label="deck ▾" plain hotkey="0" dimColor />
          <Text color="#77756f">
            {`· ${length} row`}
          </Text>
          <Box flexGrow={1} />
          <Box flexShrink={0}>
            <Text color="#9a9893">
              {extras}
            </Text>
          </Box>
        </Box>
        <Box flexDirection="row" alignItems="flex-start" gap={1}>
          <Text>
            ⇄
          </Text>
          <Text wrap="truncate">
            {title}
          </Text>
          <Box flexGrow={1} />
          <Svg source={`${source}`} alt={`${alt}`} />
          <Button label="✕" plain dimColor />
        </Box>
        <Box flexDirection="row" alignItems="flex-start" gap={1}>
          <Text>
            ⇄
          </Text>
          <Text wrap="truncate">
            {title2}
          </Text>
          <Box flexGrow={1} />
          <Svg source={`${source}`} alt={`${alt}`} />
          <Button label="✕" plain dimColor />
        </Box>
        <Box flexDirection="row" alignItems="flex-start" gap={1}>
          <Text>
            ⇄
          </Text>
          <Text wrap="truncate">
            {title3}
          </Text>
          <Box flexGrow={1} />
          <Svg source={`${source}`} alt={`${alt}`} />
          <Button label="✕" plain dimColor />
        </Box>
        {await next(e)}
      </Box>
    )
  })
}

Mod 自身のコード

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

hooks/register.js 1469〜1525 行 · ペイン
  on('ui.render', { component: 'Pane' }, async ($, e, next) => {
    if (e.requestId !== 'deck-style') return next(e)
    const { Box, Text, Button, Svg } = $.ui.resolve(e)
    const desktop = e.surface === 'desktop'
    const nowMs = Date.now()
    const list = desktop ? DESKTOP_STYLES : TERMINAL_STYLES
    const names = desktop ? DESKTOP_STYLE_NAMES : TERMINAL_STYLE_NAMES
    const current = desktop ? prefs.style.desktop : prefs.style.terminal
    const row = collectRows(nowMs).find((r) => r.kind === 'bar') ?? sampleRow()
    const cols = Math.max(40, e.props.bodyColumns ?? 80)
    const pw = Math.max(200, Math.min(420, cols * 8 - 160))
    const lines = list.map((name, i) => {
      const preview = desktop
        ? Svg({
            alt: names[name] + ' style',
            width: pw,
            height: TRACK_H,
            
            source: `<svg xmlns="http://www.w3.org/2000/svg" width="${pw}" height="${TRACK_H}">${desktopTrack(name, { ...row, id: 'pick-' + name }, pw, nowMs, new Map())}</svg>`,
          })
        : Box({ flexDirection: 'row', children: runs(Text, terminalBar(name, { ...row, id: 'pick-' + name }, Math.max(24, Math.min(48, cols - 26)), frame)) })
      return Box({
        key: 'style-row-' + name,
        flexDirection: 'row',
        columnGap: 2,
        alignItems: 'center',
        children: [
          Box({
            width: 14,
            flexShrink: 0,
            children: [
              Button({
                key: 'style-' + name,
                label: names[name],
                plain: true,
                hotkey: String(i + 1),
                onPress: async (ev) => {
                  const surface = ev?.surface ?? e.surface
                  if (surface === 'desktop') prefs.style.desktop = name
                  else prefs.style.terminal = name
                  $.ui.invalidate('ui.render')
                  await $.store.set('prefs', prefs)
                },
              }),
            ],
          }),
          preview,
          Text({ color: name === current ? STYLE.ok.fill : DIM, children: [name === current ? '← now' : ' '] }),
        ],
      })
    })
    return Box({
      flexDirection: 'column',
      gap: desktop ? 1 : 0,
      children: [...lines, Text({ color: DIM, children: ['Press ' + list.map((_, i) => i + 1).join('/') + ' to choose · Esc to close'] })],
    })
  })
hooks/register.js 1527〜1686 行 · バンド
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    if (e.props.hasSurvey) return next(e)
    const { Box, Text, Button, Svg, Image } = $.ui.resolve(e)
    const desktop = e.surface === 'desktop'
    if (e.surface === 'terminal') sawTerminal = true
    const nowMs = Date.now()
    const cols = Math.max(40, e.props.bodyColumns ?? e.viewport?.columns ?? 100)
    const rows = collectRows(nowMs)
    const extras = []
    if (prefs.show.clock) extras.push((desktop ? '◷ ' : '') + clockText())
    const wt = prefs.show.weather ? weatherText(desktop) : ''
    if (wt) extras.push(wt)
    if (!rows.length && !extras.length && !prefs.show.pet) return next(e)

    // the pet's lane
    const lane = []
    if (prefs.show.pet) {
      if (desktop && Svg) {
        const W = Math.max(320, cols * 8)
        lane.push(Svg({ source: petLaneSvg(pet, nowMs, W, 54), alt: 'Claude pet, ' + pet.act, width: W, height: 54 }))
      } else if (!desktop && Image) {
        // leave a margin: a row as wide as the band gets cut and marked with [-]
        const room = Math.max(0, cols - PET_COLS - 4)
        const x = Math.round(petX(pet, nowMs) * room)
        const px = petFrame(pet.act, nowMs - pet.start, pet.dir)
        lane.push(
          Box({
            flexDirection: 'row',
            height: PET_ROWS,
            overflow: 'hidden',
            children: [
              Box({ width: x, flexShrink: 0, children: [] }),
              Image({ key: 'pet', source: { rgba: toBase64(px), width: PET_RASTER.width, height: PET_RASTER.height }, columns: PET_COLS, rows: PET_ROWS, alt: ' ' }),
            ],
          }),
        )
      }
    }

    const toggle = Button({
      key: 'deck-toggle',
      label: isOpening() ? 'deck ▾' : 'deck ▸',
      plain: true,
      hotkey: '0',
      dimColor: true,
      onPress: () => setOpen($, !isOpening()),
    })
    const extrasText = Box({ flexShrink: 0, children: [Text({ color: MUTED, children: [extras.join('  ·  ')] })] })
    const spacer = Box({ flexGrow: 1, children: [] })

    // ----- collapsed, rings: a ring per limit, its reset, and spend -----
    if ((!prefs.open || !rows.length) && prefs.collapsed === 'rings') {
      const items = []
      const ask = rows.find((r) => r.state === 'needs_input')
      if (ask) items.push(Text({ color: STYLE.ask.fill, children: ['? ' + trunc(ask.title, 24) + ' needs you'] }))
      for (const row of rows.filter((r) => r.limit)) {
        const st = STYLE[row.style]
        const tag = row.kindKey === 'five_hour' ? '5h' : row.kindKey === 'seven_day' ? '7d' : row.title
        const ring = desktop
          ? Svg({ alt: tag + ' ' + Math.round(row.pct) + '% used', width: 22, height: 22, source: ringSvg(row.pct, st.desk, row.kindKey === 'seven_day' ? 'week' : 'clock') })
          : Text({ color: st.fill, children: ['○◔◑◕●'[Math.min(4, Math.round(row.pct / 25))]] })
        items.push(
          Box({
            flexDirection: 'row',
            flexShrink: 0,
            columnGap: 1,
            alignItems: 'center',
            children: [ring, Text({ color: TEXT, bold: true, wrap: 'truncate', children: [Math.round(row.pct) + '%'] }), Text({ color: MUTED, wrap: 'truncate', children: [tag + (row.resets ? ' · resets ' + row.resets : '')] })],
          }),
        )
      }
      if (prefs.cost) {
        items.push(
          Box({
            flexDirection: 'row',
            flexShrink: 0,
            columnGap: 1,
            alignItems: 'center',
            children: [
              desktop ? Svg({ alt: 'spend', width: 22, height: 22, source: ringSvg(100, STYLE.done.desk, 'usd') }) : Text({ color: STYLE.done.fill, children: ['$'] }),
              Text({ color: STYLE.done.fill, bold: true, wrap: 'truncate', children: [fmtUsd(spend.dayUsd)] }),
              Text({ color: MUTED, wrap: 'truncate', children: ['today · ' + fmtUsd(spend.monthUsd) + ' this month'] }),
            ],
          }),
        )
      }
      const busy = rows.find((r) => (r.kind === 'bar' || r.kind === 'activity') && r.animating && r.state !== 'needs_input')
      if (busy) items.push(Box({ flexShrink: 1, children: [Text({ color: MUTED, wrap: 'truncate', children: [STYLE[busy.style].glyph + ' ' + trunc(busy.short, 22)] })] }))
      const line = Box({
        flexDirection: 'row',
        columnGap: 2,
        alignItems: 'center',
        children: [
          ...(rows.length ? [toggle] : []),
          Box({ flexDirection: 'row', flexShrink: 1, overflow: 'hidden', columnGap: desktop ? 4 : 3, alignItems: 'center', children: items }),
          spacer,
          extrasText,
        ],
      })
      return Box({ flexDirection: 'column', children: [...lane, line] })
    }

    // ----- collapsed, text: one plain status line, clock and weather at its end -----
    if ((!prefs.open || !rows.length) && prefs.collapsed === 'text') {
      const parts = []
      for (const row of collapsedOrder(rows)) {
        const st = STYLE[row.style]
        if (parts.length) parts.push(Text({ children: ['  '] }))
        if (row.kind === 'route') {
          parts.push(Text({ color: desktop ? STYLE.run.desk : STYLE.run.fill, children: ['⇄ '] }))
          parts.push(Text({ color: MUTED, children: [row.to + (row.effort ? ' · ' + row.effort : '')] }))
          continue
        }
        parts.push(Text({ color: desktop ? st.desk : st.fill, children: [st.glyph + ' '] }))
        parts.push(Text({ color: row.state === 'needs_input' ? st.fill : MUTED, children: [row.short] }))
      }
      if (extras.length) parts.push(Text({ color: MUTED, children: [(parts.length ? '  ' : '') + [...extras].reverse().join('  ')] }))
      const line = Box({
        flexDirection: 'row',
        columnGap: 1,
        children: [...(rows.length ? [toggle] : []), Box({ flexDirection: 'row', flexShrink: 1, children: [Text({ wrap: 'truncate', children: parts })] })],
      })
      return Box({ flexDirection: 'column', children: [...lane, line] })
    }

    // ----- collapsed, chips: one line of chips, limits first -----
    if (!prefs.open || !rows.length) {
      const chips = []
      // the terminal counts columns; the desktop counts pixels (about 8 per column, ~7.5 per character)
      let budget = desktop ? cols * 8 - 140 - extras.join('  ·  ').length * 7.5 : cols - 10 - extras.join('  ·  ').length
      let hidden = 0
      for (const row of collapsedOrder(rows)) {
        const st = STYLE[row.style]
        const w = desktop ? row.short.length * 8.5 + 76 : row.short.length + 10
        if (w > budget) {
          hidden++
          continue
        }
        budget -= w
        if (chips.length) chips.push(Text({ color: TRACK, children: [' │ '] }))
        if (row.kind === 'route') {
          chips.push(Text({ color: desktop ? STYLE.run.desk : STYLE.run.fill, children: [row.short + ' '] }))
          continue
        }
        chips.push(Text({ color: desktop ? st.desk : st.fill, children: [st.glyph + ' '] }))
        const chipText = { color: row.state === 'needs_input' ? st.fill : row.limit ? TEXT : '#c9c7c1', children: [row.short + ' '] }
        if (row.limit) chipText.bold = true
        chips.push(Text(chipText))
        chips.push(
          desktop
            ? Svg({
                alt: row.title + ' ' + Math.round(row.pct) + '%',
                width: 36,
                height: 8,
                source: `<svg xmlns="http://www.w3.org/2000/svg" width="36" height="8"><rect width="36" height="8" rx="4" fill="#808080" fill-opacity=".2"/><rect width="${Math.max((36 * row.pct) / 100, row.pct > 0 ? 4 : 0)}" height="8" rx="4" fill="${st.desk}"/></svg>`,
              })
            : Box({ flexDirection: 'row', children: runs(Text, terminalMini(prefs.style.terminal, row, 5)) }),
        )
      }
      if (hidden) chips.push(Text({ color: DIM, children: ['  +' + hidden] }))
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 nvr0x5

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 に読んだコミット 497f43ab7735 のソースから。最初のまとまりが載せる条件で、残りは自分で判断するための材料です。後のコミットは、次に読むまで見ていません。

載せる条件: 確かめやすいコード
入口を読んだhooks/hooks.json が名指すモジュールをすべて読んだ。hooks/register.js
解析できるすべてのファイルが TypeScript か JavaScript として解析できる。5 ファイルを解析
コードが 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 のホスト)がコードに書いてあるか。hooks/register.js:939 fetch('https://api.open-meteo.com/v1/forecast?latitude='); hooks/register.js:1210 fetch('https://geocoding-api.open-meteo.com/v1/search?co)
プログラム起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。プログラムを起動しない
読んで送るファイルや環境変数を読み、かつ通信するか。通信するが、ファイルも環境変数も読まない
ソースの鍵ソースに API キーや秘密鍵らしきものがあるか。ソースに鍵なし
ライセンスオープンなライセンス(MIT・Apache-2.0・BSD・ISC・Unlicense・0BSD・CC0)で全文があれば、modscode にコードを載せる。違えばリンクだけ。MIT

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

入れる

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

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

/plugin marketplace add nvr0x5/claude-deck
/plugin install deck@deck

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

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン