| name | markdown |
| description | Markdown linting and automated fixing using markdownlint-cli2. Use when Claude needs to: (1) Check markdown files for style issues, (2) Fix markdown formatting problems, (3) Ensure markdown follows best practices, (4) Validate markdown documents, or (5) Apply consistent markdown styling
|
| license | MIT |
| metadata | {"author":"Ikuma Yamashita","version":"1.1"} |
Markdown Lint
Automated markdown validation and fixing using markdownlint-cli2.
Workflow Overview
1. Run auto-fix ā markdownlint-cli2 --fix <file>
2. Check remaining ā markdownlint-cli2 <file>
3. Fix manually ā str_replace for structural issues
4. Verify ā markdownlint-cli2 <file> (should show 0 errors)
Expected results: Auto-fix resolves 70-90% of issues. Remaining 3-5
issues require manual correction.
Basic Commands
markdownlint-cli2 --fix document.md
markdownlint-cli2 document.md
markdownlint-cli2 --fix file1.md file2.md
markdownlint-cli2 --fix "**/*.md"
markdownlint-cli2 --config .markdownlint.json document.md
File Paths
markdownlint-cli2 --fix /mnt/user-data/uploads/document.md
markdownlint-cli2 --fix /home/claude/document.md
cp /path/to/fixed.md /mnt/user-data/outputs/
Manual Fixes Required
Auto-fix cannot resolve these issues - they need Claude's judgment:
MD025 - Multiple H1 Headers
Why: Requires understanding document hierarchy
Fix: Convert extra H1s to appropriate level
# Main Title
# Second Title ā Change to: ## Second Title
MD036 - Emphasis as Header
Why: Requires determining author intent
Fix: Replace bold/italic with proper header
**Section Title** ā Change to: ## Section Title
MD013 - Line Too Long
Why: Requires deciding where to break content
Fix: Wrap at natural points (spaces, punctuation)
This is a very long line exceeding 80 characters that needs wrapping.
ā
This is a very long line exceeding 80 characters that needs
wrapping.
Exception: URLs typically exempt
MD041 - Missing First Line Header
Why: Requires structural decision
Fix: Add H1 at start or restructure
Execution Pattern
For Uploaded Files
markdownlint-cli2 --fix /mnt/user-data/uploads/document.md
markdownlint-cli2 /mnt/user-data/uploads/document.md
str_replace "# Extra Title" ā "## Extra Title"
markdownlint-cli2 /mnt/user-data/uploads/document.md
cp /mnt/user-data/uploads/document.md /mnt/user-data/outputs/
For New Content
create_file /home/claude/doc.md "content..."
markdownlint-cli2 --fix /home/claude/doc.md
markdownlint-cli2 /home/claude/doc.md
cp /home/claude/doc.md /mnt/user-data/outputs/
Configuration
Create .markdownlint.json to customize rules:
{
"default": true,
"MD013": { "line_length": 120 },
"MD033": false
}
Common adjustments:
"MD013": false - Disable line length checking
"MD013": { "line_length": 120 } - Increase limit to 120
"MD013": { "code_blocks": false } - Exclude code blocks
"MD033": false - Allow HTML
"MD041": false - Don't require first line header
Config file search order:
.markdownlint-cli2.jsonc
.markdownlint-cli2.yaml
.markdownlint.jsonc / .markdownlint.json
.markdownlint.yaml / .markdownlint.yml
Reporting to User
Provide clear summary of fixes:
ā
Markdown linting complete!
Initial: 18 errors
After auto-fix: 4 errors
Manual fixes:
⢠MD025: Converted 2 H1 headers to H2
⢠MD036: Replaced bold with proper header
⢠MD013: Wrapped long line
Final: 0 errors
Error Count Interpretation
Before auto-fix:
- 0-5: Minor issues
- 6-15: Moderate issues
- 16+: Significant issues
After auto-fix:
- 0-2: Excellent
- 3-5: Typical
- 6+: Check if config needed
Common Fix Patterns
str_replace "# Introduction" ā "## Introduction"
str_replace "# Details" ā "### Details"
str_replace "**Important**" ā "## Important"
str_replace "_Note_" ā "### Note"
Troubleshooting
Auto-fix not working:
view /path/to/file.md
ls -l /path/to/file.md
markdownlint-cli2 --fix /full/path/to/file.md
Too many errors after auto-fix:
echo '{"MD013": false, "MD041": false}' > .markdownlint.json
markdownlint-cli2 --config .markdownlint.json --fix file.md
Specific rule causing issues:
- Disable in config:
"MD013": false
- Or adjust parameters:
"MD013": { "line_length": 120 }
When NOT to Lint
Skip linting when:
- Code examples intentionally violate rules
- Embedded HTML/JSX required (disable MD033)
- Generated docs with different conventions
- Legacy docs where changes break references
Use custom config to disable problematic rules.
Quick Rule Reference
Most common rules Claude will encounter:
- MD001 - Heading levels increment by one at a time
- MD003 - Consistent heading style (atx vs setext)
- MD004 - Consistent unordered list markers
- MD007 - Unordered list indentation (default: 2 spaces)
- MD009 - No trailing spaces
- MD010 - No hard tabs
- MD012 - No multiple consecutive blank lines
- MD013 - Line length (default: 80 chars)
- MD014 - No
$ before shell commands unless showing output
- MD018 - Space after
# in headings
- MD019 - No multiple spaces after
# in headings
- MD022 - Blank lines around headings
- MD023 - Headings must start at beginning of line
- MD024 - No duplicate heading content
- MD025 - Single H1 only
- MD026 - No trailing punctuation in headings
- MD029 - Ordered list numbering style
- MD031 - Blank lines around fenced code blocks
- MD032 - Blank lines around lists
- MD033 - No inline HTML (unless explicitly allowed)
- MD034 - No bare URLs (wrap with
<url> or [text](url))
- MD035 - Consistent horizontal rule style
- MD036 - No emphasis as headers
- MD037 - No spaces inside emphasis markers
- MD038 - No spaces inside code span backticks
- MD040 - Language for fenced code blocks
- MD041 - First line should be H1 header
- MD046 - Consistent code block style (fenced vs indented)
- MD047 - File must end with a single newline
Full rule documentation: https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md