markdown-toc

Generate or update Markdown Table of Contents with configurable header levels.

4|Updated Dec 3, 2025
One-click install
npx skills add https://github.com/Emasoft/ghe-marketplace --skill markdown-toc
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: markdown-toc
Source: https://github.com/Emasoft/ghe-marketplace/tree/main/plugins/marketplace-utils/skills/markdown-toc
Command: npx skills add https://github.com/Emasoft/ghe-marketplace --skill markdown-toc

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

Use when generating or updating Table of Contents in markdown files. Supports multiple files, glob patterns, configurable header levels, and various insertion modes.

Core Features & Use Cases

  • Batch TOC generation: Process multiple Markdown files with globs
  • Insertion modes: Auto, top, or marker-based insertion
  • Header level control: Include specified levels (e.g., H2-H3)

Quick Start

python "${CLAUDE_PLUGIN_ROOT}/scripts/generate_toc.py" README.md

Frequently Asked Questions about markdown-toc

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate a table of contents for my markdown files?

Generate a table of contents by running the script on your Markdown file. The Skill automatically creates a TOC with GitHub-compatible anchors, detects header levels, skips code blocks, and preserves YAML frontmatter. Use insertion modes like auto, top, or marker-based placement to control where the TOC appears.

Can I update table of contents across multiple markdown files at once?

Yes, the Skill supports batch processing using glob patterns and recursive directory scanning. Process entire projects or targeted file sets in a single run, with configurable header level ranges to control which headers are included in each file's TOC.

What markdown header levels can I include in the table of contents?

You can configure which header levels to include in your TOC. The Skill lets you specify a range—for example, H2 through H3—so you control the depth and granularity of your generated table of contents.

How do I preview changes before updating my markdown files?

Use the dry-run mode to preview the generated table of contents before it's inserted into your files. This lets you verify the TOC structure, anchor generation, and insertion placement without modifying your Markdown documents.

Does the tool work with markdown files that already have a table of contents?

Yes, the Skill detects and skips existing TOC headers to avoid duplication. It also respects YAML frontmatter and code blocks, ensuring only actual document structure is indexed and your metadata and code samples remain untouched.

What are the dependencies for generating markdown tables of contents?

The Skill has no hard dependencies, making it portable across environments. It runs as a standalone script with no external packages required, so you can use it immediately without additional setup or installation steps.