Design and build well-crafted command-line interfaces following modern best practices...
Comprehensive guide to designing command-line interfaces following modern best practices. Based on the Command Line Interface Guidelines. Prioritized by impact to guide CLI development and code review.
Reference these guidelines when:
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | The Basics | CRITICAL | basics- |
| 2 | AI Agent Integration | CRITICAL | agents- |
| 3 | Help & Documentation | CRITICAL | help- |
| 4 | Output Formatting | HIGH | output- |
| 5 | Error Handling | HIGH | errors- |
| 6 | Arguments & Flags | HIGH | args- |
| 7 | Interactivity | HIGH | interactive- |
| 8 | Signals & Control | HIGH | signals- |
| 9 | Robustness | MEDIUM-HIGH | robustness- |
| 10 | Subcommands | MEDIUM-HIGH | subcommands- |
| 11 | Configuration | MEDIUM | config- |
| 12 | Future-proofing | MEDIUM | future- |
| 13 | Naming & Distribution | LOW-MEDIUM | naming- |
| 14 | Documentation | MEDIUM | help- |
| 15 | Analytics | MEDIUM | analytics- |
basics-use-parsing-library - Use argument parsing library (don't roll your own)basics-exit-codes - Return 0 on success, non-zero on failurebasics-stdout-stderr - Send output to stdout, messages/errors to stderrbasics-help-flags - Support -h and --help flagsbasics-full-flags - Have full-length versions of all flagsagents-json-required - Always support --json for agent consumptionagents-structured-errors - Provide structured error informationagents-exit-codes-documented - Document all exit codesagents-no-prompts-default - Avoid interactive prompts, use flagsagents-yes-flag - Provide --yes flag to skip confirmationsagents-progress-to-stderr - Send progress to stderr, data to stdoutagents-deterministic-output - Ensure deterministic, versioned outputagents-dry-run - Provide --dry-run for safetyagents-help-machine-readable - Make help text machine-readablehelp-concise-default - Display concise help when run with no argshelp-lead-examples - Lead with examples in help texthelp-suggest-corrections - Suggest corrections for typosoutput-tty-detection - Check if TTY before using colors/animationsoutput-json-flag - Support --json for machine-readable outputoutput-plain-flag - Support --plain for script-friendly outputoutput-state-changes - Tell the user when you change stateoutput-pager - Use a pager for long outputerrors-rewrite-for-humans - Catch errors and rewrite for humanserrors-signal-to-noise - Maintain signal-to-noise ratio in error outputerrors-important-info-end - Put important info at end of outputerrors-exit-code-mapping - Map exit codes to failure modesargs-prefer-flags - Prefer flags over positional argumentsargs-standard-names - Use standard flag names (-f/--force, -n/--dry-run)args-no-secrets-flags - Don't read secrets from flags (use files or stdin)args-stdin-stdout - Accept - to read from stdin / write to stdoutargs-order-independent - Make flags order-independentinteractive-tty-check - Only prompt if stdin is a TTYinteractive-no-input-flag - Support --no-input to disable promptsinteractive-password-no-echo - Don't echo passwords as user typessignals-exit-on-ctrl-c - Exit immediately on Ctrl-Csignals-crash-only-design - Design for crash-only operationrobustness-100ms-response - Print something within 100msrobustness-progress-indicators - Show progress for long operationsrobustness-validate-early - Validate input early, fail fastrobustness-idempotent - Make operations idempotent/recoverablerobustness-network-timeouts - Set timeouts on network operationssubcommands-consistency - Be consistent across subcommands (same flags, output)subcommands-consistent-verbs - Use consistent verbs (create/get/update/delete)subcommands-no-abbreviations - Don't allow arbitrary abbreviationssubcommands-no-catch-all - Don't have catch-all subcommandsconfig-precedence - Follow precedence: Flags > Env vars > Project > User > Systemconfig-xdg-spec - Follow XDG Base Directory spec for config locationsfuture-additive-changes - Keep changes additive (add flags, don't change behavior)naming-simple-memorable - Use simple, memorable, lowercase command namesnaming-distribute-single-binary - Distribute as single binary when possiblehelp-web-documentation - Provide web-based documentationanalytics-no-phone-home - Don't phone home without consentThese are the fundamental principles of good CLI design:
This skill contains:
rules/ - Focused, actionable rulesreferences/ - Comprehensive topic guides (for deeper context)AGENTS.md - Complete compiled guide (auto-generated from rules)Read individual rule files for specific guidance:
rules/basics-use-parsing-library.md
rules/agents-json-required.md
rules/output-tty-detection.md
Each rule file contains:
For deeper background, see reference files:
references/philosophy.md
references/basics.md
For the complete guide with all rules expanded: AGENTS.md
| Language | Libraries |
|---|---|
| Node | oclif, commander |
| Go | Cobra, urfave/cli |
| Python | Click, Typer, argparse |
| Rust | clap |
| Ruby | TTY |
| Java | picocli |
| Swift | swift-argument-parser |
| Multi-platform | docopt |