You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(skill): document --markdown mode and MarkdownDoc component
Updates the Claude Code skill to cover v0.2.0 additions:
- SKILL.md: rename 'three modes' to 'four modes', add --markdown (Mode 3) with --comments/--edits/--allow-html flags and comment object shape. Renumber HTML agent:// to Mode 4 with a 'try Mode 3 first' nudge. Add MarkdownDoc as component #12 in the A2UI catalog. Flag missing mode flag as the most common exit-3 failure. Document NSURLErrorDomain -1100 troubleshooting.
- references/templates.md: fix stale 'no markdown — plain text only' line (true for Text, not for MarkdownDoc/--markdown). Add Template 5: markdown document review with flag matrix and response shape.
Copy file name to clipboardExpand all lines: skill/SKILL.md
+48-7Lines changed: 48 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,7 @@ If running the command feels risky, ask for permission to run it — not to past
21
21
| Collecting 3+ related fields (name + role + options) |**Yes** — one form beats N questions |
22
22
| Presenting 5-20 options to choose from |**Yes** — radio/select picker |
23
23
| Showing a diff/preview/report before user confirms |**Yes** — formatted content is readable |
24
+
| Reviewing a markdown doc (spec, PR description, draft) with comments/edits |**Yes** — use `--markdown` mode (Mode 3) |
24
25
| Simple yes/no question |**No** — just ask in terminal |
25
26
| Agent-side computation taking >30s before UI can render |**No** — show a text status instead |
26
27
| Non-interactive environment (CI, piped output) |**No** — preflight will fail, fall back to terminal |
@@ -42,7 +43,9 @@ fi
42
43
43
44
If preflight fails, fall back to terminal Q&A — don't try to be clever. Report why the webview path isn't available and continue in text.
44
45
45
-
## The three modes
46
+
## The four modes
47
+
48
+
**Exactly one of `--a2ui`, `--url`, or `--markdown` must be specified.** Omitting all three is the most common failure — the binary exits 3 with usage.
Best for spec review, PR-description review, draft approval — any flow where the agent produced markdown and the human needs to read, comment on, or edit it. Feed markdown on stdin. Rendered with CommonMark + GFM (tables, fenced code).
69
+
70
+
Three independent toggles:
64
71
65
-
Best when you need visual fidelity beyond A2UI (charts, diffs, diagrams). The HTML page uses the same `window.webkit.messageHandlers.complete.postMessage({...})` bridge.
|`--edits`| Preview/Source tabs (`Cmd+/` to toggle). Returns `{edited_text:"...", modified:bool}`|
77
+
|`--allow-html`| Opt out of HTML sanitization (default strips `<script>`, `<iframe>`, event handlers, `javascript:` URLs). Use only for trusted content. |
78
+
79
+
`--comments` and `--edits` compose; turn both on to get all four fields back.
Line numbers are 1-indexed against the markdown source.
92
+
93
+
### Mode 4 — `html` · custom HTML via `agent://`
94
+
95
+
Best when you need visual fidelity beyond A2UI and markdown (charts, custom diffs, diagrams). The HTML page uses the same `window.webkit.messageHandlers.complete.postMessage({...})` bridge.
96
+
97
+
**Before reaching for Mode 4, ask whether Mode 3 (markdown) covers the case.** Markdown renders GFM tables, fenced code, links, and lists — enough for ~80% of "show the user some formatted content" needs, with no HTML to author or debug.
66
98
67
99
**Two separate Bash calls** (don't chain — the `load` command and the webview invocation sequence matters):
**The `--url` CLI flag is required** — without it the binary exits with usage. The stdin `load` command populates the in-memory resource map that `agent://host/...` reads from.
83
115
84
-
Pick Mode 3 over A2UI only when you need charts, syntax-highlighted diffs, images, or custom interactions. If you're writing >200 lines of HTML, consider splitting the work into a proper tool instead.
116
+
**Common failure — `NSURLErrorDomain error -1100`**: the resource key in the `load` command doesn't match the path in `--url`. If you use `--url "agent://host/index.html"`, the `resources` map must contain the key `"index.html"` (exact match, no leading slash). When this persistently fails, fall back to Mode 3 — pipe the rendered content as markdown instead of hand-rolling HTML.
117
+
118
+
Pick Mode 4 over Mode 3 only when you need charts, syntax-highlighted diffs, images, or custom interactions. If you're writing >200 lines of HTML, consider splitting the work into a proper tool instead.
85
119
86
120
## A2UI catalog (Mode 1)
87
121
88
-
All 11 components in the built-in renderer:
122
+
All 12 components in the built-in renderer:
89
123
90
124
| Component | Purpose | Key props |
91
125
|-----------|---------|-----------|
92
126
|`Column`| Vertical stack |`children.explicitList` (array of IDs) |
**Form data collection**: every component with `fieldName` is collected when a Button is clicked. The response `data` contains `{fieldName: value, ...}` plus the button's `action.name` (and `action.context` if set).
105
140
141
+
**`MarkdownDoc` vs `--markdown` mode**: use `MarkdownDoc` when the markdown review is one part of a larger form (e.g. spec review + "approve/reject" radio + notes field). Use `--markdown` mode (Mode 3) when the window is *only* about the markdown doc — simpler invocation, no JSONL to generate.
142
+
106
143
## Response format reference
107
144
108
145
Canonical stdout shape on successful completion (exit 0):
@@ -166,7 +203,11 @@ For anything beyond trivial substitution, **write the JSONL in a Python generato
166
203
## Workflow: when asked to show UI
167
204
168
205
1.**Run preflight** (above). If it fails, fall back to terminal Q&A with a one-line note.
169
-
2.**Pick the mode**: A2UI (forms/approvals/selection — 90% of cases), URL (existing page), HTML (rich visuals only).
206
+
2.**Pick the mode**:
207
+
- A2UI (forms/approvals/selection) — most common
208
+
-`--markdown` — reviewing a spec / PR description / draft; simpler than A2UI when the window is only about the doc
209
+
- URL — existing page (OAuth, external service)
210
+
- HTML via `agent://` — last resort for rich visuals that neither A2UI nor markdown can render
170
211
3.**Window size**: small forms 520×460, mid-size 620×580, full content 720×700. Tight height prevents dead space at the bottom.
Use for: spec review, PR description review, draft approval, any flow where the agent produced markdown and the human needs to read / comment on / edit it.
111
+
112
+
This is **not** A2UI JSONL — it's a separate mode. Pipe raw markdown on stdin.
- HTML in the markdown is sanitized by default. Pass `--allow-html` for trusted content only
155
+
108
156
## Template variables guide
109
157
110
158
When substituting into templates:
111
159
112
160
-**Titles**: 3-6 words, imperative or declarative. "Deploy Approval Required", "Choose a Base Branch".
113
161
-**Subtitles**: one sentence, ~10-15 words, give context.
114
-
-**Descriptions**: can be multi-paragraph but no markdown — plain text only (the renderer doesn't parse markdown).
162
+
-**Descriptions**: in a `Text` component, plain text only — `Text` does not parse markdown. If you need rendered markdown (headings, lists, code blocks, tables, links), use the `MarkdownDoc` component inside your A2UI form, or switch the whole window to `--markdown` mode.
0 commit comments