Generates a self-contained interactive HTML file that teaches code from zero knowledge, with before/after toggles, Mermaid diagrams, step-through walkers, and playground widgets. Use for PR walkthroughs, subsystem explainers, or interactive code reviews.
Ships in code-walkthrough. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Produce ONE self-contained interactive HTML file that teaches code from zero prior knowledge: a change, or how existing code works. After a change explainer, the reader can review the change line by line: what each module does, why the seams are where they are, what the failure modes are, and what to scrutinize. After a code explainer, the reader can change the code safely: what each part does, how a request moves through the parts, and which invariants a change must keep.
The output is a teaching document, not a diff dump. Code is quoted verbatim; understanding is built in layers; interactivity does real pedagogical work (toggles for before/after, walkers for execution order, playgrounds for logic under study).
Aim for understanding over economy. Put the bottom line first, and write in ASD-STE100. The prose rules give the details.
Use this skill for every request for an explainer HTML file, also when another skill could write a page (show-me writes one focused visual; this skill writes the explainer). The related skills do parts of the pipeline.
Decide the kind from the request. "An explainer for this PR" is a change explainer. "An explainer of how X works" is a code explainer. Both use the same pipeline, template, prose rules, and browser checks. Only these parts differ:
| Change explainer | Code explainer | |
|---|---|---|
| Subject | a branch, PR, diff, or commit range | existing code: a subsystem, feature, mechanism, or flow |
| Refs (Phase 0) | before and after | the one commit that you read |
| 30-second version | what changes, why, and what the reviewer must check | what the code does, why it has this shape, and what a change must keep |
| Units (Phase 3, step 4) | one for each branch or module, with before/after toggles; a file that the change adds also gets a file tour | one for each component, in the order that a request reaches it; a toggle only compares with an earlier design or an alternative |
| Last section before the glossary (Phase 3, step 8) | reviewer checklist | "Before you change it": each invariant, the code that enforces it, and the test that guards it |
If the topic is not code in the repository (a protocol, or the design of a library), use the same pipeline. Take the facts from the source that the user names (a spec, the library's code, its documentation), and cite that source where the document would cite a ref.
Three rules control all prose in the document: body text, captions, callouts, walker steps, and glossary entries. Each rule has a different job. Rule 1 selects the content. Rule 2 sets the order. Rule 3 controls the words. Quoted code and quoted code comments stay verbatim, so these rules do not apply to them.
If a shorter text would be less clear, write the longer text. The reader does not know this domain or this codebase, so the reader cannot fill a gap. A step that you skip to save space is a step that the reader cannot make. Use one test for each section: after one read, can the reader explain it back? The length of the section is not the test.
the lookup table (resolver map), the record's ID (row uid)), and define each domain term in a short clause as well as in the glossary. The reader must not need the glossary to read a sentence.<details> with a one-sentence plain paraphrase. Prefer a domain word over a noun made from a code identifier, and write glossary headings as plain terms with the code name in brackets: job (task), attempt (retry slot), schedule (backoff policy).match, differ, refused, passes, fails) instead of unexplained jargon such as holds or breaks. Link each rule in a rules table to a concrete example.Understanding is not length. Some text adds words and removes understanding, so delete it:
This rule also applies to the work behind the document. Read the full function and its callers before you explain a hunk. An explanation of code that you only skimmed is short because it is shallow.
Put the conclusion first at each level. Put the support after it.
h2 a descriptive title that states the section's point in plain words (such as "The form now keeps the values the user chose"), and give the sidebar a separate short link label; avoid opaque numbered titles such as "1 · ". The first paragraph states the point in one to three sentences. The code, the diagrams, and the detail come after it.BLUF does not break the spiral order of Phase 3. A bottom line uses only plain words and terms that an earlier section taught. The section then teaches what its bottom line needs.
Use the STE rules. STE permits technical names, so code identifiers, file paths, and the domain terms in the glossary are correct words.
-ing forms, no double negatives, no idioms. Technical names are the exception.A style rule must not delete a fact. STE makes sentences shorter, not explanations. If an explanation needs 60 words, write three sentences of 20 words. If a rule and a fact conflict, keep the fact. Rule 3 serves rule 1, not the reverse.
Follow these phases in order. Phases 1–2 protect fidelity; phases 3–4 build the document; phase 5 proves it works.
gh pr view <n> --json number,url,headRefOid,baseRefName,files. Pin after to headRefOid; git fetch <remote> pull/<n>/head gets it, also for a PR from a fork. Pin before to git merge-base <remote>/<baseRefName> <headRefOid>. The PR's Files changed view compares with the merge base, so the Before line numbers then match its left side.main, before the change), check whether that branch has moved since in the files that the page quotes, keep those exact version names everywhere on the page, and never use the change's own name for an intermediate commit.Extraction parallelizes well; use subagents for independent units (one per branch/module/ring of context). Rules for every extractor:
git show <ref>:<path> / git diff <a>..<b> / git grep <pat> <ref>. Never check out branches, never modify files, never run the repo's test suite (respect host-repo constraints — e.g. shared test databases, single-runner rules).file.py:123) for every claim.Never bake agent output into the document unverified. Independently re-read every critical block yourself at the exact refs: the star functions, the before/after of the core change, anything surprising. Agent reports are leads, not facts — expect a couple of wrong or stale claims per batch and catch them here. If the doc will state a number (test counts, line counts, rows that the code selects), count it yourself. When the count comes from a query, check that the query's filter is the same predicate as the code's. A filter with one of the code's two conditions can count four times the rows that the code selects.
Load the statechart skill. Model the code with the rules that the reader cares about, and check the model with TLC: before and after for a change explainer, the code as it is for a code explainer. Replay each bug path against the real code, and label it reproduced or model only. Model each proposed fix, each alternative, and each simpler design, and check each with the same rules. A claim that a fix or a design works needs the report of its run. references/state-models.md gives the steps.
Order the document so each section only needs what came before:
A code explainer keeps this order, with the changes in Two kinds of explainer.
Write each mechanism or per-unit walkthrough section in this order (short structural sections such as Scope boundaries, Reviewer checklist, and Glossary keep their compact structure instead of adding empty tables):
<h2> title — state the section's point in plain words, with a separate short label in the sidebar."Read the highlighted lines like this" explaining what each highlighted line decides.Sections that explain a mechanism quote only the slice of code that they need, so no section reads a new file in order. A reviewer needs that read. For each file that the change adds:
<details>..lbl): each note names the lines it explains and links to the mechanism section that teaches them in depth.Keep the mechanism sections. The tour is the linear read, and it links into them. When the mechanism sections are long, the tour can be its own page in a series (see Scaling notes).
Write every fragment to the prose rules. Write the document as fragment files, then concatenate in order. This keeps a 1500-line file editable and lets you fix one section without rewriting all of it. Copy references/template-shell.html — it contains the full CSS theme and the JS for every component below, with <!-- @SLOT --> markers showing where content goes.
Component library (all wired in the template; use them, don't reinvent):
| Component | Use for |
|---|---|
| Sidebar TOC + scrollspy | navigation in long docs (short sidebar labels pointing to descriptive <h2> section headings) |
| Before/after tab toggles | every meaningful diff — reader flips between base and tip |
Diff-colored lines (.cl.add/.cl.del/.cl.hl) | real diffs (add/del) and attention (hl = not a diff!) |
| Line numbers (on by default) | every quoted block: data-start on the <code>, a .cl.gap line for each elision, data-old-start/data-new-start for a unified diff |
Line-keyed note list (.lbl) | the notes under each chunk of a file tour |
| Source links (when the code is on GitHub) | the #walkthrough-source block (repository, PR, base and head SHAs, optional extra refs, the PR's files) and data-path on each quoted block; the JS links each block's line range at the pinned commit and in the PR's Files changed view, and each .ln range |
Syntax highlighting (<code class="language-python">) | every code block — highlight.js colours the tokens and keeps the per-line diff/walker classes |
Collapsible <details> deep-dives | side context, raw TLA+ spec snippets (with a one-sentence paraphrase), run folder names, and full listings that would interrupt the spiral |
| Step-through walker | execution-ordered code (a write path, a state machine) — steps highlight line ranges |
| Mermaid diagrams | chain maps, ER diagrams, dependency graphs, sequence diagrams, state transitions |
Callouts (.note/.warn/.key) | the one idea per section the reader must not miss |
Glossary-linked <dfn> | domain terms in plain words with the code name in brackets (job (task)), clickable to the glossary |
| Light/dark theme | follows the OS until the reader toggles (then persisted); set before first paint; code tokens and diagrams re-theme too |
| Playground widgets | mirror the logic under study in JS (a validator the reader can throw inputs at, a scheduler that shows race outcomes) — the strongest teaching tool when the domain allows |
Statechart (.mermaid[data-statechart]) | a chart.mmd from the statechart command, pasted verbatim; its marks (breaks, mayBreak, bugPath, repeats) and group colours follow the theme |
Chart walker (data-chartwalk) | a walk through a statechart: one normal run, then each bug path in the report's numbering; each step highlights its state and scrolls it into view |
Breakdown card (.rulecard) and chips (.chip) | one card for each broken rule: plain-English title, the rule in plain words, folded TLA+ spec in <details>, its path, why, how likely, and a toggle of fixes with plain status chips (fails in model, passes in model, match, differ, refused) |
| Design comparison | a before/after toggle of statecharts paired with a one-axis table (rows = code versions, columns = plain questions, bottom line above the table) |
Fidelity rules:
<= → <=); run the balance check in phase 5 to catch what you missed.add/del colors only for lines that are actually added/removed in the diff; use hl for emphasis elsewhere.@@ -a,b +c,d @@). An elision line gets no number..lbl notes are the exception: they sit under the chunk that they number.#walkthrough-source block once. Put data-path on every quoted block, and data-ref="base" on each Before pane. The JS builds each link from the block's line numbers, so the link always covers the lines that the block shows. Do not write these URLs by hand. Use the same block for a code explainer of code on GitHub, without pr, files and base. When quoting an intermediate pushed commit named in the Versions key, add "refs": {"<key>": "<full SHA>"} to #walkthrough-source and set data-ref="<key>" on that block (the JS links to that commit without a PR diff link); leave data-path off unpushed alternatives or proposed designs.data-path. Link its source in the caption.language-<name> (a highlight.js name or alias: python, ts, tsx, go, sql, ...) on every code block's <code>. Keep lines plain text — no +/- prefixes, no spans inside a .cl line; a line with markup in it opts its whole block out of highlighting.style X fill:#…, coloured classDef): they break in one of the two themes. Mark the node the reader should look at with class NodeId current. For sequence diagrams and multi-actor flows, give participants plain names with the code name on a second line (participant R as Request router<br/>router.py), wrap long edge labels with <br/>, and tune actorMargin or width in an %%{init}%% block when needed so rendered text stays legible.chart.mmd into a .mermaid[data-statechart] unchanged; never draw or edit a statechart by hand. Its classDef colours do not break the colour rule above: the template drops them. A bug path uses the report's numbering and words. A verdict chip (.chip.breaks, .chip.may, .chip.holds) uses plain status words and needs a report in the fragments folder, and a replay chip (.chip.repro, .chip.model) names the test or the command. A TLA+ block uses language-plaintext, because highlight.js has no TLA+ grammar.mermaid-cli skill before it goes into a fragment: mmdc -i diagram.mmd -o diagram.svg exits 1 and prints the parse error with its line. In the page, a syntax error shows only as an error graphic.href="#…" resolves; check tab buttons match panes; count mermaid blocks.
data-start (or the diff pair), and every .cl line that is not a .gap has a data-n after load.data-n of each chunk with git show <ref>:<path> | wc -l.def, its class, or its first decorator. A range that starts on another test's decorator is a wrong range.pre, code and .lbl for lines? \d+. Each hit is a number that the next re-pin will leave stale.data-path.gh pr view <n> --json headRefOid still equals the pinned head. If the PR moved, re-pin.git show <sha>:<path>. The commit is the base for a data-ref="base" block and for a removed line in a unified diff, the matching entry in refs for any other data-ref, and the head for all other lines. A link is correct only when the quoted text is on the lines that it opens. Each difference must be a marked condensation.python3 -m http.server 0 --bind 127.0.0.1, then read the port; a fixed port can hit a stale server and check its 404 page) and drive a headless browser (the Playwright MCP tools, or the playwright, dev-browser, or chrome-cdp skill):
.mermaid contains an svg (count them), and no svg has aria-roledescription="error". Mermaid draws a syntax error as an SVG that reads "Syntax error in text", so the count alone passes a broken diagram. mmdc runs its own mermaid version, and the template loads mermaid 10.9.3, so newer syntax can pass mmdc and still fail here..mermaid svg, compute svg.getBoundingClientRect().width / (svg.viewBox.baseVal.width || parseFloat(svg.style.maxWidth) || svg.getBoundingClientRect().width). Under about 0.6, wrap labels with <br/>, set actorMargin and width in an %%{init}%% block, use fewer participants, or use plain participant names with the code name on a second line.img, compute img.getBoundingClientRect().width / img.naturalWidth. Under about 0.85, crop the image to the part that matters or show it larger.code[class*=language-] block contains .hljs-* spans and still has its original number of .cl linesdata-lines, not from a hard-coded number, so that a re-pin does not break the checkcw-on, it is the state that data-node names, and it is inside the chart pane<details>: they are not clickable until it opensL<a>-L<b> link matches its first and last data-n, and a block whose file is in files also has a PR #<n> link. Open one link of each kind and look at the highlighted linesscrollWidth equals clientWidth), figure elements have no horizontal margins shrinking images, and each walker's "next" button is inside its cardsvg ids) and re-check readability of diagrams and codeevaluate (set input, assert verdict output)…/languages/<name>.min.js means a language- name highlight.js does not know)locator.screenshot()): a page screenshot clipped to coordinates fails for an element below the fold.rule card, hand-off, run folder names, raw spec operators) appear in body prose, and no sentence uses a term before the document defines itp, li, .wstep, summary, and captions; skip pre and code). Treat 25 words as advisory: split long sentences when they stay clear, and keep a longer sentence when splitting would separate a cause from its effect.Deliver the single HTML file at the requested path. The deliverable is the local file; publish it as an Artifact only when the user asks for a link. Once the user has asked for a link, publish again to the same URL after each rebuild that passes Phase 5. Keep the fragments directory (mention it — it is how the user iterates). Note the two external dependencies (mermaid and highlight.js, both from the jsDelivr CDN) and that offline the document degrades to plain code and readable diagram source. If the user is currently reading an earlier document, write a NEW file and cross-link; never edit a file the user has open.
Load each one at the phase that needs it:
| Skill | Phase | Job |
|---|---|---|
mermaid-cli | 4 | Validate each diagram's source with mmdc before it goes into a fragment. |
statechart | 2b, 4 | Check a TLA+ model of the code's states with TLC, and write the chart.mmd and report.md that the state-model sections show. |
spock | 2b | Model, inductively prove (spock prove), and trace-check stateful protocols in statically typed .spock when TLA+ + Mermaid statecharts are not needed. |
Playwright MCP tools, playwright, dev-browser, or chrome-cdp | 5 | Serve the page, run the render checks, and take the light and dark screenshots. |
dataviz, when it is available | 4 | Draw a chart (numbers over time or across categories) as inline SVG that uses the page's colour variables, so it follows the theme. |
show-me | — | A quick visual in the chat or one focused page. It sends a request for an explainer file to this skill. |
mermaid.initialize({startOnLoad: true}) silently never renders when the import resolves after the load event. Use startOnLoad: false + explicit await mermaid.run({querySelector: ".mermaid"}), with a fallback that swaps diagrams for their (readable) source text if the CDN is unreachable.base theme with themeVariables read from the page's CSS colours, and re-renders every diagram when the theme changes. It renders off-screen and swaps the SVG in, because rendering in place shows raw source mid-render, and a diagram inside a hidden tab or closed <details> lays out broken (clipped notes, missing actor boxes).hljs.highlightElement and similar re-read textContent and replace the block, destroying the .cl line spans that carry diff colours and walker line numbers. The template highlights the joined text and splits the HTML back onto the lines, closing and re-opening any span (a multi-line string or comment) that crosses a newline.pwd after hopping between repos.order_by vs in-Python sort (and similar framework subtleties): when the code comments explain a non-obvious choice, quote the comment — it is usually the reason the reader was confused.difflib line map from the old file to the new one is wrong for a range that starts on a line that repeats, such as the decorator above every test: the range moves onto another test. Find each quoted function or test again by its name in the new file, then run the "quoted ranges start where they claim" check.243 → 245 and then the new 245 → 247. Remap in one pass with a lookup table.class NodeId current).#walkthrough-source block, and every number that the prose states in one list of facts named by meaning, and fill them in when the fragments are assembled. Give two quantities two names even when they are equal today: a later commit can change one and not the other. Let a widget read its "decided at" line numbers from the same assembly step, not from constants in its JS.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Mermaid, HTML, CSS, JavaScript
/code-walkthrough:code-walkthroughfrom code-walkthrough
npx claudepluginhub dashed/claude-marketplace --plugin code-walkthroughOther plugins' skills for the same job