360 Secure SkillHub
360 安全技能中心

md-toc

该 Skill 通过一个 POSIX shell 脚本读取指定 Markdown 文件,提取 # 到 ###### 的 ATX 标题,输出带相对锚点链接的 Markdown 目录列表;可用 --max 限制标题深度,跳过代码块内的标题,文件缺失或不可读时以非零状态退出。

分类:效率
terrycarter1985
terrycarter1985
热度 10.99
最近更新 2026-08-18 19:49:48

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add terrycarter1985/md-toc
兼容性
通用兼容
联网要求
不联网
数据出网
数据不出本机
Metadata
name
md-toc
description
Generate a table of contents (TOC) for any Markdown file by extracting its ATX headings (# ..
metadata
{"openclaw":{"emoji":"📑","requires":{"bins":["bash"]}}}

md-toc

Generates a Markdown table of contents from the ATX headings in a file.

When to use

  • Building a TOC for a README or long notes file.
  • Getting a quick outline of a document before editing or summarizing.
  • Verifying heading structure during a doc review.

Prerequisites

  • The target file must be UTF-8 text with ATX headings (#, ##, ...).
  • A POSIX shell (bash/sh) and awk must be available.

Usage

bash scripts/md-toc.sh path/to/file.md
bash scripts/md-toc.sh path/to/file.md --max 3   # cap heading depth

Output is a Markdown list with relative anchor links, printed to stdout.

Notes

  • Headings inside fenced code blocks are skipped.
  • The script exits non-zero if the file is missing or unreadable.