--- name: repo-explainer description: 'Turn a codebase into a guided, interactive HTML tour: architecture map, step-through end-to-end flows with file:line citations, data model, and a "what changed and why" timeline of recent human and agent merges. Use when someone asks to explain, onboard onto, map, document, or catch up on a repository (backend, frontend, full-stack, mobile, library or CLI), or to show how a request flows end to end.' --- # Repo Explainer You produce **one self-contained HTML file** that teaches a repo the way Brilliant teaches math: one idea at a time, with interactive diagrams and a big Continue button. **You only write data.** The design, components, icons, animation and layout are finished and tested. Your job is to investigate the repo and fill `explainer.json` with true, cited facts. The CLI turns that into the page. `SKILL_DIR` below means the folder this file is in. Run the CLI with `node "$SKILL_DIR/bin/repo-explainer.mjs" ` (Node 18.3+, no install step). ## Workflow Copy this checklist into your todo list and work through it in order. 0. **(Optional) Check the cost.** `repo-explainer estimate ` prints a rough per-model cost for this repo's size. 1. **Scan.** Run `repo-explainer scan `. It gives you facts to verify, not conclusions: stack, entry points, route handlers, data files, env var *names*, scripts, and a suggested preset. 2. **Pick a preset.** Run `repo-explainer presets` and take the suggestion unless it is clearly wrong. Each preset fixes the layers, the chapter order, the flows you must trace and the questions you must answer. See `presets/.json`. 3. **Start the data file.** Run `repo-explainer init --preset --out /.explainer/explainer.json`. Every `TODO` in it is deliberate. 4. **Investigate.** Follow `references/investigation-playbook.md`. Read the entry points, then trace each `mustTrace` flow through the real code, one call at a time. Write down `file:line` as you go. 5. **Fill the data** using `references/data-schema.md`. Start each flow from a pattern: run `repo-explainer patterns`, then `repo-explainer patterns `, copy its steps, and rename its roles to your node ids. 6. **Draft the changes chapter.** Run `repo-explainer changes --data --write --since "14 days ago"`. Add `--merges` when the repo merges PRs, and `--remote https://github.com//` for links. Then replace each `why` TODO with the reason from the PR description, linked issue or commit body. If you cannot find a reason, say "No reason recorded". **Never invent one.** 7. **Build with file checks.** Run `repo-explainer build --repo --strict`. Fix every error and warning, since `--strict` fails on warnings too. `--repo` proves every cited path exists. 8. **Look at it.** Open the HTML (add `--open`, or use a browser tool). Click a node, step through every flow to the trophy, answer the quiz, and narrow the window to phone width. Fix the data, not the template. 9. **Hand off.** Report the output path, the flows you traced, and anything you could not verify. ## Brand and UX guardrails (non-negotiable) The look is a deliberate system: a Duolingo-style palette inside a Brilliant-style lesson flow. Consistency across every repo's explainer is the point, so treat these as hard rules: - **Do not edit** `template/`, `styles.css`, the icons, the tokens or the layout to make one explainer "fit". If something does not fit, change the data: shorter labels, fewer actors, a split flow. If the template is genuinely missing something, stop and say so. That is a template change for a maintainer and a separate PR. - **Do not add** CSS, `