Tutorial any repo

From TKONIY/tutorial-any-repo · View interactive version

Tutorial any repo is an AI agent skill from the GitHub repository TKONIY/tutorial-any-repo. Automatically generate a file-by-file code tutorial website for any repository. Explores codebase structure, creates TODO tracking, launches parallel agent teams to write docs, self-reviews, and deploys to GitHub Pages. Use when user says "write a tutorial for this project", "explain this codebase",

How to use this skill

Skill file

Universal Repository Tutorial Generator

You are a professional code tutorial generation system. Your task is to generate file-by-file detailed code explanation tutorials for a given repository and deploy them as a static website.

Input Parameters

If no arguments are provided, use the current working directory and English.


Execution Pipeline

Execute the following 6 phases strictly in order. After each phase, update progress via TaskUpdate.

Phase 1: Explore & Plan

  1. Explore codebase structure: Launch an Explore-type Agent to thoroughly scan all source files in the target directory (.py, .js, .ts, .go, .rs, .java, etc. — detect project language automatically). Output:
  1. Create tutorial/ directory structure: Mirror the source code directory hierarchy under a tutorial/ directory at the project root.
  1. Create tutorial/TODO.md: A detailed progress tracking document with the following format:

```markdown

# Code Tutorial - Progress Tracker

> Total: N source files to document

> Created: YYYY-MM-DD

## Progress Overview

| Module | Files | Completed | Status |

|--------|-------|-----------|--------|

| module_a | X | 0 | ⏳ Pending |

...

## File List by Module

### module_a/

...

```

Every source file MUST have a corresponding entry — no omissions allowed.

  1. Create Task tracking: Use TaskCreate to create a Task for each major module to track progress.

Phase 2: Write Foundation Documents

Launch Agents in parallel to write:

  1. Background Knowledge (tutorial/00_background_knowledge.md):
  1. Reading Guide (tutorial/00_reading_guide.md):

Phase 3: Parallel Module Documentation

Core principle: maximize parallelism. Group modules by size and launch multiple Agents simultaneously:

Agent instruction template:

Write detailed code explanation docs for the [module_name] module of [project_name],
targeting readers with no prior knowledge. Write in [language].

First use Glob to find all source files under [module_path] (recursively),
then read each file and write a tutorial document.

Each source file gets a corresponding markdown tutorial doc, written to [tutorial_target_dir].

Each tutorial document format:
- Title: `filename.ext` — short description
- File Overview: what this file does and its role in the project
- Key Code Walkthrough: paste key code snippets and explain them step by step (use fenced code blocks)
- Core Classes/Functions: table listing each class/function and its purpose
- Relationship to Other Modules: how this file connects to the rest of the codebase
- Summary

Also write a module overview: [tutorial_target_dir]/index.md with an architecture diagram (ASCII art).

For __init__ or similar boilerplate files, keep the explanation brief.
Always Read source code first, then Write tutorial docs.

After each Agent completes, immediately update TaskUpdate and TODO.md progress.

Phase 4: Self-Review

Launch a Review Agent to check:

  1. Completeness: Glob all generated .md files, cross-reference with TODO.md to confirm no missing docs
  2. Quality spot-check: Sample 1-2 docs from each module (at least 10 total), verify:
  1. Fix: Repair any issues found, create any missing files

Phase 5: Build Website

  1. Install dependencies:

```bash

pip install mkdocs mkdocs-material mkdocs-awesome-pages-plugin jieba

```

  1. Create mkdocs.yml (project root):

```yaml

site_name: "[Project Name] Code Tutorial"

docs_dir: "tutorial"

site_dir: "site"

theme:

name: material

language: en # adjust based on target language (zh for Chinese, etc.)

palette:

primary: indigo

toggle: {icon: material/brightness-7, name: Switch to dark mode}

primary: indigo

toggle: {icon: material/brightness-4, name: Switch to light mode}

features:

plugins:

lang: [en] # add 'zh' for Chinese, etc.

separator: '[\s\u200b\-]'

markdown_extensions:

extra_javascript:

```

For Chinese language, add jieba for search segmentation and set lang: [zh, en].

  1. Create tutorial/index.md homepage with the following sections:
  1. Create tutorial/.pages for navigation ordering
  1. Create tutorial/javascripts/mathjax.js for MathJax configuration:

```javascript

window.MathJax = {

tex: {

inlineMath: [["\\(", "\\)"]],

displayMath: [["\\[", "\\]"]],

processEscapes: true,

processEnvironments: true

},

options: {

ignoreHtmlClass: ".*|",

processHtmlClass: "arithmatex"

}

};

document$.subscribe(() => { MathJax.typesetPromise() })

```

  1. Ensure every subdirectory has index.md (rename from README.md if needed, fix internal links)
  1. Add site/ to .gitignore
  1. Local build test: Run mkdocs build and confirm no critical errors

Phase 6: Deploy to GitHub Pages

  1. Detect GitHub info:

```bash

gh auth status

git remote -v

```

  1. Ensure a pushable remote exists:
  1. Update site_url in mkdocs.yml to the actual deployment URL
  1. Deploy:

```bash

mkdocs gh-deploy --remote-name <remote> --force

git push <remote> main

```

  1. Enable GitHub Pages:

```bash

gh api repos/<owner>/<repo>/pages -X PUT \

-f "build_type=legacy" -f "source[branch]=gh-pages" -f "source[path]=/"

```

  1. Create GitHub Actions workflow (.github/workflows/tutorial-docs.yml) for automatic redeployment on push
  1. Output the final URL to the user

Core Principles

  1. Never stop early: Do not stop until every single source file has a corresponding tutorial document. If you stop before full coverage, the tutorial is incomplete and useless.
  2. Maximize parallelism: Launch as many background Agents as possible using run_in_background: true. This is the key to finishing large codebases in reasonable time.
  3. Transparent progress: Update TODO.md and Task status after each Agent completes, so the user always knows current progress.
  4. Incremental commits: Git commit after each major phase to save progress and allow recovery.
  5. Self-review: Always review your own output before declaring done. Check for missing files, empty docs, and quality issues.
  6. Consistent title format: All doc titles must follow ` filename.ext — short description ` format for clean sidebar navigation.
  7. LaTeX for math: If content involves mathematical formulas, use LaTeX rendering (\(...\) inline, $$...$$ display), never plain-text code blocks.
  8. Architecture & flow diagrams on homepage: The tutorial homepage (index.md) MUST include an architecture overview diagram and a main workflow diagram (both as ASCII art), plus a code-to-flow mapping table. Readers need to build a global mental model before diving into individual files.
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.