agentleFS
juandelossantosjuandelossantos/another-agent-skills/skills/cli-tools/SKILL.md

cli-tools

Skill1 starsChanged 11 days agoMITView on GitHub

Build production-grade CLI tools with argument parsing, exit codes, colored output, progress, and error handling. Triggers: CLI, terminal, shell script. Do NOT use for GUI applications.

  • Reads credentials

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use a standard parser: Never parse argv manually.

    line 48
  2. Distinctive:

    Never exit 0 on failure: Every error path returns a non-zero code.

    line 74
  3. Very specific:

    Piped output must be clean: When stdout is piped, strip colors and progress indicators automatically.

    line 84
  4. Very specific:

    Use libraries: cli-spinners (Node), rich.progress (Python), indicatif (Rust)

    line 89

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

CLI Tools

A CLI without standards is a script no one wants to run.

This skill covers the patterns that separate professional CLI tools from ad-hoc scripts: predictable argument parsing, meaningful exit codes, colored output, progress indication, and proper error handling.

When to Use

MANDATORY when:

  • Building a new CLI tool or command
  • Adding a CLI interface to an existing project or service
  • Refactoring ad-hoc scripts into a proper CLI (argument parsing, exit codes, composability)
  • Creating developer tooling: scaffolds, code generators, linters, formatters, migration tools
  • Building a multi-command tool (git-style subcommands: tool <noun> <verb>)
  • Implementing automation that needs reliable exit codes and piped output (CI/CD, scripts)

User says: "build a CLI", "terminal app", "command line tool", "make a tool that...", "create a command"

When NOT to Use

  • GUI applications (desktop, web, mobile)
  • Simple one-off shell scripts (use a shell script directly)
  • Full-screen TUI applications (emacs, vim-style interactive interfaces)

Output Contract

ArtifactFormatLocationQuality Criteria
CLI tool source codeCLI executable (language-agnostic, framework-independent)src/cli/ or project rootStandard argument parser used, exit codes (0=success, non-zero=error), stdout for data + stderr for logs/errors, --help + --version flags, --quiet suppresses non-essential output, colors auto-suppressed when non-TTY (isatty), NO_COLOR env var respected, --json flag for machine-readable output, config file at ~/.config/<tool>/ with --config override, SIGINT handler for clean shutdown, -- separates options from positional args

Core Principles

1. Argument Parsing

Use a standard parser. Never parse argv manually.

LanguageLibrary
Node.jscommander, yargs, clack
Pythonclick, typer, argparse
Rustclap, structopt
Gocobra, urfave/cli
Bashgetopt (long options), argbash

Convention:

  • Flags before arguments (tool --verbose build)
  • -- separates options from positional args
  • -h / --help shows usage
  • -v / --version (unless -v is verbose)

2. Exit Codes

0   — Success
1   — General error
2   — Misuse (invalid args, wrong usage)
127 — Command not found
130 — Interrupted (Ctrl+C)

Never exit 0 on failure. Every error path returns a non-zero code.

3. Output Channels

StreamWhen
stdoutCommand output (data, results, lists)
stderrLogs, warnings, errors, progress
/dev/nullHide when --quiet is set

Piped output must be clean. When stdout is piped, strip colors and progress indicators automatically. Detect with: !isatty(sys.stdout).

4. Progress Indication

  • Tasks > 2s: show a spinner or progress bar
  • Use libraries: cli-spinners (Node), rich.progress (Python), indicatif (Rust)
  • Suppress when non-TTY or --quiet

5. Error Messages

❌ Error: File not found: /path/to/missing
   Hint: Check the path and try again. Use --help for options.

Format: [context] Error: [what happened] then optional hint on next line.

6. Configuration

  • ~/.config/<tool>/config.{json,yaml,toml} for user config
  • --config <path> to override
  • .env in project root for env vars
  • CLI_TOOL_* env vars with clear prefix

Language-Specific Patterns

→ See guides/LANGUAGE-GUIDE.md for code examples in Node.js (commander/clack), Python (click), Rust (clap), and Go (cobra).

Anti-Patterns

→ See guides/ANTI-SLOP-GUIDE.md for CLI-specific anti-patterns and best practices.

Verification

  • Uses standard argument parser
  • --help and --version work
  • Exit codes: 0 = success, non-zero = error
  • Errors go to stderr, results to stdout
  • Colors suppressed when non-TTY
  • --quiet silences non-essential output
  • Config file with --config override
  • README with install + usage + examples

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.