qa-guide
Shows Claude's questions in a side pane with context, option details, an AI explanation and answer history; also explains questions Claude asks in plain text.
何をするか
- プロンプトの上の帯・欄・トーストを描く
- /qa-guide を足す
- AskUserQuestion の呼び出しを見張る
- prompt.submit・session.start・turn.completeにフックする
良いところ
- ネットワークに出ない
- プロセスを起こさない
- TypeScript で書かれている
- エラーを扱う
作り始めるためのコード
2 種類あります。上のデザインから modscode が書いた雛形と、その Mod 自身のコードのうち描いている部分です。
雛形(register.tsx)
import type { Register } from 'claude-code'
// Drawn like qa-guide by aieo-product (pane, band, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/aieo-product-qa-guide/
// 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 truncateCells = '…'
return (
<Box flexDirection="column">
<Box flexDirection="row" gap={1}>
<Text color="yellow" bold>
⏳
</Text>
<Text wrap="truncate-end">
<Text color="yellow">
Claude is waiting for your decision
{": "}
</Text>
<Text dimColor>
{truncateCells}
</Text>
</Text>
<Text dimColor>
Explaining in the question guide…
</Text>
<Text dimColor wrap="truncate-end">
or type ?? + Enter
</Text>
<Button plain label="×" />
</Box>
{await next(e)}
</Box>
)
})
// the pane: open it with $.ui.open({ id: 'my-pane', title: "Question guide" })
on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
const { Box, Text, Button, Markdown } = $.ui.resolve(e)
const count = '…'
const selectedCursor = '…'
const total = '…'
const sessionCost = '…'
const lead = '…'
const answers = '…'
const usageLine = '…'
const explanation = '…'
const index = '…'
const header = '…'
const question = '…'
const question2 = '…'
const question3 = '…'
const answers2 = '…'
const question4 = '…'
const question5 = '…'
const question6 = '…'
const answers3 = '…'
const question7 = '…'
const question8 = '…'
const question9 = '…'
const answers4 = '…'
return (
<Box flexDirection="column">
<Box flexDirection="row" gap={1}>
<Text backgroundColor="yellow" color="black" bold>
{" Awaiting answer "}
</Text>
<Text bold>
{`Questions from Claude (${count})`}
</Text>
</Box>
<Box flexDirection="column">
<Box flexDirection="row" gap={1}>
<Text dimColor>
{`${selectedCursor}1/${count}`}
</Text>
<Button hotkey="p" plain label="◀ Previous" />
<Button hotkey="n" plain label="Next ▶" />
<Button hotkey="l" plain label="Latest" />
</Box>
<Box flexDirection="row" gap={1}>
<Button hotkey="a" plain label="AI explanation: ON" />
<Button hotkey="h" plain label="Hide history" />
<Button role="dismiss" plain label="Close" />
</Box>
<Text dimColor>
{`AI tokens this session: ${total}`}
{sessionCost}
</Text>
</Box>
<Box flexDirection="column" marginTop={1}>
<Text color="blue" bold>
▍Your recent instructions
</Text>
<Box flexDirection="column">
<Text dimColor wrap="truncate-end" />
<Text dimColor wrap="truncate-end" />
<Text dimColor wrap="truncate-end" />
</Box>
<Box flexDirection="column">
<Text dimColor wrap="truncate-end" />
<Text dimColor wrap="truncate-end" />
<Text dimColor wrap="truncate-end" />
</Box>
<Box flexDirection="column">
<Text dimColor wrap="truncate-end" />
<Text dimColor wrap="truncate-end" />
<Text dimColor wrap="truncate-end" />
</Box>
</Box>
<Box flexDirection="column" marginTop={1}>
<Text color="blue" bold>
▍Claude's preceding explanation
</Text>
<Markdown text={`${lead}`} dimColor />
</Box>
<Box flexDirection="column" marginTop={1}>
<Text color="green" bold>
Freeform answer
</Text>
<Text color="green">
{answers}
</Text>
</Box>
<Box flexDirection="column" marginTop={1} borderStyle="round" borderColor="magenta" paddingX={1}>
<Box flexDirection="row" gap={1}>
<Text color="magenta" bold>
✦ AI explanation (instructions, context, effects, recommendation)
</Text>
<Text dimColor>
compact context
</Text>
</Box>
<Text dimColor>
{usageLine}
</Text>
<Text dimColor>
Generating… (you can keep answering)
</Text>
<Markdown text={`${explanation}`} />
<Text color="red">
{`Could not generate an explanation: ${explanation}`}
</Text>
<Text dimColor>
OFF (enable for the next question with [a])
</Text>
</Box>
<Button hotkey="f" plain label="Full context" />
<Box flexDirection="column" marginTop={1}>
<Text dimColor>
────────
</Text>
<Text bold>
Past questions and answers
</Text>
<Box flexDirection="column" marginTop={1}>
<Button plain label={`${index}1/${count} ▶ Selected`} />
<Box flexDirection="column">
<Text>
{`[${header}] `}
{question}
</Text>
<Text color="yellow">
{" → "}
{" Awaiting answer "}
</Text>
</Box>
<Box flexDirection="column">
<Text>
{`[${header}] `}
{question2}
</Text>
<Text color="yellow">
{" → "}
{" Awaiting answer "}
</Text>
</Box>
<Box flexDirection="column">
<Text>
{`[${header}] `}
{question3}
</Text>
<Text color="yellow">
{" → "}
{" Awaiting answer "}
</Text>
</Box>
<Text color="green">
{" → Freeform: "}
{answers2}
</Text>
</Box>
<Box flexDirection="column" marginTop={1}>
<Button plain label={`${index}1/${count} ▶ Selected`} />
<Box flexDirection="column">
<Text>
{`[${header}] `}
{question4}
</Text>
<Text color="yellow">
{" → "}
{" Awaiting answer "}
</Text>
</Box>
<Box flexDirection="column">
<Text>
{`[${header}] `}
{question5}
</Text>
<Text color="yellow">
{" → "}
{" Awaiting answer "}
</Text>
</Box>
<Box flexDirection="column">
<Text>
{`[${header}] `}
{question6}
</Text>
<Text color="yellow">
{" → "}
{" Awaiting answer "}
</Text>
</Box>
<Text color="green">
{" → Freeform: "}
{answers3}
</Text>
</Box>
<Box flexDirection="column" marginTop={1}>
<Button plain label={`${index}1/${count} ▶ Selected`} />
<Box flexDirection="column">
<Text>
{`[${header}] `}
{question7}
</Text>
<Text color="yellow">
{" → "}
{" Awaiting answer "}
</Text>
</Box>
<Box flexDirection="column">
<Text>
{`[${header}] `}
{question8}
</Text>
<Text color="yellow">
{" → "}
{" Awaiting answer "}
</Text>
</Box>
<Box flexDirection="column">
<Text>
{`[${header}] `}
{question9}
</Text>
<Text color="yellow">
{" → "}
{" Awaiting answer "}
</Text>
</Box>
<Text color="green">
{" → Freeform: "}
{answers4}
</Text>
</Box>
</Box>
</Box>
)
})
on('session.start', async ($, e, next) => {
await $.ui.toast(`Question guide: use /qa-guide to view context and option details`)
return next(e)
})
}
Mod 自身のコード
Mod のライセンス(MIT)に従って載せています。全文は下にあります。写すときは著作権表示を残してください。
plugins/qa-guide/hooks/register.tsx 999〜1038 行 · バンド
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
if (options.chatQuestions === 'off' || e.props.hasSurvey || e.props.isWorking) return next(e)
const pending = await read($, waiting)
if (!pending) return next(e)
const { Box, Text, Button } = $.ui.resolve(e)
const lang = pending.lang
const width = Math.max(20, e.props.bodyColumns)
const cells = (text: string) => [...text].reduce((n, char) => n + cellWidth(char), 0)
// Icon, label, button or status, ×, the gaps between them and a margin for the engine's own controls.
const fixed = 2 + cells(t(lang, 'waitingLabel')) + 2 +
(pending.entryId ? cells(t(lang, 'waitingPending')) : cells(t(lang, 'explainWaiting')) + 4) + 1 + 4 + 6
// The ?? hint is the first thing to go in a narrow row, so it never wraps.
const hint = !pending.entryId && width - fixed - cells(t(lang, 'waitingHint')) - 1 >= 16
const room = Math.max(10, width - fixed - (hint ? cells(t(lang, 'waitingHint')) + 1 : 0))
return (
<Box flexDirection="row" gap={1}>
<Text color="yellow" bold>⏳</Text>
<Text wrap="truncate-end">
<Text color="yellow">{t(lang, 'waitingLabel')}: </Text>
<Text dimColor>{truncateCells(oneLine(pending.question), room)}</Text>
</Text>
{pending.entryId
? <Text dimColor>{t(lang, 'waitingPending')}</Text>
: <Button key="explain-waiting" hotkey="e" variant="primary" label={t(lang, 'explainWaiting')}
onPress={() => explainWaiting($, pending, compactContexts, runIds, settled)} />}
{hint && <Text dimColor wrap="truncate-end">{t(lang, 'waitingHint')}</Text>}
<Button key="dismiss-waiting" plain label="×" onPress={async () => {
let removed: QaWaiting | null = null
await update($, waiting, w => {
removed = null
if (!w || w.id !== pending.id) return w
removed = w
return null
})
const old = removed as QaWaiting | null
if (old?.entryId) await settleChat($, old.entryId, { status: 'cancelled', answers: {} }, settled)
}} />
</Box>
)
})plugins/qa-guide/hooks/register.tsx 1040〜1199 行 · ペイン
on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
const { Box, Text, Button, Markdown } = $.ui.resolve(e)
// State survives reloads; normalize entries saved before prompts/language existed.
const list = (await read($, entries)).map(x => ({
...x,
lang: x.lang ?? 'ja',
explainMode: x.explainMode ?? 'full',
userPrompts: Array.isArray(x.userPrompts) ? x.userPrompts : [],
}))
const aiOn = await read($, isAiOn)
const history = await read($, showHistory)
const total = await read($, usageTotal)
const cost = await read($, costTotal)
const showCost = options.showCost !== 'off'
const width = Math.max(20, e.props.bodyColumns)
const selectedCursor = clampCursor(await read($, cursor), list.length)
const openDialog = [...list].reverse().find(isOpenDialog)
const current = openDialog ?? list[list.length - 1 - selectedCursor]
const lang = current?.lang ?? await resolveLang($, options.language)
const sessionCost = showCost && cost.hasPricedUsage
? costSuffix(lang, cost.usd, cost.hasUnpricedUsage || total > cost.tokens) : ''
const navigate = async (select: (value: number) => number) => {
await update($, cursor, value => clampCursor(select(clampCursor(value, list.length)), list.length))
try {
const selected = list[list.length - 1 - clampCursor(await read($, cursor), list.length)]
if (selected && selected.lang !== lang) {
await $.ui.open({ id: PANE, title: t(selected.lang, 'title') }).catch(() => undefined)
}
// History buttons can sit below the selected question's full content.
await $.ui.scroll({ in: PANE, to: 'start' })
} catch {
// The pane may have closed while changing the selection.
}
}
const rule = <Text dimColor>{t(lang, 'rule').repeat(Math.min(width, 60))}</Text>
const toolbar = (
<Box flexDirection="column">
{current && (
<Box flexDirection="row" gap={1}>
<Text dimColor>{t(lang, 'counter', { number: selectedCursor + 1, count: list.length })}</Text>
{selectedCursor < list.length - 1 && (
<Button
key="prev"
hotkey="p"
plain
label={t(lang, 'previous')}
onPress={() => navigate(value => value + 1)}
/>
)}
{selectedCursor > 0 && (
<Button
key="next"
hotkey="n"
plain
label={t(lang, 'next')}
onPress={() => navigate(value => value - 1)}
/>
)}
{selectedCursor > 0 && (
<Button key="latest" hotkey="l" plain label={t(lang, 'latest')} onPress={() => navigate(() => 0)} />
)}
</Box>
)}
<Box flexDirection="row" gap={1}>
<Button
key="ai"
hotkey="a"
plain
label={t(lang, 'aiToggle', { state: t(lang, aiOn ? 'on' : 'off') })}
onPress={() => update($, isAiOn, v => !v)}
/>
<Button
key="hist"
hotkey="h"
plain
label={t(lang, history ? 'hideHistory' : 'history', { count: list.length })}
onPress={() => update($, showHistory, v => !v)}
/>
<Button key="close" role="dismiss" plain label={t(lang, 'close')} onPress={() => $.ui.close({ id: PANE })} />
</Box>
<Text dimColor>{t(lang, 'sessionUsage', { total: totalTokens(lang, total) })}{sessionCost}</Text>
</Box>
)
if (!current) {
return (
<Box flexDirection="column">
<Text dimColor>{t(lang, 'empty')}</Text>
{toolbar}
</Box>
)
}
const statusBadge =
current.status === 'open' ? (
<Text backgroundColor="yellow" color="black" bold>{t(lang, 'awaiting')}</Text>
) : current.status === 'answered' ? (
<Text backgroundColor="green" color="black" bold>{t(lang, 'answered')}</Text>
) : (
<Text backgroundColor="gray" color="black" bold>{t(lang, 'cancelled')}</Text>
)
const modeTag = t(lang, current.explainMode === 'compact' ? 'compactContext' : 'fullContext')
const usageLine = current.usage && current.usageModel ? t(lang, 'usageLine', {
input: groupedTokens(current.usage.input_tokens),
read: groupedTokens(current.usage.cache_read_input_tokens),
write: groupedTokens(current.usage.cache_creation_input_tokens),
output: groupedTokens(current.usage.output_tokens),
model: t(lang, current.usageModel === 'session' ? 'sessionModel' : 'haikuModel'),
}) + (showCost ? costSuffix(lang, current.costUsd, current.costIncomplete) : '') : undefined
const deepButton = <Button key="deep" hotkey="f" plain label={t(lang, 'deep')} onPress={() => explain($, current.id, 'full', compactContexts, runIds)} />
if (openDialog) {
const columns = Math.max(1, Math.floor(e.props.bodyColumns))
const bodyRows = Math.max(0, Math.floor(e.props.scroll?.bodyRows ?? e.viewport?.rows ?? 24))
let remaining = Math.max(0, bodyRows - 1) // one header row
const latestPrompt = current.userPrompts[current.userPrompts.length - 1]
const instructionLines = latestPrompt ? promptLines(latestPrompt, columns) : []
const contextRows = (instructionLines.length ? 1 + instructionLines.length : 0) + (current.lead ? 2 : 0)
const aiText = current.explainState === 'pending'
? t(lang, 'generating')
: current.explainState === 'done'
? current.explanation
: current.explainState === 'error'
? t(lang, 'explainError', { explanation: current.explanation })
: t(lang, 'compactOff')
// Each Text costs one row. Reserve the newest instruction and a lead
// tail, then let completed AI guidance use up to 65% of the visible rows.
// Short OFF/pending/error messages leave their spare rows for the lead.
const aiBudget = Math.min(remaining, Math.max(1, Math.floor(bodyRows * 0.65)),
Math.max(1, remaining - contextRows))
const rawAiLines = compactAiLines(aiText, columns, lang)
const aiContent = clampedLines(rawAiLines.filter(line => !line.spacer), aiBudget, columns)
remaining -= aiContent.length
const requestLines = remaining >= 2 ? instructionLines.slice(0, remaining - 1) : []
if (requestLines.length) remaining -= 1 + requestLines.length
const leadLines = current.lead && remaining >= 2
? wrappedLines(current.lead, columns).slice(-(remaining - 1))
: []
if (leadLines.length) remaining -= 1 + leadLines.length
// Allocate text first across the whole tree. Only unused rows can become
// spacers, and AI spacers also stay inside its 65% limit.
const aiLines = clampedLines(rawAiLines, Math.min(aiBudget, aiContent.length + remaining), columns)
remaining -= aiLines.length - aiContent.length
const requestSpacer = requestLines.length > 0 && remaining > 0
if (requestSpacer) remaining -= 1
const leadSpacer = leadLines.length > 0 && remaining > 0
if (leadSpacer) remaining -= 1
const showDeep = current.explainState === 'done' && remaining > 0
if (showDeep) remaining -= 1
const showUsage = !!usageLine && aiLines.length > 0 && remaining > 0
const showModeTag = !!aiLines[0] &&
(current.explainState === 'done' ||
[...`${aiLines[0].text} ${modeTag}`].reduce((cells, char) => cells + cellWidth(char), 0) <= columns)
const inlineModeTag = truncateCells(modeTag, columns)
const tagCells = [...inlineModeTag].reduce((cells, char) => cells + cellWidth(char), 0)
const firstAiColumns = Math.max(0, columns - tagCells - 1)ライセンスの全文(MIT)
MIT License Copyright (c) 2026 aieo-product 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 に読んだコミット 260d25cae05d のソースから。最初のまとまりが載せる条件で、残りは自分で判断するための材料です。後のコミットは、次に読むまで見ていません。
| 載せる条件: 確かめやすいコード | |
|---|---|
| 入口を読んだ | hooks/hooks.json が名指すモジュールをすべて読んだ。plugins/qa-guide/hooks/register.tsx |
| 解析できる | すべてのファイルが TypeScript か JavaScript として解析できる。2 ファイルを解析 |
| コードが 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 aieo-product/claude_qamods/plugin install qa-guide@claude-qamods入るのはマーケットプレイスの最新のコミットで、ここで読んだもの(260d25cae05d)と違うことがあります。入れる前に見比べてください。
Claude に聞く
modscode のコネクタを入れると、Claude がこのデザイン・コードが触るもの・コードを読んで、それをもとに作れます。たとえば:
modscode のデザイン「aieo-product-qa-guide」をコードごと読んで、同じようなペインを作って似たデザイン
-
Claude に頼む…HandoffHandoffHandoff… the rest of the step is in the handoff████████░░░░░░░░ /clear in 4spress 1 to clear now, or send a prompt to stay
-
Claude に頼む…Skins0 Your promptadd rate limiting to the hub api0 Tool rows: finished, running, failedYour prompt Spinner0 Folded group of reads and searches●main · note 3 · note 3 · note 30 Edit diff cardDesktop only; the terminal keeps Claude Code's diff.0 Shell output cardDesktop only.0 Code block cardDesktop only; the terminal keeps Claude Code's markdown.0 TableAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentCopyAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentCopyAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentAccentCopy0 SpinnerAccent SpinnerSpinnerSpinner… 2h 10m0 Band above the prompt: normal, then nudging to compact█████░░░ 42% build█████░░░ 42% build█████░░░ 42% buildContext is 42% full0 Compact now0 Band above a questionTable BashBashBash0 Turn footer (terminal)3 build in 2h 10m · Grep · +3 −3
-
Claude に頼む…Glossary BrowserGlossary openContextsContextsContexts▲ prevWrite1/Glossary▼ nextContexts
-
Claude に頼む…envbuildbuildbuild+ .env.localsrc/app.ts is not in .gitignoreWriteNo .env files in the project root yet.K = paste the value, Enter saves saveNew key: NAME, Enter to continuegenerate randomcancelMissing compared with Write:KKK
-
何をするか
- 欄・プロンプトの上の帯を描く
- Bash の呼び出しを見張る(止めることがある)
- classic.CwdChanged・classic.SessionStart・classic.SubagentStart・classic.UserPromptSubmit ほか 5 個にフックする
- ターンをまたいで自分の状態を持つ
-
Claude に頼む…────────Clear doneClaude⋯└─ buildCancelCancelCancel└─ buildCancelCancelCancel└─ buildCancelCancelCancel