xiaohongshu
xiaohongshu
fix-markdown-lint
Fix markdown linting errors in documentation files
Full skill instructions
Purpose: Fix markdown linting errors in documentation files Owner: Development Team Last Updated: 2025-10-17 Frequency: Before releases, when CI lint workflow fails
This runbook provides procedures for fixing markdown linting errors using markdownlint-cli2. Our CI/CD runs markdown linting on all *.md files, and errors will block merges to main.
Script Reference: ../../scripts/lint-markdown.sh
Expected duration: 5-10 minutes for most fixes (auto-fix handles ~95% of errors)
npm - Node.js package managernpm install)Before starting, ensure:
npm --versionls node_modules/markdownlint-cli2Purpose: Understand what errors exist
Commands:
# Run markdown linter (shows all errors)
npm run lint:md
# Or use the script directly:
scripts/lint-markdown.sh
# Count total errors
npm run lint:md 2>&1 | grep -c "MD0"
# See errors for specific file
scripts/lint-markdown.sh docs/guides/getting-started.md
Validation:
If step fails:
npm installPurpose: Automatically fix ~95% of markdown linting errors
Commands:
# Auto-fix all fixable errors
npm run lint:md -- --fix
# Or use the script directly:
scripts/lint-markdown.sh --fix
# Check remaining errors
npm run lint:md
Validation:
git statusCommon Auto-Fixed Errors:
If step fails:
git diff to understand what changedPurpose: Handle errors that can't be auto-fixed
Common Manual Fixes:
Error:
file.md:193:1 MD029/ol-prefix Ordered list item prefix [Expected: 1; Actual: 2; Style: 1/1/1]
Cause: Inconsistent ordered list numbering style
Fix Options:
Option A: Use sequential numbering (1, 2, 3)
1. First item
2. Second item
3. Third item
Option B: Use all 1's (lazy numbering)
1. First item
1. Second item
1. Third item
Commands:
# Find the problematic file and line
npm run lint:md 2>&1 | grep MD029
# Edit the file
$EDITOR docs/guides/getting-started.md
# Go to line number shown in error
# Fix numbering to be consistent
# Save and re-check
npm run lint:md
Validation:
Error:
file.md:45 MD013/line-length Line length [Expected: 80; Actual: 120]
Cause: Line exceeds 80 characters (or configured limit)
Fix:
# View the long line
sed -n '45p' docs/guides/getting-started.md
# Edit and break into multiple lines
$EDITOR docs/guides/getting-started.md
# For code blocks, this rule is often ignored - check if it should be
Note: Often better to configure .markdownlintrc to ignore line length in code blocks
Error:
file.md:67 MD040/fenced-code-language Fenced code blocks should have a language specified
Cause: Code fence without language specifier
Fix:
# Before (no language)
code here
# After (with language)
```bash
code here
**Common Languages:**
- `bash` - Shell commands
- `javascript` / `typescript` - JS/TS code
- `json` - JSON config
- `markdown` - Markdown examples
- `text` - Plain text output
---
### Step 4: Verify All Errors Fixed
**Purpose:** Confirm linting passes
**Commands:**
```bash
# Run linter
npm run lint:md
# Check exit code
echo $?
# Expected: 0 (success)
# Verify in CI (after commit)
gh run list --workflow=lint.yml --limit 3
Validation:
npm run lint:md shows "0 error(s)"git status shows modified filesIf step fails:
Purpose: Understand what changed before committing
Commands:
# See all changes
git diff
# Review specific file
git diff docs/guides/getting-started.md
# Check summary of changes
git diff --stat
Validation:
Common Changes to Expect:
If step fails:
git checkout -- <file>Purpose: Save linting fixes
Commands:
# Stage all markdown files
git add '*.md' 'docs/**/*.md'
# Or stage specific files
git add README.md docs/guides/getting-started.md
# Commit with clear message
git commit -m "chore: fix markdown linting errors
- Auto-fix whitespace and formatting issues
- Fix ordered list numbering consistency
- All lint checks now passing"
# Verify commit
git log -1 --stat
Validation:
If step fails:
git commit --amend to fix messagegit reset HEAD~1 to undo and restartAfter completing all steps, verify:
Local Lint Passes:
npm run lint:md
# Expected: "Summary: 0 error(s)"
Exit Code is 0:
npm run lint:md && echo "PASS" || echo "FAIL"
# Expected: "PASS"
Files Committed:
git log -1 --name-only
# Expected: Shows markdown files changed
CI Will Pass:
# After pushing
gh run watch
# Expected: Lint workflow succeeds
Symptoms:
Resolution:
# Focus on one directory at a time
npx markdownlint-cli2 'docs/guides/**/*.md' --fix
npx markdownlint-cli2 'docs/rfcs/**/*.md' --fix
# Or one file at a time
npx markdownlint-cli2 docs/guides/getting-started.md --fix
# Check progress
npm run lint:md 2>&1 | grep -c "MD0"
Symptoms:
Resolution:
# Revert changes
git checkout -- docs/guides/problematic-file.md
# Fix manually without auto-fix
$EDITOR docs/guides/problematic-file.md
# Check specific file
npx markdownlint-cli2 docs/guides/problematic-file.md
Prevention:
git diff before committingSymptoms:
Resolution:
# Get rule documentation URL
npm run lint:md 2>&1 | grep -A 1 "MD032"
# Shows link to: https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md032.md
# Or search for rule:
# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md
Common Rules:
Symptoms:
npm run lint:md passes locallyResolution:
# Ensure you're linting the same files as CI
npm run lint:md
# Check if .gitignore is excluding files CI sees
git ls-files '*.md' | wc -l
# Verify no unstaged changes
git status
# Try exact CI command
npx markdownlint-cli2 '**/*.md' '!node_modules' '!lib'
Common Causes:
.gitignore differencesEscalate if:
Escalation Contact:
After completion:
# Check errors
npm run lint:md
# Auto-fix everything
npm run lint:md -- --fix
# Fix specific directory
npx markdownlint-cli2 'docs/guides/**/*.md' --fix
# Fix specific file
npx markdownlint-cli2 docs/guides/file.md --fix
# Count remaining errors
npm run lint:md 2>&1 | grep -c "MD0"
# Commit fixes
git add '*.md' 'docs/**/*.md'
git commit -m "chore: fix markdown linting errors"
Linting configuration in package.json scripts:
{
"scripts": {
"lint:md": "markdownlint-cli2 '**/*.md' '!node_modules' '!lib'"
}
}
This project uses the default markdownlint rules. If you need to customize rules, you can create a .markdownlintrc or .markdownlint.json file in the project root.
Important Notes:
git diff before committingdocs/.journal/ are gitignored - lint errors OKGotchas:
Related Procedures:
| Date | Author | Changes |
|---|---|---|
| 2025-10-17 | @tnez | Initial creation |
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience