One-page reference for CLI design. Print-friendly version of essential principles and patterns.
Obvious Over Clever β’ Helpful Over Minimal β’ Consistent Over Special β’ Human-First, Machine-Friendly
β‘ --help everywhere β‘ Examples in help β‘ Meaningful errors
β‘ Exit codes work β‘ Progress >1 second β‘ No config required
β‘ --json for machines β‘ --dry-run safety β‘ Piping workssimple-tool [options] <args> # curl, jq, grep
tool <command> [options] [args] # git, docker, npm
tool <resource> <action> [options] # kubectl, awsError: What went wrong
Why it happened
How to fix it
Example: tool <correct-usage>
# Default: Human readable
$ tool list
NAME STATUS TIME
app-1 running 2h ago
# Pipe: Auto plain text
$ tool list | grep running
app-1 running 2h
# Explicit: Machine format
$ tool list --json
[{"name":"app-1",...}]-h, --help Help text
-v, --version Version info
-v, --verbose More output
-q, --quiet Less output
-y, --yes No prompts
-n, --dry-run Preview only
--json JSON output
--no-color Plain text# Spinner (unknown duration)
Loading... β Ό
# Bar (known duration)
[ββββββββββ] 80% ETA: 2s
# Steps (multiple ops)
β Build complete
β Tests passed
β Ό Deploying...- Add examples to help text
- Show progress for operations >1s
- Suggest fixes in error messages
- Support --dry-run for safety
- Auto-detect TTY vs pipe
β Mystery commands: mkcfg 3 p
β Useless errors: Error: ENOENT
β No feedback: deploying... (5 min)
β Required config for basics
β Breaking pipes and scripts
Need subcommands? β More than 5 operations
Interactive mode? β Complex/dangerous operations
JSON output? β Always offer via flag
Color output? β Only in TTY, respect NO_COLOR
Config files? β Optional with good defaults
- Works with no arguments
- Pipes chain correctly
- Errors are helpful
- --help is comprehensive
- Exit codes meaningful
- Works on Win/Mac/Linux
Principles β’ Patterns β’ Anti-Patterns β’ Quick Start
Based on clig.dev, Atlassian, GNU, and Heroku guidelines. Keep this handy when designing CLIs!