modscode EN

modscode / 図鑑 / decision-lens

decision-lens

See the decisions Claude made in each turn, why it made them, and steer future turns with keep and avoid rules.

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

何をするか

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

良いところ

  • ネットワークに出ない
  • プロセスを起こさない
  • TypeScript で書かれている
  • エラーを扱う

作り始めるためのコード

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

雛形(register.tsx)

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

// Drawn like decision-lens by Atchyut (pane, status, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/theonly1me-decision-lens/
// 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: "Decision Lens" })
  on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
    const { Box, Text, Button } = $.ui.resolve(e)
    const position = '…'
    const ruleCount = '…'
    const hint = '…'
    const prompt = '…'
    const message = '…'
    const number = '…'
    const title = '…'
    const confidenceGlyph = '…'
    const label = '…'
    const text = '…'
    const text2 = '…'
    const text3 = '…'
    const alternative = '…'
    const unquoted = '…'
    const explanation = '…'
    const confidenceGlyph2 = '…'
    const text4 = '…'
    const text5 = '…'
    const text6 = '…'
    const explanation2 = '…'
    const confidenceGlyph3 = '…'
    const text7 = '…'
    const text8 = '…'
    const text9 = '…'
    const explanation3 = '…'
    return (
      <Box flexDirection="column">
        <Box flexDirection="column" marginBottom={1}>
          <Text>
            <Text bold color="#a78bfa">
              Decision Lens
            </Text>
            <Text dimColor>
              {position}
            </Text>
          </Text>
          <Box flexDirection="row" flexWrap="wrap" columnGap={2}>
            <Button plain hotkey="p" label="◀ Earlier turn" />
            <Button plain hotkey="n" label="Later turn ▶" />
            <Button plain hotkey="d" label="Decisions" />
            <Button plain hotkey="r" label={`Rules (${ruleCount})`} />
            <Button plain hotkey="x" role="dismiss" label="Close" />
          </Box>
          <Text color="#8b93a1">
            {hint}
          </Text>
        </Box>
        <Text italic dimColor>
          {`“${prompt}”`}
        </Text>
        <Text dimColor>
          {message}
        </Text>
        <Box flexDirection="column" borderStyle="round" borderColor="#a78bfa" paddingX={1}>
          <Box flexDirection="row" justifyContent="space-between" columnGap={1}>
            <Button plain hotkey={`${number}`} label={`◆ ${title}`} />
            <Text color="#8b93a1">
              {confidenceGlyph}
            </Text>
          </Box>
          <Text>
            <Text bold>
              {`${label}  `}
            </Text>
            {text}
          </Text>
          <Text>
            <Text bold>
              {`${label}  `}
            </Text>
            {text2}
          </Text>
          <Text>
            <Text bold>
              {`${label}  `}
            </Text>
            {text3}
          </Text>
          <Text dimColor>
            {`◇ ${alternative}`}
          </Text>
          <Text dimColor>
            {`◇ ${alternative}`}
          </Text>
          <Text dimColor>
            {`◇ ${alternative}`}
          </Text>
          <Text italic dimColor>
            {`“${unquoted}”`}
          </Text>
          <Text color="#a78bfa">
            Asking Claude…
          </Text>
          <Text>
            {explanation}
          </Text>
          <Box flexDirection="row" flexWrap="wrap" columnGap={2} marginTop={1}>
            <Text color="#34d399">
              ✓ keep rule saved
            </Text>
            <Text color="#fb7185">
              ✓ avoid rule saved
            </Text>
            <Button plain label="? Ask why" />
          </Box>
        </Box>
        <Box flexDirection="column" borderStyle="round" borderColor="#a78bfa" paddingX={1}>
          <Box flexDirection="row" justifyContent="space-between" columnGap={1}>
            <Button plain hotkey={`${number}`} label={`◆ ${title}`} />
            <Text color="#8b93a1">
              {confidenceGlyph2}
            </Text>
          </Box>
          <Text>
            <Text bold>
              {`${label}  `}
            </Text>
            {text4}
          </Text>
          <Text>
            <Text bold>
              {`${label}  `}
            </Text>
            {text5}
          </Text>
          <Text>
            <Text bold>
              {`${label}  `}
            </Text>
            {text6}
          </Text>
          <Text dimColor>
            {`◇ ${alternative}`}
          </Text>
          <Text dimColor>
            {`◇ ${alternative}`}
          </Text>
          <Text dimColor>
            {`◇ ${alternative}`}
          </Text>
          <Text italic dimColor>
            {`“${unquoted}”`}
          </Text>
          <Text color="#a78bfa">
            Asking Claude…
          </Text>
          <Text>
            {explanation2}
          </Text>
          <Box flexDirection="row" flexWrap="wrap" columnGap={2} marginTop={1}>
            <Text color="#34d399">
              ✓ keep rule saved
            </Text>
            <Text color="#fb7185">
              ✓ avoid rule saved
            </Text>
            <Button plain label="? Ask why" />
          </Box>
        </Box>
        <Box flexDirection="column" borderStyle="round" borderColor="#a78bfa" paddingX={1}>
          <Box flexDirection="row" justifyContent="space-between" columnGap={1}>
            <Button plain hotkey={`${number}`} label={`◆ ${title}`} />
            <Text color="#8b93a1">
              {confidenceGlyph3}
            </Text>
          </Box>
          <Text>
            <Text bold>
              {`${label}  `}
            </Text>
            {text7}
          </Text>
          <Text>
            <Text bold>
              {`${label}  `}
            </Text>
            {text8}
          </Text>
          <Text>
            <Text bold>
              {`${label}  `}
            </Text>
            {text9}
          </Text>
          <Text dimColor>
            {`◇ ${alternative}`}
          </Text>
          <Text dimColor>
            {`◇ ${alternative}`}
          </Text>
          <Text dimColor>
            {`◇ ${alternative}`}
          </Text>
          <Text italic dimColor>
            {`“${unquoted}”`}
          </Text>
          <Text color="#a78bfa">
            Asking Claude…
          </Text>
          <Text>
            {explanation3}
          </Text>
          <Box flexDirection="row" flexWrap="wrap" columnGap={2} marginTop={1}>
            <Text color="#34d399">
              ✓ keep rule saved
            </Text>
            <Text color="#fb7185">
              ✓ avoid rule saved
            </Text>
            <Button plain label="? Ask why" />
          </Box>
        </Box>
      </Box>
    )
  })

  on('session.start', async ($, e, next) => {
    await $.ui.status(`◆ reading the decisions in this turn`)
    await $.ui.toast(`Keep rule saved. Claude reads it from the next request.`)
    return next(e)
  })
}

Mod 自身のコード

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

plugins/decision-lens/hooks/pane.tsx 116〜156 行 · ペイン
  on('ui.render', { component: 'Pane', requestId: PANE_ID }, async ($, e) => {
    const elements = $.ui.resolve(e)
    const { Box, Text } = elements
    const view = lensView()
    const turn = selectedTurn()
    const act = (action: PaneAction) => {
      perform($, { action }).catch(noop)
    }
    const hasCards = view.tab === 'decisions' && turn?.status === 'ready' && turn.decisions.length > 0
    const position = view.tab === 'decisions' && turn ? `  turn ${view.turns.indexOf(turn) + 1} of ${view.turns.length}` : ''
    const message = view.tab === 'decisions' ? turnMessage({ turn, isAnalysisOn: view.isAnalysisOn }) : undefined
    const header = headerTree({
      elements,
      act,
      tab: view.tab,
      position,
      ruleCount: view.rules.length,
      hint: hintText({ isFocused: e.props.isFocused, tab: view.tab }),
    })
    if (view.tab === 'rules') {
      return (
        <Box flexDirection="column">
          {header}
          <Text dimColor>Claude reads these rules in every session: project rules here, global rules everywhere.</Text>
          {view.rules.length === 0 && <Text dimColor>No rules yet. Press k or a on a decision card, or type /why keep 1.</Text>}
          {view.rules.map((rule, index) => ruleTree({ elements, act, rule, number: index + 1 }))}
        </Box>
      )
    }
    return (
      <Box flexDirection="column">
        {header}
        {turn && <Text italic dimColor>{`“${turn.prompt}”`}</Text>}
        {message !== undefined && <Text dimColor>{message}</Text>}
        {hasCards &&
          turn.decisions.map((decision, index) =>
            cardTree({ elements, act, turn, decision, number: index + 1, isSelected: index + 1 === view.selectedNumber, rules: view.rules }),
          )}
      </Box>
    )
  })
plugins/decision-lens/hooks/lens/panel.tsx 30〜56 行 · ペイン
export function headerTree(options: {
  elements: ElementTable
  act: Act
  tab: LensTab
  position: string
  ruleCount: number
  hint: string
}): RenderElement {
  const { Box, Text, Button } = options.elements
  const { act, tab } = options
  return (
    <Box flexDirection="column" marginBottom={1}>
      <Text>
        <Text bold color={COLORS.accent}>Decision Lens</Text>
        <Text dimColor>{options.position}</Text>
      </Text>
      <Box flexDirection="row" flexWrap="wrap" columnGap={2}>
        <Button key="previous" plain hotkey="p" label="◀ Earlier turn" onPress={() => act({ kind: 'turn', step: -1 })} />
        <Button key="next" plain hotkey="n" label="Later turn ▶" onPress={() => act({ kind: 'turn', step: 1 })} />
        <Button key="tab-decisions" plain hotkey="d" label="Decisions" dimColor={tab !== 'decisions'} onPress={() => act({ kind: 'tab', tab: 'decisions' })} />
        <Button key="tab-rules" plain hotkey="r" label={`Rules (${options.ruleCount})`} dimColor={tab !== 'rules'} onPress={() => act({ kind: 'tab', tab: 'rules' })} />
        <Button key="close" plain hotkey="x" role="dismiss" label="Close" onPress={() => act({ kind: 'close' })} />
      </Box>
      <Text color={COLORS.muted}>{options.hint}</Text>
    </Box>
  )
}
plugins/decision-lens/hooks/lens/panel.tsx 121〜139 行 · ペイン
export function ruleTree(options: { elements: ElementTable; act: Act; rule: Rule; number: number }): RenderElement {
  const { Box, Text, Button } = options.elements
  const { act, rule } = options
  const isKeep = rule.kind === 'keep'
  return (
    <Box key={`rule-${rule.id}`} flexDirection="column" marginBottom={1}>
      <Text>
        <Text color={COLORS.muted}>{`${options.number}. `}</Text>
        <Text color={isKeep ? COLORS.keep : COLORS.avoid}>{isKeep ? '▲ keep  ' : '▼ avoid '}</Text>
        {rule.text}
      </Text>
      <Box flexDirection="row" columnGap={2} paddingLeft={3}>
        <Text dimColor>{rule.scope === 'project' ? 'this project' : 'every project'}</Text>
        <Button key={`scope-${rule.id}`} label={rule.scope === 'project' ? 'Make global' : 'This project only'} onPress={() => act({ kind: 'scope', ruleId: rule.id })} />
        <Button key={`remove-${rule.id}`} label="Remove" onPress={() => act({ kind: 'remove', ruleId: rule.id })} />
      </Box>
    </Box>
  )
}
plugins/decision-lens/hooks/lens/panel.tsx 87〜119 行 · ペイン
export function cardTree(options: {
  elements: ElementTable
  act: Act
  turn: LensTurn
  decision: Decision
  number: number
  isSelected: boolean
  rules: readonly Rule[]
}): RenderElement {
  const { Box, Text, Button } = options.elements
  const { decision, number, isSelected } = options
  return (
    <Box key={`decision-${decision.id}`} flexDirection="column" borderStyle="round" borderColor={isSelected ? COLORS.accent : COLORS.frame} paddingX={1}>
      <Box flexDirection="row" justifyContent="space-between" columnGap={1}>
        <Button key={`card-${number}`} plain hotkey={String(number)} {...(number === 1 ? ({ autoFocus: true } as const) : {})} label={`◆ ${decision.title}`} onPress={() => options.act({ kind: 'select', number })} />
        <Text color={COLORS.muted}>{confidenceGlyph(decision.confidence)}</Text>
      </Box>
      {decisionBody(decision).map(part => (
        <Text>
          <Text bold>{`${part.label}  `}</Text>
          {part.text}
        </Text>
      ))}
      {decision.alternatives.map(alternative => (
        <Text dimColor>{`◇ ${alternative}`}</Text>
      ))}
      {decision.evidence !== '' && <Text italic dimColor>{`“${unquoted(decision.evidence)}”`}</Text>}
      {decision.isAsking && <Text color={COLORS.accent}>Asking Claude…</Text>}
      {decision.explanation !== '' && <Text>{decision.explanation}</Text>}
      {steerButtons(options)}
    </Box>
  )
}
plugins/decision-lens/hooks/lens/panel.tsx 58〜85 行 · ペイン
function steerButtons(options: {
  elements: ElementTable
  act: Act
  turn: LensTurn
  decision: Decision
  rules: readonly Rule[]
  isSelected: boolean
}): RenderElement {
  const { Box, Text, Button } = options.elements
  const { act, decision, isSelected } = options
  const ids = { turnId: options.turn.id, decisionId: decision.id }
  const keyed = (key: string) => (isSelected ? { hotkey: key } : {})
  return (
    <Box flexDirection="row" flexWrap="wrap" columnGap={2} marginTop={1}>
      {hasRule({ rules: options.rules, text: decision.keep }) ? (
        <Text color={COLORS.keep}>✓ keep rule saved</Text>
      ) : (
        <Button key={`keep-${decision.id}`} plain {...keyed('k')} dimColor={!isSelected} label="▲ Keep doing this" onPress={() => act({ kind: 'keep', ...ids })} />
      )}
      {hasRule({ rules: options.rules, text: decision.avoid }) ? (
        <Text color={COLORS.avoid}>✓ avoid rule saved</Text>
      ) : (
        <Button key={`avoid-${decision.id}`} plain {...keyed('a')} dimColor={!isSelected} label="▼ Don't do this" onPress={() => act({ kind: 'avoid', ...ids })} />
      )}
      <Button key={`why-${decision.id}`} plain {...keyed('w')} dimColor={!isSelected} label="? Ask why" onPress={() => act({ kind: 'ask', ...ids })} />
    </Box>
  )
}
ライセンスの全文(MIT)
MIT License

Copyright (c) 2026 Atchyut

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

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

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

入れる

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

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

/plugin marketplace add theonly1me/claude-code-mods
/plugin install decision-lens@claude-code-mods

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

Claude に聞く

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

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

Claude から探す: MCP コネクタ

似たデザイン