360 Secure SkillHub
360 安全技能中心

markdown-lint

基于 Node 脚本对单个 Markdown 文件或目录做静态检查,覆盖标题层级、代码块语言标签、行尾空白、多个一级标题、空行、裸链接和列表缩进;输出文本或 JSON 报告,可通过 --fix 修复行尾空白、空行和列表缩进,退出码区分通过、错误和读取失败。

terrycarter1985
terrycarter1985
热度 7.64
最近更新 2026-09-01 04:37:43
分类:效率依赖:代码执行 / 读写文件应用场景:校对润色 / 工作流

安装技能

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

执行命令安装此 skill: npx secure-skills-cli add markdown-lint
Metadata
name
markdown-lint
description
Check markdown files for common issues including heading structure, link validity, list formatting, trailing whitespace, and code block language tags. Use when reviewing documentation, README files, or any .md file for consistency and best practices.
metadata
{"openclaw":{"emoji":"📝","requires":{"bins":[]}}}

Markdown Lint Skill

Static analysis for markdown files. Detects structural issues, broken links, and formatting inconsistencies before they become review comments.

When to use it

  • Reviewing a README or docs file before committing
  • Auditing a docs directory for consistency
  • CI gate for markdown quality
  • Onboarding a new repo and wanting a quick health check

Quick start

# Lint a single file
node /path/to/markdown-lint/scripts/lint.mjs README.md

# Lint a directory (recursive)
node /path/to/markdown-lint/scripts/lint.mjs ./docs/

# JSON output for automation
node /path/to/markdown-lint/scripts/lint.mjs README.md --format json

# Fix safe issues automatically
node /path/to/markdown-lint/scripts/lint.mjs README.md --fix

What it checks

Check What it detects
heading-order Skipped heading levels (e.g. h1 → h3)
code-lang Fenced code blocks without a language tag
trailing-ws Trailing whitespace on lines
multiple-h1 More than one top-level heading
blank-lines Missing blank lines around headings/lists
link-text Bare URLs without link text
list-indent Inconsistent list indentation
hr-style Mixed horizontal rule styles

Exit codes

  • 0 — all checks passed
  • 1 — lint errors found
  • 2 — file not found or read error

Output format

Text (default):

README.md
  12:3  error  heading-order    Expected h2, got h3 (skips h2)
  28:1  error  multiple-h1      Multiple H1 headings found
  35:0  warn   trailing-ws      Trailing whitespace

2 errors, 1 warning

JSON:

{
  "file": "README.md",
  "errors": [
    {"line": 12, "col": 3, "rule": "heading-order", "message": "Expected h2, got h3"}
  ],
  "warnings": [
    {"line": 35, "col": 0, "rule": "trailing-ws", "message": "Trailing whitespace"}
  ],
  "summary": {"errors": 1, "warnings": 1}
}

Fixable rules

--fix automatically resolves:

  • trailing-ws — strips trailing whitespace
  • blank-lines — inserts missing blank lines
  • list-indent — normalizes list indentation to 2 spaces

Non-fixable rules (like heading-order, multiple-h1) are reported but not auto-corrected.

Adding custom rules

Create a file rules.json in the same directory as the script:

{
  "maxLineLength": 120,
  "requiredHeadings": ["Installation", "Usage", "License"]
}

The script reads rules.json if present and applies additional checks.