agentleFS
yumeiriowlyumeiriowl/code-learn-skill/skills/code-walkthrough/SKILL.md

code-walkthrough

Skill1 starsChanged 4 months agoMITView on GitHub

Split source code into segments and generate a self-contained explanatory HTML that embeds the full code, commentary, SVG diagrams, and a glossary panel (multiple files are combined into a single HTML with tabs). Use it for "explain this code", "make a walkthrough", "create a code-explanation HTML/report", "make it readable with diagrams", and similar. When a source path is given and an explained HTML is wanted, use it even without an explicit instruction.

15 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

7 rules. 0 are common, 3 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 12 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    When the output destination is omitted, generate walkthrough-<a>-<b>[-...].html in the folder of the first file.

    line 24
  2. Distinctive:

    If even one file does not exist, exit with an error

    line 26
  3. Very specific:

    If the last argument ends in .html, separate it out as the output destination

    line 33
  4. Distinctive:

    If specified by argument, that path

    line 36
  5. Distinctive:

    Read each source file in full.

    line 39
  6. Very specific:

    When you diagram a processing flow with SVG, run the "SVG verification phase" in reference/svg.md every time you make a diagram, and …

    line 42
  7. Very specific:

    After generating, open it in the default browser matching the OS of the execution environment ($OUTPUT_PATH is the path to the output HTML):

    line 67

“Common” is measured: kept by at least 6 in 10 of the 12 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Code Walkthrough — Source Code Explanation HTML Generation Skill

Split source code from the top into processing units (segments), and generate a single self-contained interactive HTML that pairs the fully embedded code with detailed commentary, SVG diagrams, and a glossary panel.

For progressive loading, this skill splits the detailed spec into reference/. As shown in the table below, read the relevant file at the point you need it.

Usage

Arguments: source file paths (required, multiple allowed), output HTML path (optional). If the last argument ends in .html, treat it as the output destination.

Single file

Pass one source file. If an output destination is specified, generate there; if omitted, generate walkthrough-<filename>.html in the same folder as the source.

Multiple files (combined into a single HTML with tabs)

Passing two or more source files switches to multi-file mode, combining them into a single HTML with a tab-switching UI.

  • When the output destination is omitted, generate walkthrough-<a>-<b>[-...].html in the folder of the first file. If the combined name exceeds 80 characters, fall back to walkthrough-multi-<N>files.html
  • Each source file = one tab. The tab label is the base file name (without extension). When names collide, such as main.py, prefix the parent folder name (e.g., 08_rlm_real/main)
  • If even one file does not exist, exit with an error

Execution steps

  1. Parse the arguments:
    • Just one file → single-file mode
    • Two or more files → multi-file mode (see "Multi-file tab spec")
    • If the last argument ends in .html, separate it out as the output destination
  2. Confirm that all source files exist. If even one is missing, exit with an error.
  3. Determine the output destination:
    • If specified by argument, that path
    • Single file: walkthrough-<filename>.html (same folder as the source)
    • Multiple files: walkthrough-<a>-<b>[-...].html (folder of the first file; if too long, walkthrough-multi-<N>files.html)
  4. Read each source file in full.
  5. For each file, write the commentary following "Segment splitting rules" and "Structure of each segment". In environments where web search is available, when a library, API, or spec you use is new / your knowledge is stale / you are unsure, check the official docs before writing the commentary.
    • Identify "technical terms that even a general engineer would find hard to understand without specialized knowledge" appearing in the commentary, underline them with <span class="term"> following reference/glossary-panel.md, and register their overviews in GLOSSARY.
    • When you diagram a processing flow with SVG, run the "SVG verification phase" in reference/svg.md every time you make a diagram, and confirm that all arrows connect to their targets before moving on to the next segment.
  6. Assemble and output the HTML, starting from the bundled template:
    • Copy assets/template.html to the output path and fill its placeholders following reference/html-layout.md. The CSS/JS (layout, interactive features, glossary panel, tab switching) is already implemented in the template — do not rewrite it
    • Multiple files: additionally follow reference/multi-file-tabs.md
    • Register the glossary terms following reference/glossary-panel.md
    • When the output exceeds what can be written out at once (files over 500 lines / a large combined total across multiple files): generate and run gen_walkthrough.py under a temporary directory (/tmp, $TMPDIR, or on Windows %TEMP%, whichever path fits the environment) that fills the template and writes the HTML
  7. Open it in the browser with "Browser display command".

Reference (read when needed)

The detailed spec is split into reference/. Read the relevant file at the point it becomes needed within the execution steps.

Reference fileContentsWhen to read
reference/segments.mdSegment splitting rules, structure of each segment, checklist for code embedding/commentaryWhen splitting the code and writing commentary (execution step 5)
reference/svg.mdSVG diagram generation rules, CSS classes, SVG verification phase, checklistWhen diagramming a complex processing flow, after making the diagram (execution step 5)
reference/html-layout.mdHow to fill assets/template.html, segment markup, syntax highlighting, large-file handlingWhen assembling the HTML (execution step 6)
reference/multi-file-tabs.mdMulti-file tab spec (template steps, naming rules)When there are two or more sources (execution step 6, multi-file case)
reference/interactive.mdExpected behavior of the template's interactive featuresWhen verifying the output's UI behavior
reference/glossary-panel.mdTerm underlining and GLOSSARY registrationWhen underlining terms and registering the glossary (execution steps 5 and 6)

The template assets/template.html implements the page skeleton, CSS, and all interactive JS; the generated HTML must start from it rather than hand-written CSS/JS.

Browser display command

After generating, open it in the default browser matching the OS of the execution environment ($OUTPUT_PATH is the path to the output HTML):

  • macOS: open "$OUTPUT_PATH"
  • Linux: xdg-open "$OUTPUT_PATH"
  • WSL: cmd.exe /c start "" "$(wslpath -w "$OUTPUT_PATH")"
  • Windows (cmd): start "" "%OUTPUT_PATH%"
  • Windows (PowerShell): Start-Process "$OUTPUT_PATH"

To auto-detect in a POSIX shell:

if grep -qi microsoft /proc/version 2>/dev/null; then
  cmd.exe /c start "" "$(wslpath -w "$OUTPUT_PATH")" 2>/dev/null   # WSL
elif command -v open >/dev/null 2>&1; then
  open "$OUTPUT_PATH"                                              # macOS
elif command -v xdg-open >/dev/null 2>&1; then
  xdg-open "$OUTPUT_PATH"                                          # Linux
fi

Pre-completion check

Before outputting the HTML, review the "Checklist" at the end of each reference file corresponding to the features you used. At a minimum, always review reference/segments.md (code embedding, commentary), reference/html-layout.md (layout), and reference/glossary-panel.md (glossary panel). If you used SVG or multiple files, also review the checklists of reference/svg.md (that the SVG verification phase has been run) and reference/multi-file-tabs.md respectively.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.