modscode EN

modscode / 図鑑 / workbench

workbench

Workbench for Claude Code: a live narration band above the prompt and a side pane with this turn's steps, working tree changes and turn history.

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

何をするか

  • プロンプトの上の帯・欄・ステータス行・トーストを描く
  • /workbench を足す
  • ツールの呼び出しを見張る(止めることがある)
  • prompt.submit・session.start・turn.complete・turn.stepにフックする
  • ターンをまたいで自分の状態を持つ

良いところ

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

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like workbench by fanbuz (pane, band, status, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/fanbuz-workbench/
// 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 text = '…'
    const bandSteps = '…'
    const elapsed = '…'
    const bandFailures = '…'
    const bandChanges = '…'
    const current = '…'
    const input = '…'
    const fmtTokens = '…'
    const output = '…'
    const fmtTokens2 = '…'
    const cacheRead = '…'
    const fmtTokens3 = '…'
    const cacheWrite = '…'
    const fmtTokens4 = '…'
    const narrator = '…'
    const fmtTokens5 = '…'
    const hit = '…'
    const hitRate = '…'
    const cost = '…'
    const costUsd = '…'
    const ctx = '…'
    const GLYPHS = '…'
    const legend = '…'
    const GLYPHS2 = '…'
    const legend2 = '…'
    const GLYPHS3 = '…'
    const legend3 = '…'
    return (
      <Box flexDirection="column" paddingX={1}>
        <Box flexDirection="row" gap={1}>
          <Box flexGrow={1} flexShrink={1} minWidth={0}>
            <Text wrap="wrap">
              {text}
            </Text>
          </Box>
          <Box flexShrink={0}>
            <Button plain dimColor label="Collapse" />
          </Box>
          <Box width={6} flexShrink={0} justifyContent="flex-end">
            <Text color="#D97757">
              ● ● ●
            </Text>
          </Box>
        </Box>
        <Text color="#B0AEA5" dimColor wrap="truncate-end">
          ────────
        </Text>
        <Box flexDirection="row" alignItems="center" gap={2}>
          <Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row" flexWrap="wrap" columnGap={2}>
            <Text>
              {`${bandSteps}`}
            </Text>
            <Text>
              <Text dimColor>
                {"Time "}
              </Text>
              <Text bold>
                {elapsed}
              </Text>
            </Text>
            <Box>
              <Button plain label={`${bandFailures}`} />
            </Box>
            <Box>
              <Button plain label={`${bandChanges}`} />
            </Box>
            <Text dimColor wrap="truncate-end">
              {"▸ "}
              {current}
            </Text>
          </Box>
          <Box flexShrink={0} flexDirection="row" alignItems="center" gap={1}>
            <Button label="▤ Workbench" />
            <Button label="⚙ Settings" />
          </Box>
        </Box>
        <Box flexDirection="row" flexWrap="wrap" columnGap={2}>
          <Box flexDirection="row" alignItems="center" gap={1}>
            {`${input}`}
            <Text bold color="#D97757">
              {fmtTokens}
            </Text>
          </Box>
          <Box flexDirection="row" alignItems="center" gap={1}>
            {`${output}`}
            <Text bold color="#6A9BCC">
              {fmtTokens2}
            </Text>
          </Box>
          <Box flexDirection="row" alignItems="center" gap={1}>
            {`${cacheRead}`}
            <Text bold color="#788C5D">
              {fmtTokens3}
            </Text>
          </Box>
          <Box flexDirection="row" alignItems="center" gap={1}>
            {`${cacheWrite}`}
            <Text bold color="#D4A27F">
              {fmtTokens4}
            </Text>
          </Box>
          <Box flexDirection="row" alignItems="center" gap={1}>
            {`${narrator}`}
            <Text bold color="#8F8A80">
              {fmtTokens5}
            </Text>
          </Box>
          <Text dimColor>
            │
          </Text>
          <Box flexDirection="row" alignItems="center" gap={1}>
            {`${hit}`}
            <Text bold color="#B5836B">
              {`${hitRate}%`}
            </Text>
          </Box>
          <Box flexDirection="row" alignItems="center" gap={1}>
            {`${cost}`}
            <Text bold color="#788C5D">
              {costUsd}
            </Text>
          </Box>
          <Box flexDirection="row" alignItems="center" gap={1}>
            <Text>
              ▤
            </Text>
            <Text>
              <Text>
                ▰▰▰▰▰▰▰▰
              </Text>
              <Text color="#8F8A80">
                ▱▱▱▱▱▱▱▱
              </Text>
              <Text bold>
                {" "}
                {ctx}
                %
              </Text>
            </Text>
          </Box>
          <Box>
            <Button plain label="ⓘ Hide" />
          </Box>
        </Box>
        <Box flexDirection="row" flexWrap="wrap" columnGap={2}>
          <Box flexDirection="row" alignItems="center" gap={1}>
            <Text>
              {GLYPHS}
            </Text>
            <Text dimColor>
              {legend}
            </Text>
          </Box>
          <Box flexDirection="row" alignItems="center" gap={1}>
            <Text>
              {GLYPHS2}
            </Text>
            <Text dimColor>
              {legend2}
            </Text>
          </Box>
          <Box flexDirection="row" alignItems="center" gap={1}>
            <Text>
              {GLYPHS3}
            </Text>
            <Text dimColor>
              {legend3}
            </Text>
          </Box>
        </Box>
        {await next(e)}
      </Box>
    )
  })

  // the pane: open it with $.ui.open({ id: 'my-pane', title: "Workbench settings" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button } = $.ui.resolve(e)
    const title = '…'
    const desc = '…'
    const choice = '…'
    const title2 = '…'
    const desc2 = '…'
    const title3 = '…'
    const desc3 = '…'
    return (
      <Box flexDirection="column" gap={1}>
        <Text bold>
          Workbench settings
        </Text>
        <Box flexDirection="column">
          <Text>
            <Text bold>
              {title}
            </Text>
            <Text dimColor>
              {"  Saving…"}
            </Text>
          </Text>
          <Text dimColor wrap="wrap">
            {desc}
          </Text>
          <Box flexDirection="row" gap={1} flexWrap="wrap">
            <Button label={`${choice}`} variant="primary" />
            <Button label={`${choice}`} variant="primary" />
            <Button label={`${choice}`} variant="primary" />
          </Box>
        </Box>
        <Box flexDirection="column">
          <Text>
            <Text bold>
              {title2}
            </Text>
            <Text dimColor>
              {"  Saving…"}
            </Text>
          </Text>
          <Text dimColor wrap="wrap">
            {desc2}
          </Text>
          <Box flexDirection="row" gap={1} flexWrap="wrap">
            <Button label={`${choice}`} variant="primary" />
            <Button label={`${choice}`} variant="primary" />
            <Button label={`${choice}`} variant="primary" />
          </Box>
        </Box>
        <Box flexDirection="column">
          <Text>
            <Text bold>
              {title3}
            </Text>
            <Text dimColor>
              {"  Saving…"}
            </Text>
          </Text>
          <Text dimColor wrap="wrap">
            {desc3}
          </Text>
          <Box flexDirection="row" gap={1} flexWrap="wrap">
            <Button label={`${choice}`} variant="primary" />
            <Button label={`${choice}`} variant="primary" />
            <Button label={`${choice}`} variant="primary" />
          </Box>
        </Box>
        <Text dimColor wrap="wrap">
          Saved to your Claude Code settings (pluginConfigs); the workbench reloads to apply.
        </Text>
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    const statusLine = '…'
    const compactSkipped = '…'
    await $.ui.status(`${statusLine}`)
    await $.ui.toast(`${compactSkipped}`)
    await $.ui.toast(`Copied`)
    return next(e)
  })
}

Mod 自身のコード

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

plugins/workbench/hooks/register.tsx 603〜762 行 · バンド
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
    const line = await read($, lineAtom)
    if (config.bandMode !== 'band' || e.props.hasSurvey || !line) return next(e)
    await read($, tickAtom) // 订阅慢速时钟,让用时走起来
    const isLegendOpen = await read($, legendAtom)
    const isExpanded = await read($, narrationExpandedAtom)
    const gitState = await read($, gitAtom)

    const resolved = $.ui.resolve(e)
    const { Box, Text, Button } = resolved
    // 终端的组件表里也有 Svg,但只会显示替代文字,所以按表面判断:终端走 Unicode 符号和纯文本
    const Svg = e.surface !== 'terminal' && 'Svg' in resolved ? resolved.Svg : null
    const now = Date.now()
    const isWorkingNow = line.phase === 'working'
    const elapsed = duration((line.endedAt ?? now) - line.startedAt)
    const color = isWorkingNow ? CLAY : line.phase === 'done' ? CLAY_MUTED : STONE

    const t = line.tokens
    const hasTokens = t.input + t.output + t.cacheRead + t.cacheWrite > 0
    const prompt = t.input + t.cacheRead + t.cacheWrite
    const hitRate = prompt > 0 ? Math.round((t.cacheRead / prompt) * 100) : null
    const ctx = line.contextPercent
    const ctxColor = ctx === null ? CLOUD : ctx >= 85 ? ALERT : ctx >= 60 ? AMBER : CLAY_MUTED
    const ctxFilled = ctx === null ? 0 : Math.max(0, Math.min(10, Math.round(ctx / 10)))
    const rule = '─'.repeat(Math.max(10, Math.min(240, e.props.bodyColumns - 2)))
    const isFresh = (at: number) => isWorkingNow && now - at < FLASH_MS

    // 第一行旁白:按 narrationOverflow 决定放不下时怎么办
    const overflow = config.overflow === 'scroll' && !Svg ? 'wrap' : config.overflow
    const marqueeW = Math.max(200, Math.min(1400, (e.props.bodyColumns - 10) * 8))
    const narration =
      overflow === 'scroll' && Svg ? (
        <Box flexGrow={1} flexShrink={1} minWidth={0} overflow="hidden">
          <Svg source={marqueeSvg(line.text, color, isWorkingNow, marqueeW)} alt={line.text} width={marqueeW} height={MARQUEE_H} />
        </Box>
      ) : overflow === 'wrap' || isExpanded ? (
        <Box flexGrow={1} flexShrink={1} minWidth={0}>
          <Text bold={isWorkingNow} color={color} wrap="wrap">
            {line.text}
          </Text>
        </Box>
      ) : (
        // 省略:单行截断;放不下时旁边有「全文」按钮,点了才展开
        <Box flexGrow={1} flexShrink={1} minWidth={0}>
          <Text bold={isWorkingNow} color={color} wrap="truncate-end">
            {line.text}
          </Text>
        </Box>
      )
    // 估算放不下:按格数比较,右侧还有状态格和按钮。Desktop 用的是比例字体,格数和实际宽度对不准,
    // 门槛放宽到六成:宁可在刚好放得下时多显示一个「全文」,也不要截断了却没有入口
    const isLong = cellWidth(line.text) > (e.props.bodyColumns - 16) * 0.6
    const expandToggle =
      overflow === 'truncate' && (isLong || isExpanded) ? (
        <Box key="narration-toggle" flexShrink={0}>
          <Button
            key="narration-expand"
            plain
            dimColor
            label={isExpanded ? tr().collapseNarration : tr().expandNarration}
            hover={{ underline: true, dimColor: false }}
            onPress={() => void update($, narrationExpandedAtom, v => !v)}
          />
        </Box>
      ) : null

    // 图标的含义:悬停弹出太容易误触(引擎的悬停没有延迟),改成点 ⓘ 才在下方展开图例
    const icon = (kind: IconKind, c: string) =>
      Svg ? (
        <Svg source={ICONS[kind](c)} alt={tr().alt[kind]} width={iconWidth(kind)} height={ICON_H} />
      ) : (
        <Text color={c}>{GLYPHS[kind]}</Text>
      )
    const legend = (
      <Box flexDirection="row" flexWrap="wrap" columnGap={2}>
        {(['input', 'output', 'cacheRead', 'cacheWrite', 'narrator', 'hit', 'cost', 'context'] as const).map(kind => (
          <Box flexDirection="row" alignItems="center" gap={1}>
            {icon(kind, kind === 'input' ? CLAY : kind === 'output' ? SKY : kind === 'cacheRead' ? OLIVE : kind === 'cacheWrite' ? AMBER : kind === 'hit' || kind === 'context' ? CLAY_MUTED : kind === 'cost' ? OLIVE : IDLE)}
            <Text dimColor>{tr().legend[kind]}</Text>
          </Box>
        ))}
      </Box>
    )

    // 一个指标:图标 + 加粗数值;图标颜色表示类别,刚增长时换成高亮色、数值同色
    const stat = (kind: IconKind, value: string, tint: string, isLit = false) => {
      const c = isLit ? tint : kind === 'input' || kind === 'output' ? IDLE : tint
      return (
        <Box flexDirection="row" alignItems="center" gap={1}>
          {icon(kind, c)}
          <Text bold color={isLit ? tint : undefined}>
            {value}
          </Text>
        </Box>
      )
    }

    return (
      <Box flexDirection="column" paddingX={1}>
        {/* 旁白占满左侧,状态钉在右侧固定宽度的格子里:文字长短变化不会挪动它 */}
        <Box flexDirection="row" gap={1}>
          {narration}
          {expandToggle}
          <Box width={6} flexShrink={0} justifyContent="flex-end">
            {isWorkingNow ? (
              Svg ? (
                <Svg source={dotsSvg(CLAY, CLOUD)} alt={tr().working} width={DOTS_W} height={DOTS_H} />
              ) : (
                <Text color={CLAY}>● ● ●</Text>
              )
            ) : (
              <Text bold color={color}>
                {line.phase === 'done' ? '✓' : '✕'}
              </Text>
            )}
          </Box>
        </Box>

        <Text color={CLOUD} dimColor wrap="truncate-end">
          {rule}
        </Text>

        {/* 进度行:左边是信息,右边钉着两个入口按钮(工作台、设置),左边再长也挤不走它们 */}
        <Box flexDirection="row" alignItems="center" gap={2}>
          <Box flexGrow={1} flexShrink={1} minWidth={0} flexDirection="row" flexWrap="wrap" columnGap={2}>
            <Text>{tr().bandSteps(isWorkingNow, line.steps)}</Text>
            <Text>
              <Text dimColor>{tr().bandTime}</Text>
              <Text bold>{elapsed}</Text>
            </Text>
            {line.errors > 0 && (
              <Box key="open-errors">
                <Button
                  key="errors"
                  plain
                  label={tr().bandFailures(line.errors)}
                  hover={{ underline: true }}
                  onPress={() => void openPane($, 'turn')}
                />
              </Box>
            )}
            {gitState.files.length > 0 && (
              <Box key="open-changes">
                <Button
                  key="changes"
                  plain
                  label={tr().bandChanges(gitState.files.length)}
                  hover={{ underline: true, color: CLAY }}
                  onPress={() => void openPane($, 'changes')}
                />
              </Box>
            )}
            {line.current && (
              <Text dimColor wrap="truncate-end">
                ▸ {line.current}
              </Text>
            )}
          </Box>
          <Box flexShrink={0} flexDirection="row" alignItems="center" gap={1}>
            <Button key="open-workbench" label={tr().openWorkbench} onPress={() => void openLastTab($)} />
plugins/workbench/hooks/register.tsx 1200〜1251 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: SETTINGS_PANE }, async ($, e) => {
    const { Box, Text, Button } = $.ui.resolve(e)
    const m = tr()
    const current: Record<SettingField, string> = {
      language: config.language,
      bandMode: config.bandMode,
      narrationOverflow: config.overflow,
      narratorMode: config.mode,
      narratorIntervalSeconds: String(config.minGapMs / 1000),
      narratorMaterialChars: String(config.materialStep),
    }
    const resolved = m.langName[m.lang]
    const pending = await read($, pendingSettingAtom)

    return (
      <Box flexDirection="column" gap={1}>
        <Text bold>{m.settingsTitle}</Text>
        {SETTING_FIELDS.map(({ field, choices }) => {
          const meta = m.fields[field]!
          const isSaving = pending?.field === field
          const selected = isSaving ? pending.value : current[field]
          return (
            <Box key={`setting-${field}`} flexDirection="column">
              <Text>
                <Text bold>{meta.title}</Text>
                {isSaving && <Text dimColor>{`  ${m.settingSaving}`}</Text>}
              </Text>
              <Text dimColor wrap="wrap">
                {meta.desc}
              </Text>
              <Box flexDirection="row" gap={1} flexWrap="wrap">
                {choices.map(choice => {
                  const value = String(choice)
                  return (
                    <Button
                      key={`set-${field}-${value}`}
                      label={meta.choice(value, resolved)}
                      variant={selected === value ? 'primary' : 'secondary'}
                      onPress={() => (selected === value ? undefined : void saveSetting($, field, choice))}
                    />
                  )
                })}
              </Box>
            </Box>
          )
        })}
        <Text dimColor wrap="wrap">
          {m.settingsNote}
        </Text>
      </Box>
    )
  })
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 fanbuz

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

載せる条件: 確かめやすいコード
入口を読んだhooks/hooks.json が名指すモジュールをすべて読んだ。plugins/workbench/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 のホスト)がコードに書いてあるか。通信なし
プログラム起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。git(通信する)
読んで送るファイルや環境変数を読み、かつ通信するか。読んだうえで通信する
ソースの鍵ソースに API キーや秘密鍵らしきものがあるか。ソースに鍵なし
ライセンスオープンなライセンス(MIT・Apache-2.0・BSD・ISC・Unlicense・0BSD・CC0)で全文があれば、modscode にコードを載せる。違えばリンクだけ。MIT

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

入れる

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

リポジトリの .claude-plugin/marketplace.json にこの Mod が載っていないため、入れる手順は出せません。コードとして読むか、作者の README に従ってください。

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン