Code Explainer
Builds explanation-first repository explainers from local folders or GitHub URLs.
What Good Output Looks Like
A good run must do all of the following:
- Explain what the repository does in plain language.
- Name real entrypoints, modules, docs, and flow steps from the repository.
- Tell the reader where to start and where change risk lives.
- Produce diagrams that answer specific onboarding questions.
- Emit proof artifacts showing whether the explanation is actually useful.
This skill should fail quality gates if the output is generic, vague, or weakly grounded.
Output Model
overview/OVERVIEW.md for the plain-language explanation.
deep/*.md for architecture, modules, flows, dependencies, and glossary.
diagrams/*.mmd plus rendered diagrams/svg/*.svg and diagrams/png/*.png.
diagrams/excalidraw/*.excalidraw.json plus mirrored preview assets under diagrams/excalidraw/svg/*.svg and diagrams/excalidraw/png/*.png.
meta/explanation_plan.json describing the intended narrative.
meta/explanation_quality.json scoring clarity, specificity, grounding, usefulness, diagram usefulness, and honesty.
meta/excalidraw_report.json proving whether editable Excalidraw scenes were created or why that export was blocked.
meta/*.json for indexing, verification, confidence, attribution, and quality reports.
See references/output-contract.md for exact artifacts and references/evaluation-rubric.md for the passing bar.
Command
Run from this skill directory:
python scripts/analyze.py analyze \
--source <local_path_or_github_url> \
--output <output_dir> \
--mode <quick|standard|deep> \
--format <markdown|html|both> \
--explainer-type <onboarding|project-recap|plan-review|diff-review> \
--audience <nontech|mixed|engineering> \
--overview-length <short|medium|long> \
--since <time_window> \
--git-ref <ref> \
--plan-file <path> \
--include-glob <pattern> \
--exclude-glob <pattern> \
--enable-llm-descriptions <true|false> \
--enable-excalidraw-export <true|false> \
--enable-official-excalidraw-bridge <true|false> \
--ask-before-llm-use <true|false> \
--prompt-for-llm-key <true|false> \
--persist-llm-key <ask|true|false> \
--enable-web-enrichment <true|false>
Defaults:
mode=standard
format=markdown
explainer-type=onboarding
audience=nontech
overview-length=medium
enable-llm-descriptions=true
enable-excalidraw-export=true
enable-official-excalidraw-bridge=false
ask-before-llm-use=false
prompt-for-llm-key=true
persist-llm-key=ask
enable-web-enrichment=true
LLM Behavior
- The high-quality path is explanation-first and uses
scripts/llm_describe.py.
- The LLM path is the required production path for this skill.
- If
CODE_EXPLAINER_LLM_API_KEY or OPENAI_API_KEY is set, the skill can use a live model.
- If no key is available, the skill should prompt for one when the terminal is interactive.
- The user can choose to persist the provided key in a local
.env file for future runs.
CODE_EXPLAINER_MOCK_LLM=true is only for explicit development or offline test scenarios and is not the normal production path.
Workflow
- Normalize the source and build a repository index.
- Detect stack, entrypoints, dependencies, flows, and documentation coverage.
- Build
explanation_plan.json with top modules, audience starting points, diagram purposes, and caveats.
- Generate the narrative layer with LLM or grounded mock/deterministic fallback.
- Build focused diagrams tied to onboarding questions.
- Export those diagrams into editable Excalidraw scenes through the deterministic local exporter.
- Optionally prefer the official Excalidraw bridge only when explicitly enabled for development experiments.
- Generate overview and deep docs from the explanation plan plus narrative layer.
- Run fact-check and explanation-quality evaluation.
- Fail the run if quality gates do not clear the rubric.
Proof Path
Run the shipped self-audit:
python scripts/self_audit.py
This runs the skill on fixture repositories in assets/fixtures/, uses the grounded mock explainer path, and writes proof artifacts under .audit_tmp/code-explainer-self/.
Dependencies
Required:
- Python
3.10+
- Node.js
18+ + npm
- Git when
--source is a GitHub URL
Recommended:
- Mermaid CLI (
mmdc) from @mermaid-js/mermaid-cli for higher-fidelity diagram rendering
- Node.js is only required for GitHub cloning and optional development-time Excalidraw bridge experiments
Install dependencies:
powershell -ExecutionPolicy Bypass -File .\scripts\install_runtime.ps1
or
bash ./scripts/install_runtime.sh
Notes
- This skill does not mutate the analyzed repository.
- The skill may create or update a local
.env file in the skill directory when the user chooses to persist the prompted LLM key.
- If the explanation-quality score is below the rubric threshold, treat the output as failed even if files were produced.
- If Excalidraw export is enabled, treat missing or partial editable scene generation as a real quality issue, not a cosmetic extra.
- The deterministic local Excalidraw exporter is the canonical production path.
- The official
@excalidraw/mermaid-to-excalidraw bridge is opt-in only via --enable-official-excalidraw-bridge true and should be treated as a development experiment, not a required runtime dependency.
- Use include/exclude globs to narrow analysis when the repository is very large or noisy.
References
references/output-contract.md
references/diagram-style-guide.md
references/persona-writing-guide.md
references/mode-behavior.md
references/evaluation-rubric.md
1---2name: code-explainer3description: Analyze a local codebase folder or GitHub repository URL and generate a grounded onboarding explainer with clear markdown docs, focused Mermaid/SVG/PNG diagrams, evidence anchors, and explanation-quality scoring. Use when users need a codebase explained in simple, concrete language for PM/design/new engineer onboarding.4---56# Code Explainer78Builds explanation-first repository explainers from local folders or GitHub URLs.910## What Good Output Looks Like1112A good run must do all of the following:13141. Explain what the repository does in plain language.152. Name real entrypoints, modules, docs, and flow steps from the repository.163. Tell the reader where to start and where change risk lives.174. Produce diagrams that answer specific onboarding questions.185. Emit proof artifacts showing whether the explanation is actually useful.1920This skill should fail quality gates if the output is generic, vague, or weakly grounded.2122## Output Model23241. `overview/OVERVIEW.md` for the plain-language explanation.252. `deep/*.md` for architecture, modules, flows, dependencies, and glossary.263. `diagrams/*.mmd` plus rendered `diagrams/svg/*.svg` and `diagrams/png/*.png`.274. `diagrams/excalidraw/*.excalidraw.json` plus mirrored preview assets under `diagrams/excalidraw/svg/*.svg` and `diagrams/excalidraw/png/*.png`.285. `meta/explanation_plan.json` describing the intended narrative.296. `meta/explanation_quality.json` scoring clarity, specificity, grounding, usefulness, diagram usefulness, and honesty.307. `meta/excalidraw_report.json` proving whether editable Excalidraw scenes were created or why that export was blocked.318. `meta/*.json` for indexing, verification, confidence, attribution, and quality reports.3233See `references/output-contract.md` for exact artifacts and `references/evaluation-rubric.md` for the passing bar.3435## Command3637Run from this skill directory:3839```bash40python scripts/analyze.py analyze \41 --source <local_path_or_github_url> \42 --output <output_dir> \43 --mode <quick|standard|deep> \44 --format <markdown|html|both> \45 --explainer-type <onboarding|project-recap|plan-review|diff-review> \46 --audience <nontech|mixed|engineering> \47 --overview-length <short|medium|long> \48 --since <time_window> \49 --git-ref <ref> \50 --plan-file <path> \51 --include-glob <pattern> \52 --exclude-glob <pattern> \53 --enable-llm-descriptions <true|false> \54 --enable-excalidraw-export <true|false> \55 --enable-official-excalidraw-bridge <true|false> \56 --ask-before-llm-use <true|false> \57 --prompt-for-llm-key <true|false> \58 --persist-llm-key <ask|true|false> \59 --enable-web-enrichment <true|false>60```6162Defaults:6364- `mode=standard`65- `format=markdown`66- `explainer-type=onboarding`67- `audience=nontech`68- `overview-length=medium`69- `enable-llm-descriptions=true`70- `enable-excalidraw-export=true`71- `enable-official-excalidraw-bridge=false`72- `ask-before-llm-use=false`73- `prompt-for-llm-key=true`74- `persist-llm-key=ask`75- `enable-web-enrichment=true`7677## LLM Behavior7879- The high-quality path is explanation-first and uses `scripts/llm_describe.py`.80- The LLM path is the required production path for this skill.81- If `CODE_EXPLAINER_LLM_API_KEY` or `OPENAI_API_KEY` is set, the skill can use a live model.82- If no key is available, the skill should prompt for one when the terminal is interactive.83- The user can choose to persist the provided key in a local `.env` file for future runs.84- `CODE_EXPLAINER_MOCK_LLM=true` is only for explicit development or offline test scenarios and is not the normal production path.8586## Workflow87881. Normalize the source and build a repository index.892. Detect stack, entrypoints, dependencies, flows, and documentation coverage.903. Build `explanation_plan.json` with top modules, audience starting points, diagram purposes, and caveats.914. Generate the narrative layer with LLM or grounded mock/deterministic fallback.925. Build focused diagrams tied to onboarding questions.936. Export those diagrams into editable Excalidraw scenes through the deterministic local exporter.947. Optionally prefer the official Excalidraw bridge only when explicitly enabled for development experiments.958. Generate overview and deep docs from the explanation plan plus narrative layer.969. Run fact-check and explanation-quality evaluation.9710. Fail the run if quality gates do not clear the rubric.9899## Proof Path100101Run the shipped self-audit:102103```bash104python scripts/self_audit.py105```106107This runs the skill on fixture repositories in `assets/fixtures/`, uses the grounded mock explainer path, and writes proof artifacts under `.audit_tmp/code-explainer-self/`.108109## Dependencies110111Required:112113- Python `3.10+`114- Node.js `18+` + npm115- Git when `--source` is a GitHub URL116117Recommended:118119- Mermaid CLI (`mmdc`) from `@mermaid-js/mermaid-cli` for higher-fidelity diagram rendering120- Node.js is only required for GitHub cloning and optional development-time Excalidraw bridge experiments121122Install dependencies:123124```powershell125powershell -ExecutionPolicy Bypass -File .\scripts\install_runtime.ps1126```127128or129130```bash131bash ./scripts/install_runtime.sh132```133134## Notes135136- This skill does not mutate the analyzed repository.137- The skill may create or update a local `.env` file in the skill directory when the user chooses to persist the prompted LLM key.138- If the explanation-quality score is below the rubric threshold, treat the output as failed even if files were produced.139- If Excalidraw export is enabled, treat missing or partial editable scene generation as a real quality issue, not a cosmetic extra.140- The deterministic local Excalidraw exporter is the canonical production path.141- The official `@excalidraw/mermaid-to-excalidraw` bridge is opt-in only via `--enable-official-excalidraw-bridge true` and should be treated as a development experiment, not a required runtime dependency.142- Use include/exclude globs to narrow analysis when the repository is very large or noisy.143144## References145146- `references/output-contract.md`147- `references/diagram-style-guide.md`148- `references/persona-writing-guide.md`149- `references/mode-behavior.md`150- `references/evaluation-rubric.md`