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.
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.
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.
How to use
- Install the CLI:
npm install -g markdownlint-cli2. - Run the linter:
markdownlint-cli2 '*/.md'to check all markdown files. - Configure rules in
.markdownlint.jsonor.markdownlint-cli2.jsoncto match your project standards. - Add to CI: use the GitHub Action or pre-commit hook to catch issues before merge.
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
Related on TokRepo
- AI tools for documentation -- find tools for maintaining and generating technical docs.
- AI tools for coding -- explore linters, formatters, and developer productivity tools.
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
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.
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.
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.
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.
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)
- markdownlint GitHub— Markdownlint provides 50+ configurable rules for markdown linting
- markdownlint-cli2 GitHub— markdownlint-cli2 is the recommended CLI for markdownlint
- VS Code Marketplace— VS Code extension for markdownlint
Related on TokRepo
Source & Thanks
Created by David Anson. Licensed under MIT.
DavidAnson/markdownlint — 5k+ stars
Discussion
Related Assets
NAPI-RS — Build Node.js Native Addons in Rust
Write high-performance Node.js native modules in Rust with automatic TypeScript type generation and cross-platform prebuilt binaries.
Mamba — Fast Cross-Platform Package Manager
A drop-in conda replacement written in C++ that resolves environments in seconds instead of minutes.
Plasmo — The Browser Extension Framework
Build, test, and publish browser extensions for Chrome, Firefox, and Edge using React or Vue with hot-reload and automatic manifest generation.