360 Secure SkillHub
360 安全技能中心

markdown-link-check

该 Skill 提供独立的 Python 3 脚本,扫描指定的 Markdown 文件或目录:对远程 URL 发送 HEAD 请求、对本地相对路径校验文件是否存在,输出失效链接及其行号与原因,并用退出码区分全部通过、发现失效链接和参数错误。

terrycarter1985
terrycarter1985
热度 9.17
最近更新 2026-08-19 07:40:53
分类:效率依赖:代码执行 / 读写文件 / 第三方 API应用场景:工作流 / 报告撰写

安装技能

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

执行命令安装此 skill: npx secure-skills-cli add markdown-link-check
Metadata
name
markdown-link-check
description
Scan markdown files and verify that all hyperlinks (both local files and remote URLs) resolve correctly. Use when you need to: (1) verify documentation before publishing, (2) check a repo README or wiki links, (3) audit markdown files for broken links before generating static sites or releasing content, (4) validate links in collected digital assets before archiving.

Markdown Link Check

Scan one or many markdown files and report every broken hyperlink with line numbers and diagnostic reasons.

Quick Start

python3 scripts/check_links.py <file-or-directory>

Examples:

  • Single file: python3 scripts/check_links.py README.md
  • Whole directory: python3 scripts/check_links.py ./docs --timeout 15
  • Verbose mode (shows healthy links too): python3 scripts/check_links.py . -v

What It Checks

Link type Behavior
Remote URLs (http://, https://) Sends HEAD request, reports HTTP status or connection error
Local relative paths Verifies file exists relative to the markdown file's directory
Anchors (#section) Skipped (intra-file anchors are out of scope)
Image links (![alt](url)) Skipped (use a dedicated asset checker for those)

Exit Codes

Code Meaning
0 All links resolved successfully
1 Broken links found (details printed to stdout)
2 File/directory argument invalid or unreadable

Script Reference

scripts/check_links.py is a standalone Python 3 script with no external dependencies. It uses only the standard library (urllib, pathlib, concurrent.futures).

Key options:

  • --timeout N — HTTP timeout per request in seconds (default 10)
  • -v, --verbose — Print healthy link summary in addition to broken ones