cc-visualq
Claude Code asks multiple-choice questions through AskUserQuestion, and the
dialog is terminal-only — plain text options, no charts. When the options differ
along numbers you care about (bundle size, latency, risk, weeks of work), text
makes you hold the comparison in your head.
This plugin renders those options as an HTML comparison chart in your
terminal's embedded browser, and you answer by clicking a card. In the Claude
Code desktop app the same comparison is drawn beside the options in the app's
own dialog, with no browser at all. If neither surface is there, the terminal
dialog asks as it always would.
Install
/plugin marketplace add underw8/cc-visualq
/plugin install cc-visualq@cc-visualq
Requires Node (any version with node on PATH). No npm dependencies.
Usage
Nothing to configure. When Claude includes a metric tag in an option's
description, the chart appears:
{label: "Svelte", description: "Smallest output. {bundle_kb:12, cold_start_ms:38}"}
The {key:value, ...} tag is stripped before the dialog renders, so the
terminal still shows a clean description. If the page doesn't tell you enough to
choose, ↻ Ask again, with more closes it and Claude poses the same question
again with a fuller briefing, a diagram and more of the comparison. Options without a tag get no chart and
no browser — the question behaves exactly as it would without the plugin.
A SessionStart hook injects an option-authoring rule (hooks/askq-rule.md)
into every session, so Claude tags options with measurable dimensions on its
own — there's nothing to add to your own CLAUDE.md.
How it works
A PreToolUse hook on AskUserQuestion serves the options as an HTML
comparison over loopback, blocks until a card is clicked, and answers the tool
directly. Every path that isn't an explicit click emits nothing, which renders
no decision and lets the terminal dialog ask unchanged.
sequenceDiagram
autonumber
participant CC as Claude Code
participant H as hooks/askq.js
participant R as lib/render.js
participant L as lib/launch.js
participant B as embedded browser
Note over CC: SessionStart injected askq-rule.md,<br/>so options carry metric tags and briefings
CC->>H: PreToolUse AskUserQuestion, tool_input on stdin
H->>H: stripTags: split briefing, parse metric tag
alt no metric tag and no briefing
H-->>CC: exit 0, no output
Note over CC: terminal dialog asks unchanged
else the host draws previews as HTML
H-->>CC: ask + updatedInput.questions with previews
Note over CC: desktop app draws it in its own dialog
else something to draw
H->>H: mint nonce
H->>R: renderPage
R-->>H: HTML
H->>H: listen 127.0.0.1:0
H->>L: openUrl
alt no launcher succeeded
H-->>CC: exit 0, no output
else launched
B->>H: GET / with nonce
Note over H: arrived = true
B->>H: GET /ping every 3s
alt a card was clicked
B->>H: POST /answer with nonce, picked, other, notes
H->>H: timing-safe nonce compare
H->>H: filter labels against the tool's own set
H-->>CC: allow + updatedInput.answers
else asked again
B->>H: POST /again with nonce
H-->>CC: deny + reason: ask it again, deeper
Note over CC: same question, fuller briefing and chart
end
end
end
Three ways the hook stops waiting without an answer: ARRIVE_MS 10s with
nothing fetching the page, WAIT_MS 900s with nothing posting, or a rejected
POST giving up. WAIT_MS stays below the hook entry's timeout: 960 so the
process exits on its own terms instead of being killed mid-write.
Modules
flowchart TD
HJ["hooks/askq.js<br/>server, routes, decision"]
ME["lib/metrics.js<br/>tag parsing, units, bar widths"]
RE["lib/render.js<br/>page shell, cards, styles"]
PV["lib/preview.js<br/>inline-styled option fragment"]
CH["lib/charts.js<br/>the three forms, form selection"]
MD["lib/md.js<br/>briefing markdown subset"]
PS["lib/page-script.js<br/>the browser script"]
ES["lib/esc.js<br/>HTML escaping"]
LA["lib/launch.js<br/>launcher order and spawn"]
VS["lib/vscode.js<br/>stub file + settings"]
VE["vendor/mermaid.min.js<br/>served on demand"]
HJ --> ME
HJ --> RE
HJ --> PV
HJ --> LA
HJ -.->|"GET /mermaid.min.js"| VE
RE --> ME
RE --> CH
RE --> MD
RE --> PS
RE --> ES
CH --> ME
CH --> ES
MD --> ES
PV --> ME
PV --> CH
PV --> MD
PV --> ES
LA --> VS