$npx -y skills add Jeffallan/claude-skills --skill cli-developerUse when building CLI tools, implementing argument parsing, or adding interactive prompts. Invoke for parsing flags and subcommands, displaying progress bars and spinners, generating bash/zsh/fish completion scripts, CLI design, shell completions, and cross-platform terminal appl
| 1 | # CLI Developer |
| 2 | |
| 3 | ## Core Workflow |
| 4 | |
| 5 | 1. **Analyze UX** — Identify user workflows, command hierarchy, common tasks. Validate by listing all commands and their expected `--help` output before writing code. |
| 6 | 2. **Design commands** — Plan subcommands, flags, arguments, configuration. Confirm flag naming is consistent and no existing signatures are broken. |
| 7 | 3. **Implement** — Build with the appropriate CLI framework for the language (see Reference Guide below). After wiring up commands, run `<cli> --help` to verify help text renders correctly and `<cli> --version` to confirm version output. |
| 8 | 4. **Polish** — Add completions, help text, error messages, progress indicators. Verify TTY detection for color output and graceful SIGINT handling. |
| 9 | 5. **Test** — Run cross-platform smoke tests; benchmark startup time (target: <50ms). |
| 10 | |
| 11 | ## Reference Guide |
| 12 | |
| 13 | Load detailed guidance based on context: |
| 14 | |
| 15 | | Topic | Reference | Load When | |
| 16 | |-------|-----------|-----------| |
| 17 | | Design Patterns | `references/design-patterns.md` | Subcommands, flags, config, architecture | |
| 18 | | Node.js CLIs | `references/node-cli.md` | commander, yargs, inquirer, chalk | |
| 19 | | Python CLIs | `references/python-cli.md` | click, typer, argparse, rich | |
| 20 | | Go CLIs | `references/go-cli.md` | cobra, viper, bubbletea | |
| 21 | | UX Patterns | `references/ux-patterns.md` | Progress bars, colors, help text | |
| 22 | |
| 23 | ## Quick-Start Example |
| 24 | |
| 25 | ### Node.js (commander) |
| 26 | |
| 27 | ```js |
| 28 | #!/usr/bin/env node |
| 29 | // npm install commander |
| 30 | const { program } = require('commander'); |
| 31 | |
| 32 | program |
| 33 | .name('mytool') |
| 34 | .description('Example CLI') |
| 35 | .version('1.0.0'); |
| 36 | |
| 37 | program |
| 38 | .command('greet <name>') |
| 39 | .description('Greet a user') |
| 40 | .option('-l, --loud', 'uppercase the greeting') |
| 41 | .action((name, opts) => { |
| 42 | const msg = `Hello, ${name}!`; |
| 43 | console.log(opts.loud ? msg.toUpperCase() : msg); |
| 44 | }); |
| 45 | |
| 46 | program.parse(); |
| 47 | ``` |
| 48 | |
| 49 | For Python (click/typer) and Go (cobra) quick-start examples, see `references/python-cli.md` and `references/go-cli.md`. |
| 50 | |
| 51 | ## Constraints |
| 52 | |
| 53 | ### MUST DO |
| 54 | - Keep startup time under 50ms |
| 55 | - Provide clear, actionable error messages |
| 56 | - Support `--help` and `--version` flags |
| 57 | - Use consistent flag naming conventions |
| 58 | - Handle SIGINT (Ctrl+C) gracefully |
| 59 | - Validate user input early |
| 60 | - Support both interactive and non-interactive modes |
| 61 | - Test on Windows, macOS, and Linux |
| 62 | |
| 63 | ### MUST NOT DO |
| 64 | |
| 65 | - **Block on synchronous I/O unnecessarily** — use async reads or stream processing instead. |
| 66 | - **Print to stdout when output will be piped** — write logs/diagnostics to stderr. |
| 67 | - **Use colors when output is not a TTY** — detect before applying color: |
| 68 | ```js |
| 69 | // Node.js |
| 70 | const useColor = process.stdout.isTTY; |
| 71 | ``` |
| 72 | ```python |
| 73 | # Python |
| 74 | import sys |
| 75 | use_color = sys.stdout.isatty() |
| 76 | ``` |
| 77 | ```go |
| 78 | // Go |
| 79 | import "golang.org/x/term" |
| 80 | useColor := term.IsTerminal(int(os.Stdout.Fd())) |
| 81 | ``` |
| 82 | - **Break existing command signatures** — treat flag/subcommand renames as breaking changes. |
| 83 | - **Require interactive input in CI/CD environments** — always provide non-interactive fallbacks via flags or env vars. |
| 84 | - **Hardcode paths or platform-specific logic** — use `os.homedir()` / `os.UserHomeDir()` / `Path.home()` instead. |
| 85 | - **Ship without shell completions** — all three frameworks above have built-in completion generation. |
| 86 | |
| 87 | ## Output Templates |
| 88 | |
| 89 | When implementing CLI features, provide: |
| 90 | 1. Command structure (main entry point, subcommands) |
| 91 | 2. Configuration handling (files, env vars, flags) |
| 92 | 3. Core implementation with error handling |
| 93 | 4. Shell completion scripts if applicable |
| 94 | 5. Brief explanation of UX decisions |
| 95 | |
| 96 | ## Knowledge Reference |
| 97 | |
| 98 | CLI frameworks (commander, yargs, oclif, click, typer, argparse, cobra, viper), terminal UI (chalk, inquirer, rich, bubbletea), testing (snapshot testing, E2E), distribution (npm, pip, homebrew, releases), performance optimization |
| 99 | |
| 100 | [Documentation](https://jeffallan.github.io/claude-skills/skills/devops/cli-developer/) |