Command Patterns Reference
The four command structures, when to use each, plus flag conventions and exit-code rules.
Command structures
| Pattern | Example | Use when |
|---|---|---|
verb-noun | create-user | Default for most CLIs. Reads naturally; easy to scan in help output. |
noun-verb | user-create | Large command sets where alphabetical grouping by resource matters. |
verb-only | doctor | Single-purpose commands with an obvious target: init, sync, doctor, login. |
namespace verb (two-level) | config set | CLIs with distinct domains; mirrors docker and gcloud style. |
All four are one click away in the command name generator — generate a batch in each structure and compare.
Two-level namespaces
terminal — two-level examples
mycli config set --key theme --value dark
mycli config get --key theme
mycli users invite --email ada@example.com
mycli deploy rollback --to v1.4.2Keep namespaces to one word (config, users, deploy) and verbs consistent across namespaces: list should mean the same thing under every namespace.
Flag conventions
| Flag | Purpose | Notes |
|---|---|---|
--help, -h | Show command help | Available on every command, no exceptions. |
--version, -v | Print version | Top-level command at minimum. |
--verbose | Detailed output | Boolean; takes no value. |
--quiet, -q | Minimal output | Opposite of --verbose; don't offer both on one command. |
--output, -o | Output destination | File path or format selector. |
--json | Machine-readable output | Essential for scripting; stable schema. |
--dry-run | Preview without changes | Offer on every destructive command. |
--force, -f | Skip confirmations | Never the default for destructive actions. |
Output and exit codes
- Human-readable by default, structured with
--jsonfor scripts. - Errors go to stderr, with what failed and how to fix it — not just a stack trace.
- Exit 0 on success, non-zero on failure, documented per command.
- Don't hang silently. Show progress for long operations; confirm state changes briefly.
Consistency across subcommands matters more than any single choice: same flag names, same output formats, same error style. Users learn the pattern once and apply it everywhere.