CLI Best Practices
Rules for CLIs that are discoverable, scriptable, and respectful of user time.
Search across all documentation pages
Rules for CLIs that are discoverable, scriptable, and respectful of user time.
--help examples for every subcommandmyapp deploy, not myapp --deploy.--verbose / -v across all subcommands.--yes / --no-input for CI and scripts.As many as needed, but each should be discoverable via --help.
No. Interactive only when explicitly requested or no args provided for wizard.
argparse for simple/zero-dep. Click/Typer for multi-command production tools.
Warning on use, document in help, remove in next major version.
-v once = INFO, twice = DEBUG. Log to stderr.
Env var or prompt with hidden input. Never argv flags.
CliRunner/typer testing for integration. Unit test core logic separately.
--version on every tool. Consistent across your CLI suite.
Default auto. --no-color and NO_COLOR=1 support.
Concise per-flag. Link to docs for long examples.
Stack versions: This page was written for Python 3.14.0, FastAPI 0.115+, Django 5.2, Flask 3.1, Pydantic 2, PyTorch 2.6+, pandas 2.2+, Polars 1.x, ruff 0.9+, and uv 0.6+.
Reviewed by Chris St. John·Last updated Jul 19, 2026