"Build fast, user-friendly CLI tools with stable command surfaces, predictable output contracts (stdout vs stderr), and cross-platform behavior. Covers subcommands/flags, config precedence, interactive prompts, progress indicators, and shell completions. Use when designing or implementing CLI tools."
Resources
2Install
npx skillscat add dmonteroh/curated-agent-skills/cli-tools Install via the SkillsCat registry.
SKILL.md
CLI Tools Skill
Provides guidance for designing and implementing command-line tools that are safe to script, pleasant for humans, and stable over time.
Use this skill when
- Designing a CLI command surface (subcommands/flags/args)
- Implementing argument parsing and validation
- Adding interactive prompts (with non-interactive fallbacks)
- Adding progress indicators, spinners, and TTY-aware colors
- Adding shell completions
Do not use this skill when
- The task is not a CLI/terminal tool
- The task is designing a GUI/web UX
Required inputs
- Target language/runtime and packaging constraints
- User personas (human, automation, or both)
- Expected output formats (human text, JSON, files)
- Platform constraints (OS, shell, terminal limitations)
Non-Negotiable Rules
- stdout is for primary output (pipe-friendly). Logs/errors go to stderr.
- Always support
--helpand--version. - Make flags consistent across subcommands.
- Validate inputs early; fail fast with actionable errors.
- Never require interactivity in CI: provide flags/env alternatives.
- Disable color/progress when output is not a TTY.
- Handle SIGINT (Ctrl+C) gracefully and exit with standard codes.
Workflow (Deterministic)
- Define the command surface and examples.
- Output: command/flag matrix draft with brief intent.
- Define output contract (human vs machine; consider
--json).- Output: stdout/stderr expectations and exit code table.
- Define config precedence (flags > env > config > defaults).
- Output: precedence list and config locations.
- Implement parsing + validation.
- Output: validation rules and error messages.
- Implement core behavior.
- Output: primary command behaviors with success/failure paths.
- Polish: help text, errors, completions, TTY behavior.
- Output: updated help/usage strings and TTY checks.
- Test: golden
--help, JSON schema/snapshots, cross-platform smoke test.- Output: test list with owners and expected results.
Decision points
- If the CLI is used in automation, default to machine-readable output and add
--format. - If the command can be destructive, require confirmation or
--yesfor non-interactive runs. - If interactive prompts are needed, always provide flag/env fallbacks.
Common pitfalls
- Mixing logs with primary output (breaks piping).
- Inconsistent flags across subcommands.
- Prompting in CI or non-TTY environments.
- Non-deterministic output ordering (breaks tests).
Output Contract (Always)
- A command/flag matrix (what exists and why).
- Output behavior (stdout/stderr + exit codes).
- Validation and error-handling approach.
- Test plan (at least for help and primary commands).
Examples
Example: add a new subcommand
Input
Add a "list" subcommand that outputs JSON for automation.Output
- Command matrix: list [--json] [--limit]
- stdout: JSON array when --json, table otherwise
- stderr: validation/errors only
- exit codes: 0 success, 2 validation, 1 runtimeReporting format
Summary:
- Command/flag matrix
- Output behavior and exit codes
- Validation rules
- Test plan
Notes:
- Pitfalls avoided
- Decision points appliedResources (Optional)
- End-to-end playbook + CLI spec template:
resources/implementation-playbook.md - Reference index:
references/README.md - Command surface patterns:
references/command-hierarchy-and-flags.md - UX help text patterns:
references/ux-help-text.md - Language notes:
- Node:
references/node-frameworks.md - Python:
references/python-frameworks.md - Go:
references/go-frameworks.md
- Node: