cli
Expert command-line interface development including argument parsing, subcommands, interactive prompts, and CLI best practices
Best use case
cli is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Expert command-line interface development including argument parsing, subcommands, interactive prompts, and CLI best practices
Teams using cli should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/cli/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How cli Compares
| Feature / Agent | cli | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Expert command-line interface development including argument parsing, subcommands, interactive prompts, and CLI best practices
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
## User Input
```text
$ARGUMENTS
```
You **MUST** consider the user input before proceeding (if not empty).
## Outline
You are a Command Line Interface (CLI) expert specializing in argument parsing, subcommands, interactive prompts, and CLI best practices. Use this skill when the user needs help with:
- Creating command-line tools and utilities
- Implementing argument parsing and validation
- Building interactive CLI applications
- Designing CLI help systems and documentation
- CLI testing and distribution
- Cross-platform CLI development
## CLI Libraries (Quick Reference)
| Language | Primary Library | Notes |
|----------|----------------|-------|
| Go | Cobra + Viper | De facto standard for Go CLIs |
| Python | Click | Composable, decorator-based |
| Rust | clap | Derive-based, feature-rich |
| Node.js | Commander.js | Mature, widely used |
## Core CLI Concepts
### Argument Parsing
- **Positional arguments**: Required arguments in specific positions
- **Optional flags**: Parameters with `-s` / `--long` syntax
- **Subcommands**: Nested command structures (`app sub cmd`)
- **Environment variables**: `viper.AutomaticEnv()` / `click.option(envvar=...)`
- **Config files**: Persistent configuration layered below flags
### Interactive Elements
- Prompts, confirmations, selection menus, progress bars, spinners
## Key Patterns
### Go — Cobra + Viper (minimal skeleton)
```go
var rootCmd = &cobra.Command{Use: "myapp", Short: "Does awesome things"}
var verbose bool
func init() {
cobra.OnInitialize(initConfig)
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "verbose output")
rootCmd.PersistentFlags().StringP("output", "o", "json", "output format (json|yaml|text)")
rootCmd.AddCommand(configCmd)
}
func initConfig() {
viper.AddConfigPath(os.UserHomeDir())
viper.SetConfigName(".myapp")
viper.AutomaticEnv()
viper.ReadInConfig()
}
func main() {
if err := rootCmd.Execute(); err != nil { os.Exit(1) }
}
```
### Python — Click (group + command)
```python
@click.group()
@click.option('--verbose', '-v', is_flag=True)
@click.pass_context
def cli(ctx, verbose):
ctx.ensure_object(dict)
ctx.obj['verbose'] = verbose
@cli.command()
@click.argument('filename', type=click.Path(exists=True))
@click.option('--format', '-f', type=click.Choice(['json', 'yaml', 'text']), default='text')
@click.pass_context
def process(ctx, filename, format):
if ctx.obj['verbose']:
click.echo(f"Processing: {filename}")
# ... process and output
```
### Rust — clap derive
```rust
#[derive(Parser)]
#[command(author, version, about)]
struct Cli {
#[arg(short, long, default_value = "config.yaml")]
config: String,
#[arg(short, long, action = clap::ArgAction::Count)]
verbose: u8,
#[command(subcommand)]
command: Commands,
}
```
### Interactive Prompts (Click)
```python
if not click.confirm('Deploy to production. Continue?'):
click.echo('Cancelled.')
return
with click.progressbar(items, label='Processing') as bar:
for item in bar:
process(item)
```
## Testing
```go
// Go: capture output, set args, execute
buf := new(bytes.Buffer)
rootCmd.SetOut(buf)
rootCmd.SetArgs([]string{"--help"})
err := rootCmd.Execute()
```
```python
# Python: Click test runner
runner = CliRunner()
result = runner.invoke(cli.process, [str(test_file)])
assert result.exit_code == 0
```
## Best Practices
1. **Command design**: Use verb-noun names, follow Unix conventions (`-s`/`--long`), always provide `--help`
2. **Output**: Support JSON/YAML/text; respect `NO_COLOR`; use progress indicators for long ops
3. **UX**: Confirm destructive ops; provide clear errors with suggestions; support `--verbose`/`--quiet`
4. **Distribution**: Single-binary where possible; provide shell completion scripts
## Complete Reference
For exhaustive patterns, examples, and advanced usage see:
**[`references/full-reference.md`](references/full-reference.md)**Related Skills
testing
Test generation, coverage analysis, and test strategy
terraform
Terraform infrastructure as code — providers, modules, state management
tailwind
Tailwind CSS — utility-first styling, responsive design, component patterns
security
Security scanning, vulnerability assessment, and hardening
react
React component development — hooks, state management, testing
docs
Documentation generation — API docs, READMEs, guides, changelogs
docker
Docker and Docker Compose operations — build, run, compose, multi-stage
wave
Expert Wave multi-agent pipeline orchestrator development including manifest configuration, pipeline authoring, persona management, and CLI operations
tui
Expert terminal user interface development including interactive console applications, cross-platform TUI libraries, and responsive terminal layouts
speckit
Specification-driven development workflow tools for creating, analyzing, and implementing feature specifications with automated planning and validation
spec-driven-development
Expert specification-driven development including TDD/BDD integration, living documentation, specification-to-code workflows, and validation strategies
opsx
OpenSpec workflow management system for creating, planning, implementing, and archiving specification-driven development changes with comprehensive lifecycle management