Create CLI
Design CLI surface area (syntax + behavior), human-first, script-friendly.
Do This First
Clarify (fast)
Ask, then proceed with best-guess defaults if user is unsure:
- Command name + one-sentence purpose.
- Primary user: humans, scripts, or both.
- Input sources: args vs stdin; files vs URLs; secrets (never via flags).
- Output contract: human text,
--json, --plain, exit codes.
- Interactivity: prompts allowed? need
--no-input? confirmations for destructive ops?
- Config model: flags/env/config-file; precedence; XDG vs repo-local.
- Platform/runtime constraints: macOS/Linux/Windows; single binary vs runtime.
Deliverables (what to output)
When designing a CLI, produce a compact spec the user can implement:
- Command tree + USAGE synopsis.
- Args/flags table (types, defaults, required/optional, examples).
- Subcommand semantics (what each does; idempotence; state changes).
- Output rules: stdout vs stderr; TTY detection;
--json/--plain; --quiet/--verbose.
- Error + exit code map (top failure modes).
- Safety rules:
--dry-run, confirmations, --force, --no-input.
- Config/env rules + precedence (flags > env > project config > user config > system).
- Shell completion story (if relevant): install/discoverability; generation command or bundled scripts.
- 5–10 example invocations (common flows; include piped/stdin examples).
Default Conventions (unless user says otherwise)
-h/--help always shows help and ignores other args.
--version prints version to stdout.
- Primary data to stdout; diagnostics/errors to stderr.
- Add
--json for machine output; consider --plain for stable line-based text.
- Prompts only when stdin is a TTY;
--no-input disables prompts.
- Destructive operations: interactive confirmation + non-interactive requires
--force or explicit --confirm=....
- Respect
NO_COLOR, TERM=dumb; provide --no-color.
- Handle Ctrl-C: exit fast; bounded cleanup; be crash-only when possible.
Templates (copy into your answer)
CLI spec skeleton
Fill these sections, drop anything irrelevant:
- Name:
mycmd
- One-liner:
...
- USAGE:
mycmd [global flags] <subcommand> [args]
- Subcommands:
mycmd init ...
mycmd run ...
- Global flags:
-h, --help
--version
-q, --quiet / -v, --verbose (define exactly)
--json / --plain (if applicable)
- I/O contract:
- Exit codes:
0 success
1 generic failure
2 invalid usage (parse/validation)
- (add command-specific codes only when actually useful)
- Env/config:
- env vars:
- config file path + precedence:
- Examples:
Notes
- Prefer recommending a parsing library (language-specific) only when asked; otherwise keep this skill language-agnostic.
- If the request is “design parameters”, do not drift into implementation.
1---2name: create-cli3description: CLI UX/spec: args, flags, help, output, errors, config, dry-run.4---5
6# Create CLI
7
8Design CLI surface area (syntax + behavior), human-first, script-friendly.
9
10## Do This First
11
12- Read `agent-scripts/skills/create-cli/references/cli-guidelines.md` and apply it as the default rubric.
13- Upstream/full guidelines: https://clig.dev/ (propose changes: https://github.com/cli-guidelines/cli-guidelines)
14- Ask only the minimum clarifying questions needed to lock the interface.
15
16## Clarify (fast)
17
18Ask, then proceed with best-guess defaults if user is unsure:
19
20- Command name + one-sentence purpose.
21- Primary user: humans, scripts, or both.
22- Input sources: args vs stdin; files vs URLs; secrets (never via flags).
23- Output contract: human text, `--json`, `--plain`, exit codes.
24- Interactivity: prompts allowed? need `--no-input`? confirmations for destructive ops?
25- Config model: flags/env/config-file; precedence; XDG vs repo-local.
26- Platform/runtime constraints: macOS/Linux/Windows; single binary vs runtime.
27
28## Deliverables (what to output)
29
30When designing a CLI, produce a compact spec the user can implement:
31
32- Command tree + USAGE synopsis.
33- Args/flags table (types, defaults, required/optional, examples).
34- Subcommand semantics (what each does; idempotence; state changes).
35- Output rules: stdout vs stderr; TTY detection; `--json`/`--plain`; `--quiet`/`--verbose`.
36- Error + exit code map (top failure modes).
37- Safety rules: `--dry-run`, confirmations, `--force`, `--no-input`.
38- Config/env rules + precedence (flags > env > project config > user config > system).
39- Shell completion story (if relevant): install/discoverability; generation command or bundled scripts.
40- 5–10 example invocations (common flows; include piped/stdin examples).
41
42## Default Conventions (unless user says otherwise)
43
44- `-h/--help` always shows help and ignores other args.
45- `--version` prints version to stdout.
46- Primary data to stdout; diagnostics/errors to stderr.
47- Add `--json` for machine output; consider `--plain` for stable line-based text.
48- Prompts only when stdin is a TTY; `--no-input` disables prompts.
49- Destructive operations: interactive confirmation + non-interactive requires `--force` or explicit `--confirm=...`.
50- Respect `NO_COLOR`, `TERM=dumb`; provide `--no-color`.
51- Handle Ctrl-C: exit fast; bounded cleanup; be crash-only when possible.
52
53## Templates (copy into your answer)
54
55### CLI spec skeleton
56
57Fill these sections, drop anything irrelevant:
58
591. **Name**: `mycmd`
602. **One-liner**: `...`
613. **USAGE**:
62 - `mycmd [global flags] <subcommand> [args]`
634. **Subcommands**:
64 - `mycmd init ...`
65 - `mycmd run ...`
665. **Global flags**:
67 - `-h, --help`
68 - `--version`
69 - `-q, --quiet` / `-v, --verbose` (define exactly)
70 - `--json` / `--plain` (if applicable)
716. **I/O contract**:
72 - stdout:
73 - stderr:
747. **Exit codes**:
75 - `0` success
76 - `1` generic failure
77 - `2` invalid usage (parse/validation)
78 - (add command-specific codes only when actually useful)
798. **Env/config**:
80 - env vars:
81 - config file path + precedence:
829. **Examples**:
83 - …
84
85## Notes
86
87- Prefer recommending a parsing library (language-specific) only when asked; otherwise keep this skill language-agnostic.
88- If the request is “design parameters”, do not drift into implementation.