llms.txt Generation

Generate AI discovery documents from CLI command definitions.

1 min read 276 words

Milo can generate an llms.txt document from your CLI's registered commands. This gives AI agents a curated Markdown overview of what your tool can do.

Generating llms.txt

myapp --llms-txt

Output:

# myapp

> My tool

Version: 1.0.0

## Commands

- **greet**: Say hello
  Parameters: `--name` (string, required), `--loud` (boolean)

## Site Operations

- **build**: Build the site
  Parameters: `--output` (string)
- **serve**: Start dev server
  Parameters: `--port` (integer)

Structure

The output follows the llms.txt specification:

  1. Title — CLI name as# heading
  2. Description — CLI description as a blockquote
  3. Version — if set
  4. Commands — grouped by tag, then by command group
  5. Parameters — with types and required markers

Tags

Commands with tags are grouped under tag-derived headings:

@cli.command("deploy", description="Deploy the app", tags=("ops",))
def deploy(target: str) -> str: ...

@cli.command("rollback", description="Rollback", tags=("ops",))
def rollback(steps: int = 1) -> str: ...

Produces:

## Ops

- **deploy**: Deploy the app
  Parameters: `--target` (string, required)
- **rollback**: Rollback
  Parameters: `--steps` (integer)

Groups

Command groups produce nested headings:

## Site Operations

- **build**: Build the site

### Config Management

- **show**: Show merged config
- **set**: Update a config value

Programmatic generation

from milo import generate_llms_txt

text = generate_llms_txt(cli)

Hidden commands

Commands withhidden=Trueare excluded from the output.

Aliases

Command aliases appear in parentheses:

- **list** (ls): List all items

Tip

Pair--llms-txt with --mcpto give AI agents both a discovery document and a tool invocation interface. See MCP Server for the full MCP setup, including the gateway for multi-CLI projects.