CLI 目录 横向对比 FCRS-1.0 标准 /llms.txt
← 返回 CLI 目录

markdownlint-cli2

$ markdownlint-cli2 社区开源 低风险
David Anson · 设计与文档排版 · MIT · macos / linux / windows

markdownlint-cli2(markdownlint-cli2)是 markdownlint 的现代配置驱动 CLI,用于批量检查 Markdown 文档的标题层级、代码块、缩进与空白规范。支持 --fix 安全自动修复以及可扩展的 JSON/SARIF 输出格式器。

FCRS-1.0 综合评分
87 /100
良好 (Good)
中置信度 (源码/文档)
零摩擦安装命令
brew install markdownlint-cli2
CLI vs MCP 选型建议 仅 CLI 可用

markdownlint-cli2 在本地毫秒级完成 Markdown 仓库检查与自动修复,无需任何联网或 MCP。

Agent 友好度体检单

— 原生 JSON 输出
— 字段裁剪
✓ 无头非交互
— 支持 Dry-Run
— 只读模式开关
— 支持 NO_COLOR
✓ 自省/Schema 发现
— 官方 SKILL.md

当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。

FCRS-1.0 六维评分拆解

Agent 友好度 21 / 25

退出码确定,支持 --fix 与 --config,并可通过 .markdownlint-cli2.jsonc 配置 JSON/SARIF 输出格式器。

  • Non-interactive glob linting with clean line/rule diagnostics
  • Supports --fix for safe automated formatting cleanup
安全与权限边界 23 / 25

默认完全只读(需显式传 --fix 才修改文件),且 100% 离线运行。

  • No network or credentials
  • In-place edits only happen when --fix is passed
安装与运行摩擦 14 / 15

可通过 npm、npx 与 Homebrew 在 macOS、Linux 与 Windows 上安装运行。

  • npm install -g markdownlint-cli2, npx markdownlint-cli2, brew install markdownlint-cli2
能力覆盖与边际价值 13 / 15

高速且与 VS Code markdownlint 插件规则完全对齐的标准 Markdown 质量门禁。

  • Shared rule engine and config compatibility with editor extensions
维护与来源背书 8 / 10

由 markdownlint 原作者 David Anson(DavidAnson/markdownlint-cli2)以 MIT 协议维护。

  • Active releases from upstream markdownlint maintainer
文档与可验证性 8 / 10

GitHub README 对配置优先级、Glob 匹配、格式器与 --fix 说明详尽。

  • GitHub README documentation

安全边界、鉴权与放权指南

鉴权方式
无需鉴权
凭证存储位置

无需任何凭据;纯离线 Node.js 静态检查工具。

潜在副作用
只读查询 本地写入
费用与配额提示

免费开源软件(MIT)。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# markdownlint-cli2 Agent Rules
- Quote glob arguments (e.g. `"docs/**/*.md"`) so `markdownlint-cli2` handles globbing consistently across shells.
- Run read-only lint before `--fix`, and inspect `git diff` after `--fix`.
- Respect existing `.markdownlint-cli2.jsonc` / `.markdownlint.json` repository configs instead of overriding rules.

Agent 高频安全命令配方

只读查询(安全推荐)

检查 docs 目录下的全部 Markdown 文件
markdownlint-cli2 "docs/**/*.md"

校验 docs/ 下所有 Markdown 的格式与结构规则,不修改任何文件。

受控写入与预演

自动修复可修复的 Markdown 格式问题
markdownlint-cli2 --fix "docs/**/*.md"

就地应用安全且确定性的格式修复(如行尾空格、列表缩进与空行)。

核心优势

  • + 高速确定性的 Markdown 结构校验,并支持 --fix 自动修复。
  • + 与主流 VS Code markdownlint 扩展共享规则集和配置文件。
  • + 支持 npx markdownlint-cli2 零安装调用与 Homebrew 安装。

注意事项与踩坑点

  • ! 输出 JSON 或 SARIF 需在配置中启用对应格式器(如 markdownlint-cli2-formatter-json),而非直接传 --json 命令行开关。
  • ! 未加引号的 Glob 通配符在不同 Shell 下展开行为可能不一致。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI