Skip to content

Quick Start

import { Steps } from ‘@astrojs/starlight/components’;

This guide walks you through the most common workflows with agent-md, from initial setup to running formatting, linting, and section queries.


Run agent-md init to generate a standard configuration file in your project root:

Terminal window
agent-md init

This creates .agent-md.json with recommended AI-friendly defaults. If an existing config already exists, pass --force to overwrite it:

Terminal window
agent-md init --force

Format any Markdown file in-place:

Terminal window
agent-md fmt README.md

By default, agent-md outputs structured JSON describing what was updated. To format an entire project directory recursively:

Terminal window
agent-md fmt .

agent-md automatically honors patterns in .markdownlintignore and .gitignore, skipping directories like node_modules, target/, and dist/.


Check if your Markdown adheres to AI-friendly standards:

Terminal window
agent-md lint README.md

Sample JSON output:

{
"valid": true,
"errors": [],
"warnings": []
}

If issues are detected (such as unclosed code fences, missing language tags, or bold text formatting), agent-md reports the line and column numbers:

{
"valid": false,
"errors": [
{
"line": 14,
"column": 1,
"message": "Bold text not allowed outside code blocks",
"rule": "no-bold"
}
],
"warnings": []
}

Add the global --human flag for formatted terminal output:

Terminal window
agent-md --human lint README.md

Rather than reading and writing entire large documents, agent-md lets you interact with individual headings.

Terminal window
agent-md headings README.md

Or extract the headings field using read:

Terminal window
agent-md read README.md --field headings

Fetch the content under a specific heading:

Terminal window
agent-md read README.md --content "## Installation"

For nested sections, use the > separator:

Terminal window
agent-md read README.md --content "## Installation > Build From Source"

Update or create a heading section without rewriting the rest of the file:

Terminal window
agent-md write-section README.md --section "## Installation" --content "Run `brew install agent-md` to install."

Quickly find lines containing a keyword or pattern:

Terminal window
agent-md search README.md "TODO"

Output:

{
"query": "TODO",
"matches": [
{
"line": 42,
"content": "- TODO: add integration tests"
}
],
"total": 1
}