name: cli-design description: Design, review, and improve CLI interfaces following clig.dev guidelines. Use when building CLI tools, commands, flags, or help text — especially with Cobra/Viper in Go. Triggers on requests to create CLI tools, add commands, design flag interfaces, write help text, or improve CLI user experience. Make sure to load reference files from references/ when designing specific areas like output, errors, or configuration.
CLI Design
Apply clig.dev principles to create command-line interfaces that are intuitive, consistent, and user-friendly.
Core Principles
1. Design for Humans First
CLIs are used by humans, not just scripted. Prioritize clarity and learnability over terseness.
Do:
- Use clear, descriptive names (
--output-filenot-o) - Provide helpful defaults that "just work"
- Make error messages actionable
Don't:
- Require memorization of arcane flags
- Fail silently or with cryptic codes
- Break conventions that users expect
2. Be Consistent
Follow established CLI conventions. Users transfer knowledge between tools.
Patterns to follow:
--helpfor assistance--versionfor version info--verbose/-vfor more output--quiet/-qfor less output--dry-runto preview changes- stdin/stdout via
-(e.g.,cmd -)
3. Make Discovery Easy
Users should find functionality without reading manuals.
Checklist:
- Help text is comprehensive and shows examples
- Subcommands document their purpose
- Common workflows work without flags
- Suggestions appear in error messages
4. Respect Configuration Precedence
Users expect this order (highest to lowest):
- Flags (command-line arguments)
- Environment variables
- Project config (
.env, local config files) - User config (
~/.config/app/) - System config
Design Checklist
When building or reviewing a CLI, check each area:
Flags & Arguments
- Flags over positional arguments for optional values
- Full flag names are readable (
--max-retriesnot--mr) - Short flags for commonly used options (
-c,-f,-v) - Boolean flags are clearly false when omitted
-
-reads from stdin / writes to stdout
Output
- Human-readable by default
-
--jsonflag for machine-readable output -
--plainor--no-colorfor scripting - Progress indicators for long operations
-
--verboseincreases detail,--quietreduces it
Errors
- Errors explain what happened and why
- Errors suggest how to fix them
- Errors are human-readable, not raw stack traces
- Exit codes are documented (0 = success, non-zero = error)
Help Text
- Shows common usage patterns
- Explains what each flag does
- Includes examples
- Links to full documentation
Configuration
- Uses XDG paths for user config (
~/.config/app/) - Environment variables documented
- Config file format documented
Reference Files
Load these for detailed guidance:
| Area | File |
|---|---|
| Output design | references/output.md |
| Error messages | references/errors.md |
| Flag design | references/flags.md |
| Configuration | references/configuration.md |
| Compatibility | references/compatibility.md |
Quick CLI Review
When asked to review a CLI, use this order:
- Install/run — Does it work out of the box?
--help— Is help clear and complete?- Common tasks — Can you do the obvious thing without flags?
- Error handling — What happens with bad input?
- Flags — Do they follow conventions?
- Output — Is it readable? Is
--jsonavailable?
For Go Projects (Cobra/Viper)
Per AGENTS.md, this codebase uses:
github.com/spf13/cobrafor commandsgithub.com/spf13/viperfor configuration
Ensure your CLI follows these in addition to clig.dev:
- Viper reads env vars with
automaticEnv()andSetEnvPrefix() - Cobra root command sets
SilenceUsage: trueto avoid spamming help on errors - Use
cobra.OnInitialize()for setup logic