360 Secure SkillHub
360 安全技能中心

md-toc

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

terrycarter1985
terrycarter1985
热度 9.03
最近更新 2026-08-18 19:49:48
分类:效率依赖:代码执行 / 读写文件应用场景:工作流 / 笔记整理

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add 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.