Production CLI Builder: Flags, Exit Codes, Completions

Build CLIs that script cleanly: command tree, flags, exit codes, stdout/stderr split, TTY-aware prompts, and shell completions.

Development / Engineeringclicommand-line-tools
by AgentVoltv1.0.0
Free to sign up · every skill included with AgentVolt Pro

Before & after

Same prompt, same agent — the only difference is the skill.

Prompt“Build a command-line tool to migrate data from our old system to the new one.”
Beforegeneric AI agent
I can help you build a CLI tool for data migration. You'd want to handle command arguments, probably with subcommands for different migration stages. You could add progress indication as the migration runs. Error handling would be important to catch any issues. You might want to add logging so users can see what's happening. I could use a library like commander.js for argument parsing. Do you want the tool in Node.js, Python, or another language? What does the migration flow look like?
Afterwith Production CLI Builder: Flags, Exit Codes, Completions
CLI TOOL: legacy-migrate v1.0

USAGE:
  legacy-migrate COMMAND OPTIONS

COMMANDS:
  legacy-migrate validate      Check source system connectivity, schema match
  legacy-migrate dry-run       Simulate migration, report diffs without writing
  legacy-migrate execute       Run full migration with checkpoints
  legacy-migrate rollback      Revert to snapshot from prior migration
  legacy-migrate status        Show current migration progress

EXAMPLE INVOCATION:
  legacy-migrate execute --source legacy-db.prod --dest new-db.prod --batch-size 1000 --timestamp-field updated_at

OPTIONS:
  --batch-size               Rows per transaction (default 500)
  --timestamp-field          Field to detect incremental changes
  --skip-validation          Skip pre-flight checks (not recommended)
  --workers                  Parallel workers (1-8, default 4)
  --dry-run                  Show what would migrate, no writes
  --log-file                 Path to migration log (default ./migrate.log)
  --verbose, -v              Detailed output (debug level)

OUTPUT (real-time):
  ✓ Connected to source (legacy-db.prod)
  ✓ Connected to dest (new-db.prod)
  ✓ Schema validation passed
  → Migrating users table (14,243 rows)
    Progress: 14,243/18,000 (79%)
    Rate: 2,350 rows/sec | ETA: 1m 36s
  ✓ users: 14,243 migrated, 0 skipped, 0 failed
  → Migrating orders table (412,841 rows)
    Progress: 412,841/512,000 (81%)
    Rate: 3,100 rows/sec | ETA: 31s

FEATURES:
• Cross-platform (Mac, Linux, Windows)
• Bash/Zsh/Fish completion: source <(legacy-migrate --completion bash)
• Checkpoints every 10K rows, resumable on failure
• Exit code 0 on success, non-zero on error

About this skill

Your CLI works when you run it by hand. Then it hangs in CI waiting on a prompt, the spinner corrupts piped output, and every failure exits 0. This skill designs and builds command-line tools that behave correctly for both humans and scripts, in click/typer, commander/yargs/oclif, cobra, or clap.

What it does

  • Designs the command tree, flag names, and positional arguments before writing code, so the interface stays consistent as it grows
  • Separates data (stdout) from logs, progress, and prompts (stderr), and adds a stable --json mode for scripting
  • Sets meaningful exit codes, including usage errors and Ctrl-C, and writes error messages that say what failed and how to fix it
  • Makes prompts, color, and progress bars TTY-aware, respects NO_COLOR, and fails fast instead of hanging in CI
  • Applies config precedence (flags, env, project file, user file, defaults), keeps secrets out of flags, and handles stdin with -
  • Wires up framework-native bash/zsh/fish completions, including dynamic completion of resource names

What you get

Working CLI code for your framework, plus a command and flag map, an exit code table, and test cases that check exit codes and stream separation. If you paste an existing CLI, you get a prioritized review with fixes.

Best for

Developers shipping internal tools, deploy scripts, or public CLIs in Python, Node, Go, or Rust who need them to work in pipelines, not just in their own terminal.

SKILL.md preview

SKILL.md
---
name: production-cli-builder
description: Designs and implements command-line tools that behave correctly for humans and scripts - command tree and flag design, stdout/stderr separation, exit codes, TTY-aware prompts and progress, config precedence, and shell completions in click/typer, commander/yargs/oclif, cobra, or clap. Use when the user says "build me a CLI", "add subcommands to my tool", "add a --json output flag", "generate zsh completions for my CLI", "my CLI hangs in CI waiting for input", "my progress bar garbles piped output", "my script always exits 0 even when it fails", or "review my argparse setup".
---

# Production CLI Builder: Flags, Exit Codes, Completions

… (sign up to view the full skill)
Sign up to view, copy, and install the full skill

More development skills

View all Development skills →