CLI Design
Great CLIs are boring: predictable flags, scriptable output, useful errors, and stable exit codes.
Principles
- Subcommands for verbs; flags for options.
- stdout for data; stderr for logs/progress.
--helpaccurate; examples in help.- Exit 0 success; non-zero for classes of failure.
--jsonor stable machine output when automation matters.- Sensible defaults; prompt only when interactive and needed.
- Never break scripts with decorative Unicode unless optional.
Output format
## CLI: <name>
### Commands
### Global flags
### Output contract
### Exit codes
### Examples
Rules
- Prefer composition over god flags.
- Document config file precedence.
- Color auto-detect;
--no-color. - Version with
--version. - Destructive commands need
--forceor confirm.
Edge cases
- Pipes: behave well in CI.
- Windows paths: accept both separators when reasonable.
- Plugins: discovery and naming.