Markdown Writing Rules
import { Tabs, TabItem } from ‘@astrojs/starlight/components’;
agent-md validates Markdown against a strict set of rules designed to maximize token efficiency, prevent parsing ambiguities, and optimize document structure for AI agents.
Error Rules (Block Content)
Section titled “Error Rules (Block Content)”Error rules cause agent-md lint to return "valid": false and block write operations.
1. no-bold
Section titled “1. no-bold”- Severity: Error
- Reason: Bold markers (
**text**and__text__) add zero semantic signal to an LLM while inflating token counts by 2–4 tokens per emphasized phrase. - Scope: Outside code blocks. Code blocks and inline code spans are exempt.
Invalid:
Section titled “Invalid:”This is **critical** information.Please check the __status__ flag.Valid Alternatives:
Section titled “Valid Alternatives:”This is critical information.Please check the `status` flag.2. heading-structure
Section titled “2. heading-structure”- Severity: Error
- Reason: Multiple H1 headings confuse document hierarchy and table-of-contents parsers. Skipped heading levels (e.g., jumping from
## H2to#### H4) break section extraction logic.
Invalid:
Section titled “Invalid:”# First Title# Second Title (Multiple H1s forbidden)
## Main Section#### Deeply Nested (Skipped H3 level)Valid:
Section titled “Valid:”# Document Title
## Main Section### Sub Section#### Deeply Nested Subsection3. table-syntax & simple-table-syntax
Section titled “3. table-syntax & simple-table-syntax”- Severity: Error
- Reason: Complex table structures with extra alignment colons (
:---:) or mismatched column counts waste tokens and frequently cause markdown parsing failures.
Rules:
Section titled “Rules:”- Normal separator rows must use
|---|---|without colons. - Tables should not exceed 6 columns.
- Every row must match the column count of the header.
- Cells should avoid complex block-level nesting.
Invalid:
Section titled “Invalid:”| Name | Type | Value | Extra | Options | Notes | Debug ||:-----|:----:|------:|:------|:--------|:------|:------|| one | two | three |Valid:
Section titled “Valid:”| Name | Type | Value | Notes ||---|---|---|---|| one | two | three | four |4. table-trailing-spaces
Section titled “4. table-trailing-spaces”- Severity: Error
- Reason: Invisible trailing spaces at the end of table cells consume tokens without rendering any visible difference.
Invalid:
Section titled “Invalid:”| Name | Value ||---|---|| foo | bar |Valid:
Section titled “Valid:”| Name | Value ||---|---|| foo | bar |5. no-ascii-graphs
Section titled “5. no-ascii-graphs”- Severity: Error
- Reason: Visual ASCII art diagrams, unicode boxes, and complex line-drawn flowcharts consume hundreds of tokens that LLMs struggle to parse accurately.
- Alternative: Use structured lists, tables, or standard Mermaid code blocks.
Invalid:
Section titled “Invalid:”+------------+ +------------+| ComponentA | ---> | ComponentB |+------------+ +------------+Valid:
Section titled “Valid:”graph LR ComponentA --> ComponentB6. code-blocks
Section titled “6. code-blocks”- Severity: Error
- Reason: Fenced code blocks without language tags prevent syntax highlighting and hinder LLM code-block parsers. Unclosed fences corrupt the remainder of the document.
Rules:
Section titled “Rules:”- Every opening fence (
```) must specify an explicit language identifier (e.g.,bash,rust,json, or default totext). - Every code block must have a matching closing fence.
Invalid:
Section titled “Invalid:”```echo "hello world"Valid:
Section titled “Valid:”```bashecho "hello world"```7. list-formatting
Section titled “7. list-formatting”- Severity: Error
- Reason: Inconsistent list markers (
*,+,-) or irregular numbering within the same list create formatting noise.
Invalid:
Section titled “Invalid:”- First item* Second item with different bullet+ Third item with yet another bulletValid:
Section titled “Valid:”- First item- Second item- Third item8. space-indentation
Section titled “8. space-indentation”- Severity: Error
- Reason: Indenting regular text by 4 spaces causes Markdown parsers to treat it as an legacy indented code block.
- Rule: Limit regular paragraph indentation to 2 spaces. Nested lists should use 2 spaces per indentation level.
9. no-useless-links
Section titled “9. no-useless-links”- Severity: Error
- Reason: Writing
[https://example.com](https://example.com)duplicates the entire URL string in the token stream. - Alternative: Use standard Markdown autolinks:
<https://example.com>.
Invalid:
Section titled “Invalid:”Visit [https://github.com/loclv/agent-md](https://github.com/loclv/agent-md)Valid:
Section titled “Valid:”Visit <https://github.com/loclv/agent-md>Warning Rules (Style Guidelines)
Section titled “Warning Rules (Style Guidelines)”Warnings indicate stylistic deviations that do not prevent operations:
no-duplicate-headings
Section titled “no-duplicate-headings”- Severity: Warning
- Reason: Two identical heading names within the same document break anchor links and ambiguous section path lookups.
no-multiple-blanks
Section titled “no-multiple-blanks”- Severity: Warning
- Reason: More than one consecutive blank line wastes vertical space and context tokens.