Command Patterns Reference

The four command structures, when to use each, plus flag conventions and exit-code rules.

Command structures

PatternExampleUse when
verb-nouncreate-userDefault for most CLIs. Reads naturally; easy to scan in help output.
noun-verbuser-createLarge command sets where alphabetical grouping by resource matters.
verb-onlydoctorSingle-purpose commands with an obvious target: init, sync, doctor, login.
namespace verb (two-level)config setCLIs 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.2

Keep namespaces to one word (config, users, deploy) and verbs consistent across namespaces: list should mean the same thing under every namespace.

Flag conventions

FlagPurposeNotes
--help, -hShow command helpAvailable on every command, no exceptions.
--version, -vPrint versionTop-level command at minimum.
--verboseDetailed outputBoolean; takes no value.
--quiet, -qMinimal outputOpposite of --verbose; don't offer both on one command.
--output, -oOutput destinationFile path or format selector.
--jsonMachine-readable outputEssential for scripting; stable schema.
--dry-runPreview without changesOffer on every destructive command.
--force, -fSkip confirmationsNever the default for destructive actions.

Output and exit codes

  • Human-readable by default, structured with --json for 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.