markdown-linter
Skill1 starsChanged 3 months agoMITView on GitHub
Use when a user wants to check markdown files for issues (inconsistent heading levels, broken links, missing alt text, formatting inconsistencies) before publishing docs, or says "check my markdown" / "lint this doc" / "fix markdown issues".
In this repository58 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- api-test-suiteSkill
- ascii-artSkill
- caddy-reverse-proxySkill
- changelog-generatorSkill
- color-palette-generatorSkill
- cron-taskSkill
- csv-toolkitSkill
- discord-bot-buildSkill
- docker-umbrellaSkill
- dotfiles-manageSkill
- email-sendSkill
- env-config-managerSkill
- excalidraw-diagramSkill
- file-organizerSkill
- forgejo-self-hostSkill
- frontend-design-toolkitSkill
- generate-dockerfileSkill
- gif-searchSkill
- git-backupSkill
- github-actions-ciSkill
- hallmark-readmeSkill
- http-api-testerSkill
- invoice-generatorSkill
- json-formatterSkill
- log-analyzerSkill
- markdown-to-pdfSkill
- markdown-to-slidesSkill
- mcp-server-buildSkill
- media-id-mappingSkill
- movie-catalogue-siteSkill
- movie-night-calendarSkill
- ntfy-notifierSkill
- ocr-documentsSkill
- ollama-localSkill
- openapi-generatorSkill
- password-generatorSkill
- pdf-extractSkill
- portfolio-upkeepSkill
- qr-code-generatorSkill
- regex-testerSkill
- resume-builderSkill
- rss-monitorSkill
- searxng-self-hostSkill
- skill-publishSkill
- skill-registry-catalogSkill
- skills-portfolio-scaffoldSkill
- snippet-managerSkill
- sqlite-dashboardSkill
- streaming-provider-embedsSkill
- tailscale-deploySkill
- telegram-bot-buildSkill
- tmdb-metadataSkill
- uptime-kuma-self-hostSkill
- watchlist-syncSkill
- webhook-receiverSkill
- youtube-transcriptSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
Check markdown files for common issues: inconsistent heading levels, broken links, missing alt text, trailing whitespace, and formatting …
- Very specific: line 170
Run lint_markdown to get all issues
- Distinctive: line 182
Auto-fix is conservative: Only fixes whitespace and list markers.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
markdown-linter
Overview
Check markdown files for common issues: inconsistent heading levels, broken links, missing alt text, trailing whitespace, and formatting inconsistencies. The agent scans markdown files and reports a fixable punch list.
When to Use
- The user wants to check their markdown for issues.
- The user is preparing documentation for publication.
- The user wants consistent markdown across a project.
- The user says "check my markdown", "lint this doc", or "fix markdown issues".
Checks
import re
from pathlib import Path
def lint_markdown(filepath: str) -> list:
"""Run all markdown linting checks and return issues."""
with open(filepath, 'r') as f:
lines = f.readlines()
content = "".join(lines)
issues = []
# 1. Heading levels should not skip (h1 → h3 is bad)
heading_levels = []
for i, line in enumerate(lines, 1):
match = re.match(r'^(#{1,6})\s', line)
if match:
level = len(match.group(1))
heading_levels.append((i, level))
for j, (line_num, level) in enumerate(heading_levels):
if j > 0:
prev_level = heading_levels[j-1][1]
if level > prev_level + 1:
issues.append({
"line": line_num,
"rule": "heading-skip",
"message": f"Heading level {level} skips from h{prev_level} — should be h{prev_level+1} max"
})
# 2. Multiple h1 headings
h1_count = sum(1 for _, level in heading_levels if level == 1)
if h1_count > 1:
issues.append({
"line": 0,
"rule": "multiple-h1",
"message": f"Found {h1_count} h1 headings — should have only one"
})
# 3. Trailing whitespace
for i, line in enumerate(lines, 1):
if line.rstrip() != line and line.strip():
issues.append({
"line": i,
"rule": "trailing-whitespace",
"message": "Trailing whitespace at end of line"
})
# 4. Images without alt text
for i, line in enumerate(lines, 1):
for match in re.finditer(r'!\[([^\]]*)\]\([^\)]+\)', line):
alt = match.group(1)
if not alt.strip():
issues.append({
"line": i,
"rule": "missing-alt-text",
"message": "Image has no alt text"
})
# 5. Links without text
for i, line in enumerate(lines, 1):
for match in re.finditer(r'\[([^\]]*)\]\([^\)]+\)', line):
text = match.group(1)
if not text.strip() and not line.startswith('!'):
issues.append({
"line": i,
"rule": "empty-link-text",
"message": "Link has no display text"
})
# 6. Inconsistent list markers (mixing - and *)
dash_lists = sum(1 for line in lines if re.match(r'^\s*-\s', line))
star_lists = sum(1 for line in lines if re.match(r'^\s*\*\s', line))
if dash_lists > 0 and star_lists > 0:
issues.append({
"line": 0,
"rule": "mixed-list-markers",
"message": f"Mixed list markers: {dash_lists} dash, {star_lists} asterisk — pick one"
})
# 7. Code blocks without language
in_code_block = False
for i, line in enumerate(lines, 1):
stripped = line.strip()
if stripped.startswith("```"):
if in_code_block:
in_code_block = False
else:
lang = stripped[3:].strip()
if not lang:
issues.append({
"line": i,
"rule": "missing-code-language",
"message": "Code block has no language specified"
})
in_code_block = True
# 8. Lines too long (over 120 chars, excluding URLs and tables)
for i, line in enumerate(lines, 1):
if len(line.rstrip()) > 120 and not line.strip().startswith("|") and "http" not in line:
issues.append({
"line": i,
"rule": "line-too-long",
"message": f"Line is {len(line.rstrip())} chars (max 120 recommended)"
})
return sorted(issues, key=lambda x: x["line"])Auto-fix
def fix_markdown(filepath: str) -> dict:
"""Auto-fix simple markdown issues."""
with open(filepath, 'r') as f:
content = f.read()
fixes = 0
# Fix trailing whitespace
lines = content.split("\n")
fixed_lines = []
for line in lines:
fixed = line.rstrip()
if fixed != line:
fixes += 1
fixed_lines.append(fixed)
# Normalize list markers (use - consistently)
for i, line in enumerate(fixed_lines):
if re.match(r'^(\s*)\*\s', line):
fixed_lines[i] = re.sub(r'^(\s*)\*\s', r'\1- ', line)
fixes += 1
with open(filepath, 'w') as f:
f.write("\n".join(fixed_lines))
return {"fixes": fixes, "file": filepath}Workflow
- Run
lint_markdownto get all issues - Present issues sorted by line number
- Offer to auto-fix trailing whitespace and list markers
- For other issues, show the line and suggested fix
- Let the user decide which to fix
Common Pitfalls
- Frontmatter. YAML frontmatter (between
---lines) is not markdown. Skip it during linting. - Tables. Table rows can be long. The line-length check skips lines starting with
|. - URLs. Long URLs make lines long. The check skips lines containing
http. - Nested code blocks. Code blocks inside code blocks (quarto, mdx) can confuse the parser. The
in_code_blocktoggle handles simple cases. - Auto-fix is conservative. Only fixes whitespace and list markers. Heading levels, alt text, and link text require manual judgment.
Verification Checklist
lint_markdownwas run and its full issue list — not just a sample — was reported, sorted by line number- YAML frontmatter block was excluded from line-length and heading checks
fix_markdownwas only applied to whitespace/list-marker issues; heading levels, alt text, and link text were left for manual review- Re-running
lint_markdownafter fixes shows the fixed issue count reduced accordingly
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

