Migrate Existing CLIs

Translate existing CLI patterns from argparse, Click, Typer, Fire, and Cobra into Milo.

1 min read 194 words

Use these recipes when you already have a CLI command and want to move it to Milo's typed function contract. Each page shows a small before/after and the specific concepts to translate.

Migration Rule

Move behavior first, then output polish:

  1. Convert one command handler into a typed Python function.
  2. Register it with@cli.command.
  3. Add docstringArgs: entries or Annotated[..., Description(...)].
  4. Runuv run milo verify app.py.
  5. Add the four command contract tests before migrating the next command.

Keep old CLI compatibility wrappers only where users depend on exact argv shape. Milo's main contract is the function signature; schema, MCP, and llms.txt are derived from that signature.

Recipes

The mature-CLI guide adds the inventory, phased cutover, output/exit contract, agent-surface allowlist, exact-version canary, and downstream release policy needed when preserving an established command tree.

Official References Checked

In This Section

Adopt Milo in a Mature CLI Migrate an established framework CLI without losing argv, output, exit, startup, or agent contracts.
From argparse Replace parser-first argparse code with typed Milo command handlers.
From Click Translate Click command decorators, options, groups, and context into Milo.
From Cobra Map Cobra command trees, flags, and generated app structure into Milo groups.
From Python Fire Narrow automatic Python object exposure into explicit Milo command contracts.
From Typer Move from type-hint CLI ergonomics to Milo's CLI/MCP/llms.txt contract.