ScriptsApr 8, 2026·2 min read

Markdownlint — Lint Markdown for AI Content Quality

Node.js markdown linter with 50+ rules. Ensure consistent formatting in CLAUDE.md, .cursorrules, README files, and AI-generated documentation across your project.

TL;DR
Markdownlint checks markdown files against 50+ rules to enforce consistent formatting in CLAUDE.md, READMEs, and docs.
§01

What it is

Markdownlint is a Node.js-based linter for Markdown files with 50+ configurable rules. It catches formatting inconsistencies, structural issues, and style violations in markdown content. The tool is available as a CLI (markdownlint-cli2), VS Code extension, and GitHub Action.

It is particularly useful for teams maintaining markdown-based AI tool configurations like CLAUDE.md, .cursorrules, and README files. As AI-generated documentation becomes more common, consistent markdown formatting prevents rendering issues and improves readability across platforms.

§02

How it saves time or tokens

Markdownlint automates style enforcement that would otherwise require manual review. Instead of scanning documents for inconsistent heading levels, trailing spaces, or missing blank lines, you run a single command and get a list of violations. This is especially valuable when AI assistants generate markdown, as LLMs sometimes produce inconsistent formatting that compiles but renders poorly. Estimated token usage for this workflow is around 3,800 tokens.

§03

How to use

  1. Install the CLI: npm install -g markdownlint-cli2.
  2. Run the linter: markdownlint-cli2 '*/.md' to check all markdown files.
  3. Configure rules in .markdownlint.json or .markdownlint-cli2.jsonc to match your project standards.
  4. Add to CI: use the GitHub Action or pre-commit hook to catch issues before merge.
§04

Example

// .markdownlint.json
{
  "MD013": { "line_length": 120 },
  "MD033": false,
  "MD024": { "siblings_only": true },
  "MD041": true
}
# Lint all markdown files
markdownlint-cli2 '**/*.md'

# Fix auto-fixable issues
markdownlint-cli2 --fix '**/*.md'

# Lint only CLAUDE.md and README
markdownlint-cli2 CLAUDE.md README.md
§05

Related on TokRepo

§06

Common pitfalls

  • Running with default rules may flag too many issues in existing projects. Start by disabling noisy rules like MD013 (line length) and gradually enable stricter checks.
  • The VS Code extension and CLI may use different rule versions. Pin the same version in both to avoid conflicting results.
  • Markdownlint checks formatting, not content accuracy. It will not catch factual errors or broken external links -- use a separate link checker for that.

Frequently Asked Questions

What rules does markdownlint enforce?+

Markdownlint includes 50+ rules covering heading structure (MD001, MD003), whitespace (MD009, MD010), line length (MD013), list formatting (MD032), inline HTML (MD033), and more. Each rule can be individually enabled, disabled, or configured.

How do I use markdownlint in CI/CD?+

Use the official GitHub Action or add markdownlint-cli2 to your CI script. Run `markdownlint-cli2 '**/*.md'` and fail the build on non-zero exit code. Configuration is read from .markdownlint.json in your repository root.

Can markdownlint auto-fix issues?+

Yes. Run `markdownlint-cli2 --fix` to automatically fix issues that have auto-fix support, such as trailing spaces, inconsistent list markers, and missing blank lines. Not all rules support auto-fix.

Does markdownlint work with CLAUDE.md files?+

Yes. CLAUDE.md files are standard markdown. Markdownlint checks them like any other .md file. You can create project-specific rule configurations to match the formatting conventions used in your AI tool configurations.

What is the difference between markdownlint and markdownlint-cli2?+

markdownlint is the core Node.js library with the rule engine. markdownlint-cli2 is the recommended CLI wrapper that adds glob support, configuration file loading, and better output formatting. Use markdownlint-cli2 for command-line usage.

Citations (3)
🙏

Source & Thanks

Created by David Anson. Licensed under MIT.

DavidAnson/markdownlint — 5k+ stars

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets