Create CLI
Design CLI surface area (syntax + behavior), agent-aware, human-friendly.
Phase 1 — Prepare
Read ${CLAUDE_PLUGIN_ROOT}/skills/create-cli/references/cli-guidelines.md and
${CLAUDE_PLUGIN_ROOT}/skills/create-cli/references/language-selection.md.
Apply cli-guidelines.md as the default CLI rubric; use language-selection.md during Phase 2
to inform the language recommendation.
Proceed when both files are loaded.
Phase 2 — Clarify
Ask, then proceed with best-guess defaults if user is unsure:
- Command name + one-sentence purpose.
- Primary consumer: agent/LLM, human at a terminal, scripted automation, or mixed.
- 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.
- Language & distribution: ask for the user's preferred implementation language, or offer to
recommend one. Ask whether a single binary (no runtime needed on target machine) is required,
or whether a runtime dependency is acceptable. Apply language-selection.md to recommend if
the user is unsure. Platform: macOS/Linux/Windows.
If an existing CLI spec or tool description is provided, read it first — skip questions already answered by it.
Proceed when answers are confirmed or user is unsure — use best-guess defaults.
Phase 3 — Conventions
Apply these unless the user says otherwise:
Output
- Detect TTY: pretty/colored output when stdout is a TTY; structured JSON when piped/non-TTY (agents are always non-TTY).
--json and --human available as explicit overrides.
- List commands: NDJSON (one JSON object per line) in non-TTY mode, not a JSON array — enables streaming and
jq piping without buffering.
- Primary data to stdout; diagnostics/errors to stderr.
- Suppress ANSI codes, progress spinners, and decorative output in non-TTY mode.
Errors
- Non-TTY error object on stderr:
{"error": "<snake_case_code>", "message": "...", "hint": "<exact CLI invocation or null>"} — so agent callers can route recovery logic without parsing free-text stderr. The hint field must be an executable command, not prose.
- Exit codes:
0 success, 1 runtime error, 2 invalid usage; add command-specific codes only when genuinely useful.
Flags
-h/--help always shows help; ignores other args.
--version prints version to stdout.
- Consistent flag names across all subcommands for the same concept (
--id, --force, --json) — agents learn the naming pattern once and apply it everywhere without guessing.
- Prompts only when stdin is a TTY;
--no-input disables prompts.
- Destructive operations: interactive confirmation; non-interactive requires
--force.
- Respect
NO_COLOR, TERM=dumb; provide --no-color.
- Handle Ctrl-C: exit fast; bounded cleanup; crash-only when possible.
Reduce tool calls
- Compound output: operations return enough data to avoid a follow-up call.
create returns the new resource's ID and key fields. delete echoes what was removed.
- Rich non-TTY defaults: in JSON mode, return full objects not just IDs.
- Idempotent by default: where possible, commands are safe to repeat; document preconditions explicitly — agents rely on safe retries for error recovery without human intervention.
For deeper context on the reasoning behind these conventions, read ${CLAUDE_PLUGIN_ROOT}/skills/create-cli/references/agent-aware-design.md.
Apply all conventions, then proceed to Phase 4.
Phase 4 — Deliver
For audits of existing CLIs, produce a gap report (violations + recommended changes) rather than a full spec. For new designs, produce a compact spec the user can implement. Include all relevant sections:
- 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).
Use this skeleton, dropping irrelevant sections:
- Language & distribution:
Go · cobra · single binary · goreleaser for CI
(Omit if language was not determined.)
- 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)
--human (force human output when piped) / --json (force JSON when TTY) — if TTY auto-detection applies
- 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:
See ${CLAUDE_PLUGIN_ROOT}/skills/create-cli/examples/example-cli-spec.md for a complete worked example.
If the spec is destined for a skill body or CLAUDE.md, omit unused sections entirely (do not mark them "N/A") and limit examples to ≤5 invocations that each demonstrate multiple patterns.
Skill is complete when the spec or gap report is delivered.
Notes
- Once language is selected (Phase 2), include the idiomatic parsing library in the spec (see language-selection.md). If language remains undetermined, omit the library.
- If the request is "design parameters", do not drift into implementation.
1---2name: create-cli-23description: This skill should be used when the user asks to "design a CLI", "help me design command-line flags", "what flags should my tool have", "create a CLI spec", "refactor my CLI interface", "design a CLI my agent can call", or wants to design command-line UX (args/flags/subcommands/help/output/errors/config) before implementation or audit an existing CLI surface for consistency and composability.4---56# Create CLI78Design CLI surface area (syntax + behavior), agent-aware, human-friendly.910## Phase 1 — Prepare1112Read `${CLAUDE_PLUGIN_ROOT}/skills/create-cli/references/cli-guidelines.md` and13`${CLAUDE_PLUGIN_ROOT}/skills/create-cli/references/language-selection.md`.14Apply cli-guidelines.md as the default CLI rubric; use language-selection.md during Phase 215to inform the language recommendation.1617Proceed when both files are loaded.1819## Phase 2 — Clarify2021Ask, then proceed with best-guess defaults if user is unsure:2223- Command name + one-sentence purpose.24- Primary consumer: agent/LLM, human at a terminal, scripted automation, or mixed.25- Input sources: args vs stdin; files vs URLs; secrets (never via flags).26- Output contract: human text, `--json`, `--plain`, exit codes.27- Interactivity: prompts allowed? need `--no-input`? confirmations for destructive ops?28- Config model: flags/env/config-file; precedence; XDG vs repo-local.29- Language & distribution: ask for the user's preferred implementation language, or offer to30 recommend one. Ask whether a single binary (no runtime needed on target machine) is required,31 or whether a runtime dependency is acceptable. Apply language-selection.md to recommend if32 the user is unsure. Platform: macOS/Linux/Windows.3334If an existing CLI spec or tool description is provided, read it first — skip questions already answered by it.3536Proceed when answers are confirmed or user is unsure — use best-guess defaults.3738## Phase 3 — Conventions3940Apply these unless the user says otherwise:4142### Output43- Detect TTY: pretty/colored output when stdout is a TTY; structured JSON when piped/non-TTY (agents are always non-TTY). `--json` and `--human` available as explicit overrides.44- List commands: NDJSON (one JSON object per line) in non-TTY mode, not a JSON array — enables streaming and `jq` piping without buffering.45- Primary data to stdout; diagnostics/errors to stderr.46- Suppress ANSI codes, progress spinners, and decorative output in non-TTY mode.4748### Errors49- Non-TTY error object on stderr: `{"error": "<snake_case_code>", "message": "...", "hint": "<exact CLI invocation or null>"}` — so agent callers can route recovery logic without parsing free-text stderr. The `hint` field must be an executable command, not prose.50- Exit codes: `0` success, `1` runtime error, `2` invalid usage; add command-specific codes only when genuinely useful.5152### Flags53- `-h/--help` always shows help; ignores other args.54- `--version` prints version to stdout.55- Consistent flag names across all subcommands for the same concept (`--id`, `--force`, `--json`) — agents learn the naming pattern once and apply it everywhere without guessing.56- Prompts only when stdin is a TTY; `--no-input` disables prompts.57- Destructive operations: interactive confirmation; non-interactive requires `--force`.58- Respect `NO_COLOR`, `TERM=dumb`; provide `--no-color`.59- Handle Ctrl-C: exit fast; bounded cleanup; crash-only when possible.6061### Reduce tool calls62- Compound output: operations return enough data to avoid a follow-up call. `create` returns the new resource's ID and key fields. `delete` echoes what was removed.63- Rich non-TTY defaults: in JSON mode, return full objects not just IDs.64- Idempotent by default: where possible, commands are safe to repeat; document preconditions explicitly — agents rely on safe retries for error recovery without human intervention.6566For deeper context on the reasoning behind these conventions, read `${CLAUDE_PLUGIN_ROOT}/skills/create-cli/references/agent-aware-design.md`.6768Apply all conventions, then proceed to Phase 4.6970## Phase 4 — Deliver7172For audits of existing CLIs, produce a gap report (violations + recommended changes) rather than a full spec. For new designs, produce a compact spec the user can implement. Include all relevant sections:7374- Command tree + USAGE synopsis.75- Args/flags table (types, defaults, required/optional, examples).76- Subcommand semantics (what each does; idempotence; state changes).77- Output rules: stdout vs stderr; TTY detection; `--json`/`--plain`; `--quiet`/`--verbose`.78- Error + exit code map (top failure modes).79- Safety rules: `--dry-run`, confirmations, `--force`, `--no-input`.80- Config/env rules + precedence (flags > env > project config > user config > system).81- Shell completion story (if relevant): install/discoverability; generation command or bundled scripts.82- 5–10 example invocations (common flows; include piped/stdin examples).8384Use this skeleton, dropping irrelevant sections:85860. **Language & distribution**: `Go` · `cobra` · single binary · `goreleaser` for CI87 *(Omit if language was not determined.)*881. **Name**: `mycmd`892. **One-liner**: `...`903. **USAGE**:91 - `mycmd [global flags] <subcommand> [args]`924. **Subcommands**:93 - `mycmd init ...`94 - `mycmd run ...`955. **Global flags**:96 - `-h, --help`97 - `--version`98 - `-q, --quiet` / `-v, --verbose` (define exactly)99 - `--human` (force human output when piped) / `--json` (force JSON when TTY) — if TTY auto-detection applies1006. **I/O contract**:101 - stdout:102 - stderr:1037. **Exit codes**:104 - `0` success105 - `1` generic failure106 - `2` invalid usage (parse/validation)107 - (add command-specific codes only when actually useful)1088. **Env/config**:109 - env vars:110 - config file path + precedence:1119. **Examples**:112 - …113114See `${CLAUDE_PLUGIN_ROOT}/skills/create-cli/examples/example-cli-spec.md` for a complete worked example.115116If the spec is destined for a skill body or CLAUDE.md, omit unused sections entirely (do not mark them "N/A") and limit examples to ≤5 invocations that each demonstrate multiple patterns.117118Skill is complete when the spec or gap report is delivered.119120## Notes121122- Once language is selected (Phase 2), include the idiomatic parsing library in the spec (see language-selection.md). If language remains undetermined, omit the library.123- If the request is "design parameters", do not drift into implementation.