Use when generating or updating Table of Contents in markdown files. Supports multiple files, glob patterns, configurable header levels, and various insertion modes. Triggered by "generate toc", "update toc", "table of contents", "add toc to markdown".
/plugin marketplace add Emasoft/ghe-marketplace/plugin install marketplace-utils@ghe-marketplaceThis skill inherits all available tools. When active, it can use any tool Claude has access to.
A universal TOC generator that works with any markdown file. Supports batch processing, configurable header levels, and smart insertion.
# Single file
python "${CLAUDE_PLUGIN_ROOT}/scripts/generate_toc.py" README.md
# Preview without changes
python "${CLAUDE_PLUGIN_ROOT}/scripts/generate_toc.py" --dry-run README.md
# All markdown files in docs/
python "${CLAUDE_PLUGIN_ROOT}/scripts/generate_toc.py" docs/*.md
# Recursive processing
python "${CLAUDE_PLUGIN_ROOT}/scripts/generate_toc.py" --recursive .
Note: You can also copy the script to your project and run it locally.
| Option | Default | Description |
|---|---|---|
--dry-run | false | Preview TOC without modifying files |
--min-level N | 2 | Minimum header level (1-6) |
--max-level N | 3 | Maximum header level (1-6) |
--title TEXT | "Table of Contents" | Custom TOC title |
--no-title | false | Omit TOC title |
--recursive, -r | false | Process .md files recursively |
--insert MODE | auto | Insertion mode: auto, top, marker |
--marker TEXT | <!-- TOC --> | Custom marker for marker mode |
Smart detection in this order:
## Table of Contents section--- separator (common README pattern)python scripts/generate_toc.py README.md
Insert at top of file, respecting YAML frontmatter:
python scripts/generate_toc.py --insert top README.md
Insert/replace between marker pairs:
python scripts/generate_toc.py --insert marker README.md
In your markdown file:
<!-- TOC -->
(TOC will be inserted/updated here)
<!-- /TOC -->
Custom markers:
python scripts/generate_toc.py --insert marker --marker "<!-- INDEX -->" README.md
Include only H2-H3 (default):
python scripts/generate_toc.py README.md
Include H1-H4:
python scripts/generate_toc.py --min-level 1 --max-level 4 README.md
Include only H2:
python scripts/generate_toc.py --min-level 2 --max-level 2 README.md
# All .md in current directory
python scripts/generate_toc.py *.md
# All .md in docs/
python scripts/generate_toc.py docs/*.md
# Specific pattern
python scripts/generate_toc.py docs/guide-*.md
# All .md files recursively
python scripts/generate_toc.py --recursive .
# Recursive in specific directory
python scripts/generate_toc.py --recursive docs/
python scripts/generate_toc.py README.md CONTRIBUTING.md docs/
## Table of Contents
- [Installation](#installation)
- [Usage](#usage)
- [Basic Usage](#basic-usage)
- [Advanced Usage](#advanced-usage)
- [Contributing](#contributing)
python scripts/generate_toc.py --no-title README.md
- [Installation](#installation)
- [Usage](#usage)
- [Basic Usage](#basic-usage)
python scripts/generate_toc.py --title "Contents" README.md
## Contents
- [Installation](#installation)
GitHub-compatible anchors:
**bold**, `code`)| Header | Anchor |
|---|---|
## Getting Started | #getting-started |
## **Bold** Header | #bold-header |
## Header with code`` | #header-with-code |
## Header #1 | #header-1 |
The script automatically skips:
--- markers)Always preview first with --dry-run:
python scripts/generate_toc.py --dry-run README.md
Output:
[INFO] Found 1 markdown file(s)
============================================================
File: README.md
============================================================
## Table of Contents
- [Installation](#installation)
- [Usage](#usage)
...
Found 15 headers (levels 2-3)
python scripts/generate_toc.py --recursive --dry-run .
# Review output, then:
python scripts/generate_toc.py --recursive .
# Add markers to files, then:
python scripts/generate_toc.py --insert marker --recursive docs/
# Deep TOC for main README
python scripts/generate_toc.py --max-level 4 README.md
# Shallow TOC for guides
python scripts/generate_toc.py --max-level 2 docs/guides/*.md
File may only have H1 headers. Use --min-level 1.
Use --insert marker with explicit markers for precise control.
Check for duplicate headers (GitHub appends -1, -2, etc.).
This script is fully portable:
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
This skill should be used when the user asks to "create a hookify rule", "write a hook rule", "configure hookify", "add a hookify rule", or needs guidance on hookify rule syntax and patterns.