Use when adding new error messages to React, or seeing "unknown error code" warnings.
npx skills add MildTomato/agent-skills --skill "cli-guidelines"
Install specific skill from multi-skill repository
# Description
Design and build well-crafted command-line interfaces following modern best practices. This skill should be used when creating CLI tools, adding commands/subcommands, implementing help text, handling errors, parsing arguments/flags, or improving CLI UX. Triggers on tasks involving command-line tools, terminal interfaces, argument parsing, error handling, or CLI design.
# SKILL.md
name: cli-guidelines
description: Design and build well-crafted command-line interfaces following modern best practices. This skill should be used when creating CLI tools, adding commands/subcommands, implementing help text, handling errors, parsing arguments/flags, or improving CLI UX. Triggers on tasks involving command-line tools, terminal interfaces, argument parsing, error handling, or CLI design.
license: MIT
metadata:
author: CLI Guidelines
version: '1.0.0'
CLI Design Guidelines
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.
When to Apply
Reference these guidelines when:
- Creating new CLI tools or adding commands/subcommands
- Implementing help text and error handling
- Parsing arguments and flags
- Designing interactive prompts
- Setting up configuration systems
- Improving CLI UX and output formatting
- Reviewing CLI code for best practices
- Refactoring existing command-line tools
Rule Categories by Priority
| 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- |
Quick Reference
1. The Basics (CRITICAL)
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-hand--helpflagsbasics-full-flags- Have full-length versions of all flags
2. AI Agent Integration (CRITICAL)
agents-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-readable
3. Help & Documentation (CRITICAL)
help-concise-default- Display concise help when run with no argshelp-lead-examples- Lead with examples in help texthelp-suggest-corrections- Suggest corrections for typos
4. Output Formatting (HIGH)
output-tty-detection- Check if TTY before using colors/animationsoutput-json-flag- Support--jsonfor machine-readable outputoutput-plain-flag- Support--plainfor script-friendly outputoutput-state-changes- Tell the user when you change stateoutput-pager- Use a pager for long output
5. Error Handling (HIGH)
errors-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 modes
6. Arguments & Flags (HIGH)
args-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-independent
7. Interactivity (HIGH)
interactive-tty-check- Only prompt if stdin is a TTYinteractive-no-input-flag- Support--no-inputto disable promptsinteractive-password-no-echo- Don't echo passwords as user types
8. Signals & Control (HIGH)
signals-exit-on-ctrl-c- Exit immediately on Ctrl-Csignals-crash-only-design- Design for crash-only operation
9. Robustness (MEDIUM-HIGH)
robustness-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 operations
10. Subcommands (MEDIUM-HIGH)
subcommands-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 subcommands
11. Configuration (MEDIUM)
config-precedence- Follow precedence: Flags > Env vars > Project > User > Systemconfig-xdg-spec- Follow XDG Base Directory spec for config locations
12. Future-proofing (MEDIUM)
future-additive-changes- Keep changes additive (add flags, don't change behavior)
13. Naming & Distribution (LOW-MEDIUM)
naming-simple-memorable- Use simple, memorable, lowercase command namesnaming-distribute-single-binary- Distribute as single binary when possible
14. Help & Documentation (MEDIUM)
help-web-documentation- Provide web-based documentation
15. Analytics (MEDIUM)
analytics-no-phone-home- Don't phone home without consent
Philosophy
These are the fundamental principles of good CLI design:
- Human-first design - Design for humans, optimize for machines second
- Simple parts that work together - Composable via stdin/stdout/stderr, exit codes, JSON
- Consistency across programs - Follow existing patterns users already know
- Saying (just) enough - Not too much output, not too little
- Ease of discovery - Help users learn through suggestions, examples, clear errors
- Conversation as the norm - CLI interaction is iterative—guide the user through it
- Robustness - Handle failures gracefully, be responsive, feel solid
- Empathy - Be on the user's side, help them succeed
- Chaos - Know when to break the rules—do so with intention
Structure
This skill contains:
rules/- Focused, actionable rules- Each rule has frontmatter (title, impact, tags)
- Includes incorrect/correct code examples
- TypeScript/JavaScript examples with modern libraries
references/- Comprehensive topic guides (for deeper context)- Background documentation and detailed explanations
- Loaded by agents only when deeper understanding is needed
AGENTS.md- Complete compiled guide (auto-generated from rules)- All rules in one document
- Full table of contents
- Searchable reference
How to Use
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:
- Brief explanation of why it matters
- Incorrect code example with explanation
- Correct code example with explanation
- Additional context and implementation details
For deeper background, see reference files:
references/philosophy.md
references/basics.md
Full Compiled Document
For the complete guide with all rules expanded: AGENTS.md
Common Argument Parsing Libraries
| 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 |
Further Reading
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.