Developing CLI Tools

Design command-line interfaces with TTY detection, output routing, and scriptable machine-readable modes.

Updated Dec 4, 2025
One-click install
npx skills add https://github.com/dallascrilley/dowser --skill developing-cli-tools-dallascrilley
Or copy as Structured Prompt for Agentā–¼
Please help me install this Agent Skill.
Skill: Developing CLI Tools
Source: https://github.com/dallascrilley/dowser/tree/main/skills/developing-cli-tools
Command: npx skills add https://github.com/dallascrilley/dowser --skill developing-cli-tools-dallascrilley

SYSTEM DOCUMENTATION & REQUIREMENTS

šŸ’” This Skill includes references (resource) components.

What problem does it solve? CLI tools often break in scripts and pipelines because they mix data with messages, emit color codes when piped, or require interactive prompts. This Skill provides the patterns and rules to build CLIs that work correctly for both terminal users and automation. ## Core Features & Use Cases - Output Routing & TTY Detection: Route data to stdout and messages to stderr, and disable colors, spinners, and progress bars when output is piped or NO_COLOR is set. - Help & Error Design: Implement help across all entry points (-h, --help, help subcommand) and structure errors with codes, remediation steps, and documentation links. - Scriptable Interfaces: Prefer flags over positional args, provide stable --json/--plain output modes, and ensure every prompt has a non-interactive flag alternative. - Use Case: When adding a deploy subcommand to a Node.js CLI, use this Skill to wire Commander.js flags, TTY-aware spinners, confirmation prompts with --force bypass, and JSON output for CI pipelines. ## Quick Start Use the developing-cli-tools skill to design a new subcommand with proper help text, stdout/stderr routing, and a --json output mode.

Frequently Asked Questions about Developing CLI Tools

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I make CLI output work in pipes and scripts?ā–¼

Send primary data and machine-readable output to stdout, and route all progress, prompts, warnings, and errors to stderr. Detect TTY status and disable colors, spinners, and animations when output is piped or NO_COLOR is set.

Should CLI commands use flags or positional arguments?ā–¼

Prefer named flags whenever more than one input type is involved, such as --from X --to Y instead of two positional args. Reserve positional arguments for homogeneous lists like file paths, where order is unambiguous.

Which CLI argument parsing libraries should I use?ā–¼

Use a mature parsing library rather than manual argv inspection: Commander.js or oclif for Node, Click or Typer for Python, Cobra for Go, and clap for Rust. These handle flags, help text, and error suggestions consistently.

Why does my CLI hang when run in CI or cron?ā–¼

The CLI likely requires an interactive prompt with no non-interactive alternative. Only prompt when stdin is a TTY, provide flag equivalents for every prompt, and support a --no-input flag to disable all interactivity.

How do I structure CLI error messages for users?ā–¼

Include an error code, short title, human-readable description, the exact command to fix the issue, and a documentation URL. Map major failure classes to distinct non-zero exit codes so scripts can differentiate error types.