From spechtml
Create and edit human-readable instruction, explanation, review, and learning documents through Compact TOON, TOON patch, HTML, and Markdown. Use when the user wants LLM-friendly documents, TOON-based document normalization, HTML/Markdown generation from TOON, visible id-based document edits, or scripts/skills for a human-to-LLM document workflow.
How this skill is triggered — by the user, by Claude, or both
Slash command
/spechtml:spechtmlThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Use this skill to keep human-facing documents and LLM-facing inputs in sync.
examples/md-roundtrip-structural/01-row-add/after-edit.mdexamples/md-roundtrip-structural/01-row-add/before-edit.mdexamples/md-roundtrip-structural/01-row-add/patch.toonexamples/md-roundtrip-structural/01-row-add/rendered-after-patch.mdexamples/md-roundtrip-structural/01-row-add/source-after.toonexamples/md-roundtrip-structural/01-row-add/source-before.toonexamples/md-roundtrip-structural/02-row-remove/after-edit.mdexamples/md-roundtrip-structural/02-row-remove/before-edit.mdexamples/md-roundtrip-structural/02-row-remove/patch.toonexamples/md-roundtrip-structural/02-row-remove/rendered-after-patch.mdexamples/md-roundtrip-structural/02-row-remove/source-after.toonexamples/md-roundtrip-structural/02-row-remove/source-before.toonexamples/md-roundtrip-structural/03-section-add/after-edit.mdexamples/md-roundtrip-structural/03-section-add/before-edit.mdexamples/md-roundtrip-structural/03-section-add/patch.toonexamples/md-roundtrip-structural/03-section-add/rendered-after-patch.mdexamples/md-roundtrip-structural/03-section-add/source-after.toonexamples/md-roundtrip-structural/03-section-add/source-before.toonexamples/md-roundtrip-structural/README.mdexamples/md-roundtrip/README.mdUse this skill to keep human-facing documents and LLM-facing inputs in sync.
The human never runs commands. Write files and execute scripts yourself.
Memorize these abbreviations before generating any TOON.
| short | canonical | context |
|---|---|---|
t | title | doc, section, reqs, steps |
k | kind | doc |
p | priority | reqs |
s | status | reqs, decisions |
s | state | steps (timeline only) |
d | description | reqs |
cat | category | components |
rec | recommendation | decisions |
| code | canonical |
|---|---|
M | must |
S | should |
C | could |
A | accepted |
P | planned |
B | blocked |
D | done |
Important: s means status in reqs/decisions, but means state in steps/timeline. When ambiguity is possible, use the canonical form status or state.
Do not make HTML the source of truth.
Use Compact TOON for LLM exchange.
Use HTML/Markdown as human views.
Use TOON patch for edits.
When the user asks to create a document:
spechtml-v1 profile.docs/spec.compact.toon).node ${CLAUDE_SKILL_DIR}/runtime/dist/cli.bundle.js docs/spec.compact.toon dist/spec.html
dist/spec.html. Open it in a browser and let me know if you want to edit anything by its id number."The generated HTML has visible reference IDs (id10, id11, ...) on every section, block, and row. The human reads the HTML and can say:
id10 を初心者向けに書き直して
They never need to touch a terminal.
When the human asks for changes by visible id:
Read the generated HTML file and find the data-ref and data-path attributes:
<div data-ref="id10" data-stable-id="dd9ec098" data-path="/stack/components/name=Tokio">
The key field is data-path. For this id10, the path is /stack/components/name=Tokio.
meta:
pf: spechtml-patch-v1
v: 1
target: docs/spec.compact.toon
target_hash: sha256:<sha256 of docs/spec.compact.toon>
replace[1|]{path|value}:
/stack/components/name=Tokio/purpose|Rustの非同期処理を動かすための実行基盤
target_hash is required. Compute it from the current source file (e.g. Get-FileHash -Algorithm SHA256 on Windows, shasum -a 256 on POSIX). The applier will refuse the patch if the hash does not match.
Write it to docs/spec.patch.toon.
node ${CLAUDE_SKILL_DIR}/runtime/dist/apply-toon-patch.bundle.js docs/spec.compact.toon docs/spec.patch.toon
node ${CLAUDE_SKILL_DIR}/runtime/dist/cli.bundle.js docs/spec.compact.toon dist/spec.html
The patch is applied in-place. The applier overwrites the source file, so no third argument is accepted.
"Updated id10 in dist/spec.html. Refresh the page to see the change."
| Human says | Action |
|---|---|
| "id10 をもっと平易に" | replace the field at id10's data-path |
| "id10 の後に新しい項目を追加" | append to the table containing id10 |
| "id10 と id12 の間に新しい行を入れて" | insert with the index between id10 and id12 (v0.4) |
| "id10 を削除" | remove the row at id10's data-path |
| "id5 の優先度を must に" | replace the priority/status field |
| "新しいセクションを追加" | add_section with key, index, and body (v0.4) |
For any edit, always: write patch → apply in-place → re-render → notify human.
Templates exist as reference examples only. The primary workflow is to select blocks based on content.
Each block maps to a specific semantic need. Learn all of them.
| Block | TOON syntax | When to use | Example |
|---|---|---|---|
note | note: text | Short prose, background, summary, conclusion (1-3 sentences) | note: TOONは人間とLLMの中間表現として使うフォーマット。 |
prose | prose: text | Long-form explanation, narrative context | prose: この設計判断の背景には... |
metrics | metrics[N|]{label|value|caption}: | Key values, design targets, KPI summary | Throughput, SLA, team size |
reqs | reqs[N|]{id|p|s|t|d}: | Requirements, constraints, cautions, action items | R1|M|A|制約|理由 |
decisions | decisions[N|]{id|option|score|tradeoff|recommend}: | Options, tradeoffs, recommendations | D1|方式A|8|tradeoff|理由 |
components | components[N|]{name|cat|purpose|note}: | Concepts, parts, API elements, terms, catalog | Json<T>|extractor|用途|補足 |
steps | steps[N|]{step|state|detail}: | Ordered process, timeline, workflow, operation log | request到着|done|説明 |
nodes+edges | nodes[N|]{id|label|kind}: + edges[N|]{from|to|label}: | Flowchart, data flow, architecture diagram | kinds: input/process/output/event/decision |
notes | notes[N|]{file|line|concept|note}: | Code annotations, inline explanations | src/main.rs|42|handler|説明 |
snippets | snippets[N|]{lang|path|lines|code}: | Code examples with file reference and line numbers | rust|src/main.rs|1-10|fn main() { |
controls | controls[N|]{id|label|kind|min|max|step|value|options}: | Interactive sliders, toggles, selects | kinds: slider/toggle/select |
relations | relations[N|]{from|to|type}: | Cross-references between requirements, decisions, etc. | reqs/C1|decisions/D1|addresses |
What is the content?
Structured data (rows with consistent fields)?
→ Component/API list? → components
→ Requirements/constraints? → reqs
→ Options with tradeoffs? → decisions
→ Ordered steps/timeline? → steps
→ Code annotations? → notes
→ Cross-block references? → relations
Short text (1-3 sentences)?
→ note
Long text (paragraphs)?
→ prose
Key-value metrics?
→ metrics
Flow/diagram?
→ nodes + edges (Mermaid)
Code to display?
→ snippets (with path/lines/lang)
User-configurable parameters?
→ controls
These are patterns, not templates. Select blocks from the catalog above.
| Document type | Primary blocks | Secondary blocks |
|---|---|---|
| API specification | components, reqs, snippets | decisions, notes, metrics |
| Architecture Decision Record | decisions, prose, relations | reqs, metrics |
| Incident report | steps, metrics, prose | components, reqs |
| Learning material | prose, snippets, components | nodes+edges, notes, controls |
| Code review | reqs, notes, snippets | decisions, prose |
No document type requires all blocks. Use only what the content demands.
Do not force everything into tables.
Use:
note for short prose, background, summariescomponents, reqs, decisions, steps for structured contentnotes for code explanationsprose for narrative + inline code fences (v0.3.1+)file + lines) for long code instead of embedding full codeFor long code, prefer a file reference:
notes[1|]{file|line|concept|note}:
src/main.rs|42-58|handler|async fn handler(...) -> impl IntoResponse
prose (v0.3.1+)prose accepts triple-backtick fences. The HTML renderer turns them into <pre><code class="language-...">. Other Markdown syntax (bold, links, tables) is left as plain text.
Write prose as a \n-escaped quoted string (TOON SPEC v3 has no YAML-style block scalar). Example:
prose: "実装はこんな感じ。\n\n```python\ndef hello():\n print('hi')\n```\n\n以上。"
Render outputs:
<p>実装はこんな感じ。</p><pre><code class="language-python">def hello():\n print('hi')</code></pre><p>以上。</p>Use prose + fence for "narrative with code". Use snippets for "standalone code references" (the path / lines / lang metadata is preserved as a Copy-able block).
When team members want to edit the document via the Markdown view:
spec.md from spec.compact.toon with cli-md.bundle.jsspec.md to the repo, share with teamspec.md directly and commits the diffspec.compact.toon"pathapply-toon-patch.bundle.js applies the patch in place; target_hash rejects stale patchesDo not machine-reverse Markdown to TOON: spechtml-v1 metadata (reqs ids, decisions scores, relations) does not survive a generic md→toon parse. The LLM-mediated patch path is the safe one.
When the human says any of the trigger phrases below, the LLM must follow the 5 numbered steps in order. Do not improvise the procedure. A verified golden sample lives at plugin/skills/spechtml/examples/md-roundtrip/.
Extract the diff with the helper:
node ${CLAUDE_SKILL_DIR}/scripts/md-diff-helper.mjs <before.md> <after.md>
The output is JSON: { changes: [{ kind, before_line, after_line, context_before, before, after, context_after }, ...] }. Use context_before / context_after to map each change to a TOON section / block.
Map each change to a TOON path:
replace /section/prosereplace /section/prose (re-emit the whole prose string)append or insert on /section/<block>remove on /section/<block>/id=...add_sectionremove /<section_key>
If context_before / context_after do not uniquely identify a path, ask the human for clarification rather than guessing.Compute target_hash from the current TOON source:
node -e "import('node:crypto').then(c => import('node:fs').then(f => process.stdout.write('sha256:' + c.createHash('sha256').update(f.readFileSync('<source.toon>')).digest('hex'))))"
Write the patch.toon with all required meta fields and the chosen ops, then apply:
node ${CLAUDE_SKILL_DIR}/runtime/dist/apply-toon-patch.bundle.js <source.toon> <patch.toon>
If the applier rejects with Path segment does not exist, look at the Did you mean hint and retry with the corrected path.
Verify the round-trip:
node ${CLAUDE_SKILL_DIR}/runtime/dist/cli-md.bundle.js <source.toon> <re-rendered.md>
diff <after.md> <re-rendered.md>
Exit code 0 means the round-trip is lossless. Non-zero means structural / formatting differences exist; ask the human whether to accept or refine.
replace op on the whole /section/prose.replace of the entire block) rather than per-row ops.target_hash mismatch: the source has changed since the MD was generated. Refuse the patch, regenerate the MD, ask the team member to re-edit.If the procedure above is followed exactly, a verified-clean round-trip yields a diff of zero lines. Four golden samples ship with the plugin:
examples/md-roundtrip/ — prose-text edit (replace on /section/prose)examples/md-roundtrip-structural/01-row-add/ — table row added (append)examples/md-roundtrip-structural/02-row-remove/ — table row removed (remove)examples/md-roundtrip-structural/03-section-add/ — top-level section added (add_section)Any deviation from diff exit 0 indicates either an LLM judgement error or a structural change that the procedure deliberately surfaces to the human.
Wrong: Open dist/spec.html, edit text.
Right: Write a TOON patch, apply it in-place, re-render.
Why: HTML is not the source of truth. Edits to HTML will be lost on re-render.
Wrong: When the human says "fix id10", regenerate the entire TOON. Right: Write a 3-line patch targeting the specific data-path. Why: Full regeneration wastes tokens and risks unintended changes.
s abbreviationWrong: Writing s: D in a requirement row.
Right: For reqs/decisions, s = status (A/P/B/D). For steps, use canonical state.
Why: Context-dependent ambiguity causes validation errors.
meta.profileWrong: Starting a TOON document without meta: pf: spechtml-v1.
Right: Always include the meta block.
Why: The renderer may not recognize the compact format without it.
Wrong: "Run node src/cli.js ... to render."
Right: Execute the command yourself with the Bash tool.
Why: The human's role is to read output and give instructions, nothing else.
Before executing a render or patch:
/, uses / separators, row selectors use = (e.g., /section/table/name=Tokio)t not title, p not prio, s not state (in reqs context)replace[N|]{fields} — N must equal the number of rows that followapply-toon-patch.js output goes to the same file as sourceRead only what is needed:
references/profile-v1.md: Full abbreviation table, all standard block schemas.references/patch-format.md: TOON patch format, path rules, operation reference.references/workflow.md: End-to-end behavior for human/LLM document loops.All paths use ${CLAUDE_SKILL_DIR}/runtime/dist/. Execute them yourself — do not tell the human to run them. The runtime is shipped as standalone Node bundles, so no npm install or NODE_PATH is needed.
All input and output paths must be relative to the human's current working directory and must end in the expected extension (.toon for inputs, .html/.md for outputs). Paths that escape the working directory (.., absolute paths outside cwd) are rejected.
Validate a TOON file before rendering:
node ${CLAUDE_SKILL_DIR}/runtime/dist/validate-toon.bundle.js <input.toon>
Render Compact TOON to HTML:
node ${CLAUDE_SKILL_DIR}/runtime/dist/cli.bundle.js <input.toon> <output.html>
Render Compact TOON to Markdown:
node ${CLAUDE_SKILL_DIR}/runtime/dist/cli-md.bundle.js <input.toon> <output.md>
Apply a TOON patch (in-place — output goes back to the source file):
node ${CLAUDE_SKILL_DIR}/runtime/dist/apply-toon-patch.bundle.js <source.toon> <patch.toon>
The patch must declare meta.target (matching the source path's basename or relative form) and meta.target_hash (SHA-256 of the source file). The applier verifies both before writing.
Fetches up-to-date documentation from Context7 for libraries and frameworks like React, Next.js, Prisma. Use for setup questions, API references, and code examples.
Applies a firm's KYC/AML rules grid to parsed onboarding records: assigns risk rating, checks required documents, outputs rule outcomes with citations, and routes for escalation.
Generates daily or weekly digests of activity from connected sources (chat, email, docs, tasks, CRM), highlighting action items, decisions, mentions, and project updates.
npx claudepluginhub takahir-o/spechtml --plugin spechtml