# Migrate Existing CLIs

URL: /milo-cli/docs/get-started/migrate-existing-cli/
Section: migrate-existing-cli
Description: Translate existing CLI patterns from argparse, Click, Typer, Fire, and Cobra into Milo.

---

> For a complete page index, fetch /milo-cli/llms.txt.

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.

From argparse

Replace parser-first argparse code with typed Milo command handlers.

(/milo-cli/docs/get-started/migrate-existing-cli/from-argparse/)

From Click

Translate Click command decorators, options, groups, and context into Milo.

(/milo-cli/docs/get-started/migrate-existing-cli/from-click/)

From Typer

Move from type-hint CLI ergonomics to Milo's CLI/MCP/llms.txt contract.

(/milo-cli/docs/get-started/migrate-existing-cli/from-typer/)

From Python Fire

Narrow automatic Python object exposure into explicit Milo command contracts.

(/milo-cli/docs/get-started/migrate-existing-cli/from-fire/)

From Cobra

Map Cobra command trees, flags, and generated app structure into Milo groups.

(/milo-cli/docs/get-started/migrate-existing-cli/from-cobra/)

## Migration Rule

Move behavior first, then output polish:

- Convert one command handler into a typed Python function.

- Register it with`@cli.command`.

- Add docstring`Args:` entries or `Annotated[..., Description(...)]`.

- Run`uv run milo verify app.py`.

- 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

- From argparse (/milo-cli/docs/get-started/migrate-existing-cli/from-argparse/)

- From Click (/milo-cli/docs/get-started/migrate-existing-cli/from-click/)

- From Typer (/milo-cli/docs/get-started/migrate-existing-cli/from-typer/)

- From Python Fire (/milo-cli/docs/get-started/migrate-existing-cli/from-fire/)

- From Cobra (/milo-cli/docs/get-started/migrate-existing-cli/from-cobra/)

## Official References Checked

- argparse documentation (https://docs.python.org/3/library/argparse.html)

- Click commands and groups (https://click.palletsprojects.com/en/stable/commands-and-groups/)

- Typer first steps (https://typer.tiangolo.com/tutorial/first-steps/)

- Python Fire guide (https://google.github.io/python-fire/guide/)

- Cobra getting started (https://cobra.dev/docs/tutorials/getting-started/)

## In This Section

From argparse (/milo-cli/docs/get-started/migrate-existing-cli/from-argparse/)

Replace parser-first argparse code with typed Milo command handlers.

From Click (/milo-cli/docs/get-started/migrate-existing-cli/from-click/)

Translate Click command decorators, options, groups, and context into Milo.

From Cobra (/milo-cli/docs/get-started/migrate-existing-cli/from-cobra/)

Map Cobra command trees, flags, and generated app structure into Milo groups.

From Python Fire (/milo-cli/docs/get-started/migrate-existing-cli/from-fire/)

Narrow automatic Python object exposure into explicit Milo command contracts.

From Typer (/milo-cli/docs/get-started/migrate-existing-cli/from-typer/)

Move from type-hint CLI ergonomics to Milo's CLI/MCP/llms.txt contract.

migration (/milo-cli/tags/migration/)

cli (/milo-cli/tags/cli/)
