首页龙虾技能列表 › Markdown Lint — 技能工具

📋 Markdown Lint — 技能工具

v0.2.1

Use this skill immediately when the user needs to: set up markdownlint-cli2 and pre-commit hooks in a repository, fix or batch-repair markdownlint errors lik...

0· 376·0 当前·0 累计
by @niracler (Niracler)·MIT-0
下载技能包
License
MIT-0
最后更新
2026/3/16
安全扫描
VirusTotal
无害
查看报告
OpenClaw
安全
high confidence
The skill's requirements, instructions, and included script align with its stated purpose of installing/configuring markdownlint and a pre-commit hook to block horizontal rules; nothing requests unrelated credentials or surprising installs.
评估建议
This skill appears coherent and intended for repo-wide markdown lint setup. Before running its commands: (1) run everything on a feature branch or a copy of the repo (the script edits files in-place with mv), (2) test the check-horizontal-rules.sh on a small subset of files to confirm it matches your frontmatter format, (3) verify Node and pre-commit are installed and that you are comfortable allowing pre-commit to fetch the public markdownlint-cli2 repo (pre-commit autoupdate will pull from Git...
详细分析 ▾
用途与能力
The skill asks only for markdownlint-cli2 and (optionally) pre-commit, produces a .markdownlint.json and a pre-commit hook calling the included shell script; these are appropriate for setting up repo linting. (Minor note: the SKILL.md frontmatter lists a node install entry for markdownlint-cli2 while the registry shows no install spec — this is small metadata inconsistency but not malicious.)
指令范围
Instructions run lint/fix across the repo and include an awk+mv loop to edit files in-place and a script to detect horizontal rules; this is expected for batch repair but can make broad repository changes. The SKILL.md also instructs not to proactively check tools on skill load (odd but not dangerous). No instructions read unrelated env vars or exfiltrate data.
安装机制
No opaque downloads or remote installers are included. The pre-commit hook references the public GitHub repo for markdownlint-cli2 (expected). The included shell script is small and local. Recommended installs (npx, pipx, brew) are standard.
凭证需求
The skill requests no environment variables, secrets, or config paths beyond normal repo files; this is proportional to its function.
持久化与权限
Skill does not request always:true and does not modify other skills or system-wide agent settings. It installs a pre-commit hook into the repository (expected behavior).
安全有层次,运行前请审查代码。

License

MIT-0

可自由使用、修改和再分发,无需署名。

运行时依赖

无特殊依赖

版本

latestv0.2.12026/3/5

Release v0.2.1 — see https://github.com/niracler/skill/releases/tag/v0.2.1

● 无害

安装命令 点击复制

官方npx clawhub@latest install nini-markdown-lint
镜像加速npx clawhub@latest install nini-markdown-lint --registry https://cn.clawhub-mirror.com

技能文档

为仓库配置 markdown 格式检查(markdownlint + 水平线禁止)和 pre-commit hook。

Prerequisites

ToolTypeRequiredInstall
Node.jscliYesbrew install node or nodejs.org
markdownlint-cli2cliYesnpx markdownlint-cli2 (no install needed)
pre-commitcliNouv tool install pre-commit --with pre-commit-uv or pipx install pre-commit or brew install pre-commit
Do NOT proactively verify these tools on skill load. If a command fails due to a missing tool, directly guide the user through installation and configuration step by step.

When to Use

  • 新仓库初始化:第一次为仓库添加 markdown 格式标准
  • 检查/修复:运行格式检查或批量修复现有文件
  • 迁移:将格式标准复制到另一个仓库

不适用:

  • 单文件检查:直接运行 npx markdownlint-cli2 file.md,不需要走 setup 流程
  • 文章内容审校:使用 writing-proofreading skill(步骤 6 会引用本 skill)

Setup 流程

1. 检查仓库状态

# 已有配置?跳到「检查/修复」
ls .markdownlint.json .pre-commit-config.yaml 2>/dev/null

2. 创建配置文件

.markdownlint.json

{
  "default": true,
  "MD013": false,
  "MD024": { "siblings_only": true },
  "MD033": false,
  "MD035": false,
  "MD036": false,
  "MD041": false,
  "MD060": false
}

关闭规则说明:

规则理由
MD013CJK 文本和表格不适合行长度限制
MD033允许
, 等 inline HTML
MD035水平线完全禁止,由独立脚本检查
MD036允许 bold 作视觉标题
MD041YAML frontmatter 导致首行非标题
MD060表格管道符间距样式过于严格
按需追加禁用(根据仓库内容酌情添加):

规则场景理由
MD025仓库含导入/vendor 文档协议文档常有多个 H1
MD045仓库含导入/vendor 文档vendor 文档图片无 alt text
MD051CJK 锚点链接#_中文标题 格式的片段不被识别
MD056复杂参考表格合并行/变长列的表格触发误报
.pre-commit-config.yaml

repos:
  - repo: https://github.com/DavidAnson/markdownlint-cli2
    rev: v0.21.0  # 运行 pre-commit autoupdate 获取最新
    hooks:
      - id: markdownlint-cli2
  - repo: local
    hooks:
      - id: no-horizontal-rules
        name: no horizontal rules outside frontmatter
        entry: scripts/check-horizontal-rules.sh
        language: script
        types: [markdown]
创建后必须运行 pre-commit autoupdate,上面的 rev 可能已过时。

scripts/check-horizontal-rules.sh

scripts/check-horizontal-rules.sh 复制,然后 chmod +x

Windows 用户.sh 脚本需要在 Git Bash 或 WSL 中运行。

.gitignore(如果没有):

node_modules/
.mypy_cache/
__pycache__/

3. 移除现有 --- 分隔线

保留 YAML frontmatter 的 ---,删除其余所有水平线:

# 找出违规文件
bash scripts/check-horizontal-rules.sh $(find . -name '.md' -not -path './node_modules/')

# 提取违规文件列表(仅匹配 .md: 格式的行,避免捕获错误消息) files=$(bash scripts/check-horizontal-rules.sh \ $(find . -name '.md' -not -path './node_modules/') 2>&1 \ | grep -E '\.md:[0-9]+:' | grep -oE '^[^:]+' | sort -u)

# 批量移除(保留 frontmatter) for file in $files; do awk 'NR == 1 && /^---[[:space:]]$/ { print; fm = 1; next } fm && /^---[[:space:]]$/ { print; fm = 0; next } !fm && /^[[:space:]][-_][[:space:]][-_][[:space:]][-_][-_ ]$/ { next } { print }' "$file" > "$file.tmp" && mv "$file.tmp" "$file" echo "Fixed: $file" done

注意:grep 必须用 \.md:[0-9]+: 过滤,否则脚本末尾的 "Error: ..." 错误消息会被当成文件名。

4. 格式化全部文件

# 单仓库
npx markdownlint-cli2 --fix "*/.md"
npx markdownlint-cli2 "*/.md"

# monorepo(排除子仓库和依赖目录) npx markdownlint-cli2 --fix "*/.md" "#repos" "#node_modules" npx markdownlint-cli2 "*/.md" "#repos" "#node_modules"

4a. 处理无法自动修复的错误

--fix 无法修复的常见错误:

  • MD040(代码块缺少语言):给 ` 加上语言标识(pythonbashyamltext 等)
  • MD025/MD045/MD051/MD056:如果大量出现在 vendor 文档中,在 .markdownlint.json 中禁用对应规则

先分析错误分布再决定策略:

# 按规则统计
npx markdownlint-cli2 "*/.md" "#repos" "#node_modules" 2>&1 \
  | grep -oE 'MD[0-9]+' | sort | uniq -c | sort -rn

# 按文件统计 npx markdownlint-cli2 "*/.md" "#repos" "#node_modules" 2>&1 \ | grep -oE '^[^:]+' | sort | uniq -c | sort -rn | head -10

5. 安装 hook

pre-commit install

6. 验证

# 两项检查全部通过(monorepo 加 "#repos" 排除子仓库)
npx markdownlint-cli2 "*/.md" "#repos" "#node_modules"
bash scripts/check-horizontal-rules.sh $(find . -name '.md' -not -path './repos/' -not -path './node_modules/')
# 测试 hook: 故意加 --- 到某 md 文件,git add + commit,应被拦截

检查/修复(已有配置的仓库)

npx markdownlint-cli2 "/.md" "#repos" "#node_modules"            # 检查
npx markdownlint-cli2 --fix "*/.md" "#repos" "#node_modules"      # 自动修复
bash scripts/check-horizontal-rules.sh $(find . -name '.md' -not -path './repos/' -not -path './node_modules/*')
单仓库项目去掉 "#repos" 即可。

常见问题

问题原因修复
pre-commit: command not found未安装uv tool install pre-commit --with pre-commit-uv(推荐)或 pipx install pre-commit / brew install pre-commit
markdownlint 大量 MD060 错误表格管道符间距.markdownlint.json"MD060": false
大量 MD056 错误vendor 文档复杂表格.markdownlint.json"MD056": false
大量 MD051 错误CJK 锚点链接.markdownlint.json"MD051": false
.sh 脚本在 Windows 无法执行Windows 不原生支持 Bash使用 Git Bash 或 WSL
frontmatter --- 被误删awk 脚本问题确认文件第 1 行是 --- 且紧接 YAML 内容
批量删除 HR 产生垃圾 .tmp 文件grep 捕获了脚本错误消息作为文件名grep -E '\.md:[0-9]+:' 过滤,仅匹配文件路径行
--fix 未修复所有问题部分规则无法自动修复手动修复(通常是 MD040 缺少代码块语言,加 `text 等)
数据来源:ClawHub ↗ · 中文优化:龙虾技能库
OpenClaw 技能定制 / 插件定制 / 私有工作流定制

免费技能或插件可能存在安全风险,如需更匹配、更安全的方案,建议联系付费定制

了解定制服务