Real-World Formatting & Linting Examples
import { Tabs, TabItem } from ‘@astrojs/starlight/components’;
This guide demonstrates concrete examples of how agent-md transforms bloated Markdown into concise, LLM-optimized documents.
Example 1: Full Document Transformation
Section titled “Example 1: Full Document Transformation”Input: Typical Human/LLM Markdown
Section titled “Input: Typical Human/LLM Markdown”Here is a standard Markdown document generated by human authors or older AI templates:
# My Project
## Overview
This is a really awesome project with many outstanding features:
| Feature | Description | Status ||:---|:---|:---|| API | Complete RESTful API | ✅ Complete || UI | Modern user interface | 🚧 In Progress || Tests | Unit tests and integration tests | ✅ Complete |
### Steps to Follow
1. Clone repository2. Install dependencies: `bun i`3. Run server: `bun dev`
>Note: Make sure you have Node.js 22+ installed!Running the Linter
Section titled “Running the Linter”agent-md lint document.mdThe linter detects token-wasting patterns:
{ "valid": false, "errors": [ { "line": 8, "column": 1, "message": "Complex table alignment detected", "rule": "table-syntax" } ], "warnings": []}Running the Formatter
Section titled “Running the Formatter”agent-md fmt document.mdOutput: AI-Friendly Markdown
Section titled “Output: AI-Friendly Markdown”# My Project
## Overview
This is a really awesome project with many outstanding features:
| Feature | Description | Status ||---|---|---|| API | Complete RESTful API | (Complete) || UI | Modern user interface | (In Progress) || Tests | Unit tests and integration tests | (Complete) |
## Steps to Follow
1. Clone repository2. Install dependencies: `bun i`3. Run server: `bun dev`
Note: Make sure you have Node.js 22+ installed.Result Analysis
Section titled “Result Analysis”- Token count: Reduced by ~18–22%.
- Table normalization: Separator line stripped from
:---:to|---|---|. - Spacing: No redundant trailing spaces or padding inside table cells.
- Section Extraction: Clean headings allow instant retrieval via
agent-md read document.md --content "## Steps to Follow".
Example 2: Nested Shell Scripts and Indentation
Section titled “Example 2: Nested Shell Scripts and Indentation”Input:
Section titled “Input:”# Setup scriptbun install # Install all packagesbun run build # Build production bundlesbun test # Run all integration testsOutput:
Section titled “Output:”# Setup scriptbun install # Install all packagesbun run build # Build production bundlesbun test # Run all integration testsThe formatter collapses multi-space gaps before # comments into a single space, saving 6–10 tokens on every commented line.
Example 3: Directory Tree Structures
Section titled “Example 3: Directory Tree Structures”Input:
Section titled “Input:”my-app/├── public/│ ├── favicon.svg│ └── robots.txt├── src/│ ├── index.ts│ └── utils.ts└── package.jsonOutput:
Section titled “Output:”my-app/├─public/│ ├─favicon.svg│ └─robots.txt├─src/│ ├─index.ts│ └─utils.ts└─package.json- Replaces three-byte UTF-8 glyphs
├──and└──with compact two-character markers├─and└─. - Strips empty spacer lines and standardizes branch indentation.