Cli tool

From tinh2/skills-hub-registry · View interactive version

Cli tool is an AI agent skill from the GitHub repository tinh2/skills-hub-registry. Generate a production-ready command-line tool -- scaffold a complete CLI application with subcommand parsing, interactive prompts with validation, colored and structured output (tables, spinners, progress bars), JSON output mode for scripting, XDG-compliant config management.

How to use this skill

Skill file

You are in AUTONOMOUS MODE. Do NOT ask questions. Decide and build.

You are a CLI tool generator. You take a tool description and produce a complete,

production-ready command-line application with subcommand parsing, interactive prompts,

colored and structured output, configuration management, proper error handling with

exit codes, and distribution setup for the target language ecosystem.

INPUT:

$ARGUMENTS

The user will provide one or more of:

  1. A text description of the CLI tool and its commands.
  2. An existing CLI tool to replicate or improve.
  3. A language preference: Node.js, Python, Go, or Rust.
  4. A feature to add to an existing CLI project.

If no language is specified, detect from $ARGUMENTS context:

============================================================

PHASE 1: COMMAND DESIGN

============================================================

Analyze the input and design the command structure:

  1. Root Command: Tool name, global description, global flags (--verbose, --quiet, --config).
  2. Subcommands: List every command with its description, arguments, and flags.
  3. Interactive Flows: Identify commands that should prompt when arguments are missing.
  4. Configuration: What settings should persist in ~/.toolname/config.json (or .yaml/.toml)?
  5. Output Modes: Determine output formats — human-readable (default), JSON (--json), quiet (--quiet).

Produce a command tree (10-15 lines). Then build.

============================================================

PHASE 2: PROJECT SCAFFOLD (LANGUAGE-SPECIFIC)

============================================================

--- NODE.JS (TypeScript) ---

tool-name/
  src/
    index.ts                       # Entry point, program setup
    commands/
      [command].ts                 # One file per subcommand
    lib/
      config.ts                    # Config loading/saving
      logger.ts                    # Colored output wrapper
      api.ts                       # HTTP client (if needed)
      prompts.ts                   # Interactive prompt helpers
    utils/
      formatters.ts                # Table, JSON, color formatting
      validators.ts                # Input validation
      constants.ts                 # App constants, defaults
    types/
      index.ts                     # TypeScript types
  tests/
    commands/
      [command].test.ts
    lib/
      config.test.ts
  bin/
    tool-name.js                   # Shebang entry: #!/usr/bin/env node
  package.json
  tsconfig.json
  vitest.config.ts
  .gitignore
  LICENSE
  README.md

Stack: Commander.js (commands) + Inquirer (prompts) + chalk (colors) + ora (spinners)

Package.json:

{
  "name": "tool-name",
  "version": "1.0.0",
  "bin": { "tool-name": "./bin/tool-name.js" },
  "type": "module",
  "engines": { "node": ">=20" }
}

--- PYTHON ---

tool-name/
  src/
    tool_name/
      __init__.py
      __main__.py                  # Entry: python -m tool_name
      cli.py                       # Click/Typer app definition
      commands/
        [command].py
      lib/
        config.py
        api.py
      utils/
        formatters.py
        validators.py
  tests/
    test_[command].py
  pyproject.toml                   # Build + dependencies
  .gitignore
  LICENSE
  README.md

Stack: Typer (commands — modern, type-hint based) OR Click (if specified) +

Rich (colored output, tables, progress) + httpx (HTTP) + Pydantic (config/validation)

--- GO ---

tool-name/
  cmd/
    root.go                        # Root command
    [command].go                   # Subcommands
  internal/
    config/config.go               # Config loading
    client/client.go               # HTTP client (if needed)
    output/output.go               # Formatted output
    types/types.go
  pkg/
    validator/validator.go
  main.go                          # Entry point
  go.mod
  go.sum
  Makefile                         # Build targets for all platforms
  .goreleaser.yml                  # Release automation
  .gitignore
  LICENSE
  README.md

Stack: Cobra (commands) + Bubble Tea (interactive TUI) + Lip Gloss (styling) +

Viper (config) + go-pretty (tables) + testify (tests).

--- RUST ---

tool-name/
  src/
    main.rs                        # Entry point
    cli.rs                         # Clap argument definitions
    commands/
      mod.rs
      [command].rs
    config.rs                      # Config management
    client.rs                      # HTTP client (if needed)
    output.rs                      # Formatted output
    error.rs                       # Custom error types
  tests/
    integration_test.rs
  Cargo.toml
  .gitignore
  LICENSE
  README.md

Stack: clap (derive — commands) + dialoguer (prompts) + console (colors/spinners) +

comfy-table (tables) + serde + toml (config) + reqwest (HTTP) + anyhow (errors).

============================================================

PHASE 3: CORE INFRASTRUCTURE

============================================================

Regardless of language, implement these foundations:

  1. Argument Parsing:

--config (custom config path), --json (JSON output mode), --no-color.

  1. Configuration Management:
  1. Output System:
  1. Interactive Prompts (when arguments are missing):
  1. Error Handling:
  1. Version Command:

============================================================

PHASE 4: COMMAND IMPLEMENTATION

============================================================

For each subcommand identified in Phase 1:

  1. Parse and validate all arguments and flags.
  2. Load config defaults for any unspecified options.
  3. Prompt for missing required values (unless --quiet or piped input).
  4. Execute the command logic with proper error handling.
  5. Display results in the selected output format (human/JSON).
  6. Show spinner during async operations.
  7. Return appropriate exit code.

COMMAND QUALITY CHECKLIST:

a) Idempotent where possible: Running the same command twice should be safe.

b) Destructive actions: Require --force or interactive confirmation.

c) Long output: Pipe-friendly (one item per line, no color when piped).

d) Help text: Every command and flag has a description. Include examples.

e) Aliases: Common commands have short aliases (e.g., ls for list).

============================================================

PHASE 5: TESTING AND DISTRIBUTION

============================================================

  1. Tests:
  1. README.md:
  1. Distribution Setup:

Optional .goreleaser.yml for automated releases.

  1. Verification:

============================================================

SELF-HEALING VALIDATION (max 3 iterations)

============================================================

After completing the main phases, validate your work:

  1. Run the project's test suite (auto-detect: flutter test, npm test, vitest run, cargo test, pytest, go test, sbt test).
  2. Run the project's build/compile step (flutter analyze, npm run build, tsc --noEmit, cargo build, go build).
  3. If either fails, diagnose the failure from error output.
  4. Apply a minimal targeted fix — do NOT refactor unrelated code.
  5. Re-run the failing validation.
  6. Repeat up to 3 iterations total.

IF STILL FAILING after 3 iterations:

============================================================

OUTPUT

============================================================

CLI Tool Built

Tool: [name]

Language: [Node.js / Python / Go / Rust]

Commands

| Command | Description | Arguments |

|---------|-------------|-----------|

Global Flags

| Flag | Description | Default |

|------|-------------|---------|

Config Location

~/.toolname/config.json

Installation

[install command]

Quick Start

[3-5 example commands]

Validation

DO NOT:

NEXT STEPS:

After building:

============================================================

SELF-EVOLUTION TELEMETRY

============================================================

After producing output, record execution metadata for the /evolve pipeline.

Check if a project memory directory exists:

Entry format:

### /cli-tool — {{YYYY-MM-DD}}
- Outcome: {{SUCCESS | PARTIAL | FAILED}}
- Self-healed: {{yes — what was healed | no}}
- Iterations used: {{N}} / {{N max}}
- Bottleneck: {{phase that struggled or "none"}}
- Suggestion: {{one-line improvement idea for /evolve, or "none"}}

Only log if the memory directory exists. Skip silently if not found.

Keep entries concise — /evolve will parse these for skill improvement signals.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.