.ai/skills/woocommerce-dev-cycle/markdown-linting.md
ALWAYS lint markdown files after changes. They must pass markdownlint validation.
If markdownlint is not available:
npm install -g markdownlint-cli
# Check markdown file (run from repo root)
markdownlint plugins/woocommerce/CLAUDE.md
# RECOMMENDED: Auto-fix issues first (handles most errors)
markdownlint --fix plugins/woocommerce/CLAUDE.md
# Check multiple files
markdownlint packages/js/CLAUDE.md plugins/woocommerce/CLAUDE.md
# Lint all CLAUDE.md files
markdownlint packages/js/CLAUDE.md plugins/woocommerce/CLAUDE.md \
plugins/woocommerce/client/admin/CLAUDE.md
CRITICAL: Always run markdownlint from the repository root so the .markdownlint.json config file is loaded.
Using absolute paths bypasses the config and may show incorrect errors.
# ✅ CORRECT - run from repo root
cd /path/to/woocommerce
markdownlint plugins/woocommerce/CLAUDE.md
# ❌ WRONG - bypasses config
markdownlint /absolute/path/to/plugins/woocommerce/CLAUDE.md
markdownlint --fix path/to/file.md (auto-fixes most issues)markdownlint path/to/file.md| Code | Issue | Description | Fix |
|---|---|---|---|
| MD007 | List indentation | Wrong indentation level | Use 4 spaces for nested items |
| MD013 | Line length limit | Line exceeds 80 chars | Break into multiple lines |
| MD031 | Code blocks need blank lines | Missing blank lines | Add blank above/below code blocks |
| MD032 | Lists need blank lines | Missing blank lines | Add blank before/after lists |
| MD036 | Emphasis as heading | Using bold instead of heading | Use ### not bold |
| MD040 | Code needs language | Missing language spec | Add: ```bash, ```php, etc. |
| MD047 | Need trailing newline | File doesn't end with newline | File must end with newline |
NEVER allow control characters or null bytes into markdown files.
Use UTF-8 box-drawing characters, not spaces, tabs, or ASCII art:
✅ CORRECT - UTF-8 box-drawing:
.ai/skills/
├── woocommerce-backend/
│ ├── SKILL.md
│ └── file-entities.md
└── woocommerce-dev-cycle/
└── SKILL.md
❌ WRONG - ASCII art or spaces:
.ai/skills/
+-- woocommerce-backend/
| +-- SKILL.md
+-- file-entities.md
NEVER use Edit tool after markdownlint --fix if the file contains directory trees.
Always check file encoding first:
file path/to/file.md
# Should show: "UTF-8 text" or "ASCII text"
# NEVER: "data"
If a file becomes corrupted (shows as "data" instead of text):
# Remove control characters and null bytes
tr -d '\000-\037' < file.md > file.clean.md && mv file.clean.md file.md
# Verify encoding after fix
file file.md
Before:
```
pnpm test:php:env
```
After:
```bash
pnpm test:php:env
```
Common language specs:
bash - Shell commandsphp - PHP codejavascript or js - JavaScripttypescript or ts - TypeScriptjson - JSON datamarkdown or md - Markdown examplesBefore:
This is a very long line that exceeds the 80 character limit and needs to be broken into multiple lines for better readability.
After:
This is a very long line that exceeds the 80 character limit and needs to be
broken into multiple lines for better readability.
Before:
Some text here
```bash
command here
```
More text
After:
Some text here
```bash
command here
```
More text
markdownlint --fix automatically handles most issues