Create command-line interface (CLI) tools following clig.dev best practices. Covers argument parsing, help text, error handling, output formatting, signals, and configuration. Supports Python (Click, Typer), Node.js (Commander), Go (Cobra), Rust (Clap), and Bash. Includes starter templates. DO NOT use for web applications, web servers, GUI apps, or long-running services.
Create excellent command-line interfaces following clig.dev best practices.
Determine the task type and follow the appropriate path:
Creating a new CLI? → Follow "New CLI" below Improving an existing CLI? → Follow "Improve Existing CLI" below
assets/templates/ into the user's project directory, rename to match the CLI nameshellcheck to validate correctness--json/--plain, NO_COLOR, exit codes, secretsshellcheck to validate correctness| Language | Framework | Best For | Reference |
|---|---|---|---|
| Python | Click | General purpose, decorator-based | references/python.md |
| Python | Typer | Type-hint based, modern | references/python.md |
| Python | argparse | No dependencies, simple CLIs | references/python.md |
| Node.js | Commander | Most popular, clean API | references/nodejs.md |
| Node.js | yargs | Feature-rich, complex CLIs | references/nodejs.md |
| Go | Cobra | Industry standard (kubectl, hugo, gh) | references/go.md |
| Rust | Clap | Derive or builder API | references/rust.md |
| Bash | getopts | Simple scripts, no dependencies | references/bash.md |
Copy the appropriate template into the user's project, rename, and customize the processing logic:
assets/templates/python-click-template.py — Python + Click (PEP 723, run with uvx)assets/templates/nodejs-commander-template.js — Node.js + Commanderassets/templates/go-cobra-template.go — Go + Cobraassets/templates/rust-clap-template.rs — Rust + Clapassets/templates/bash-template.sh — Bash + getoptsAll templates include: argument parsing, stdin/stdout support, error handling with exit codes, Ctrl+C handling, --verbose and --json flags, and NO_COLOR respect.
For multi-command tools (mycli init, mycli build, mycli deploy), read the subcommand section in the language-specific reference:
@click.group() or Typer app with multiple @app.command().command() or yargs .command()AddCommand() tree#[derive(Subcommand)] enumcase dispatch on $1 with per-command functionsRead these as needed for detailed patterns and examples: