Generate CLI Command

VerifiedSafe

Generates a complete CLI command scaffold including argument parsing, handler, help text, and tests. Adapts to the project's framework and conventions.

Sby Skills Guide Bot
DevelopmentIntermediate
7/27/2026
Claude CodeCursorCodex
#cli#scaffolding#code-generation#argument-parsing#testing

Recommended for

Automated summary

Generates a new CLI command (argument definitions, handler, help text and tests) while matching the framework and conventions already used in the project.

Strengths

  • Detects the existing CLI framework (Cobra, Clap, Click, Typer, Commander, Yargs) before generating anything
  • Requires reading AGENTS.md and existing commands so the output copies real project patterns instead of inventing new ones
  • Covers the full chain: flag declarations, registration on the root command, business logic kept out of the CLI plumbing, and 0/1/2 exit codes
  • Ships per-ecosystem file path conventions (Go, Rust, Python, Node) plus a final validation checklist

Limitations

  • The detection script only knows a fixed list of frameworks and skips argparse or in-house CLI wrappers
  • Does not address side concerns such as shell completion, man pages or config files
  • Assumes a command tree already exists, so it adds little value on a brand-new CLI project
When to use it

Use it when adding a subcommand to an existing CLI whose framework and conventions are already settled.

When not to use it

Avoid it for bootstrapping a CLI from scratch or for a framework the detection script does not recognize.

Security analysis

Safe
Quality score86/100

The skill is a normal CLI scaffolding guide. Its embedded script only inspects project files with grep and prints framework/path hints; it does not perform network calls, delete files, exfiltrate secrets, or disable safety controls. File creation/editing is expected for scaffolding and is not inherently risky.

Findings
  • •No allowed-tools are declared even though the skill includes a bash script; the script only uses grep/echo for framework detection and is not destructive.
How this analysis is made

Examples

Add a deploy command (Go/Cobra)
Create a new `deploy` subcommand in our Cobra CLI. It needs a required --env string flag, a --dry-run bool, a short -o output flag, clear help text with examples, and tests covering flag parsing and exit codes. Follow the patterns of our existing commands.
Add a migrate command (Python/Typer)
Add a `migrate` command to our Typer CLI with a --steps int flag defaulting to 1. Register it under the `db` subcommand group, keep the business logic in the existing service layer, and write tests for required-arg validation and help output.
Scaffold a config subcommand (Node/Commander)
Scaffold a `config` command with `get` and `set` subcommands in our Commander-based CLI, including argument validation, help text and tests verifying that invalid usage returns exit code 2.

name: scaffold-cli description: Generate CLI command with argument parsing, handler, help text, and tests type: scaffold project_types: [cli] trigger: "create command, add CLI command, create subcommand" inputs:

  • name: name description: Command/subcommand name (e.g. init, deploy, migrate) required: true
  • name: description description: Short description of what the command does required: false default: ""
  • name: args description: Arguments and flags description (e.g. "--output -o string, --verbose bool") required: false default: ""

Context

Project {{project_name}} is a CLI application using {{stack}}. You will create a new command "{{input.name}}".

Read AGENTS.md for conventions. Read existing commands to understand patterns.

Instructions

  1. Analyze existing command patterns

    • Read existing command files
    • Identify: argument parsing library (cobra, clap, click, commander, argparse, etc.)
    • Identify: command registration pattern (subcommands, router, etc.)
    • Identify: output formatting (table, JSON, plain text, colored)
    • Note error handling patterns (exit codes, stderr vs stdout)
  2. Create command file

    • Path: according to project convention
      • Go (cobra): cmd/{{input.name}}.go or internal/cmd/{{input.name}}.go
      • Rust (clap): src/commands/{{input.name}}.rs
      • Python (click): src/commands/{{input.name}}.py
      • Node (commander): src/commands/{{input.name}}.ts
    • Implement:
      • Command definition with name, description, aliases
      • Argument/flag parsing with validation
      • Help text with usage examples
      • Handler function with business logic
  3. Create argument/flag definitions

    • Define all required and optional flags
    • Set proper types (string, bool, int, etc.)
    • Add short aliases where appropriate (-o for --output)
    • Set sensible defaults
    • Add validation for required args
  4. Register command

    • Add to root command / command registry
    • Ensure it shows up in --help output
    • Set up proper parent-child relationship for subcommands
  5. Implement handler logic

    • Separate business logic from CLI plumbing
    • Use project's existing service/logic layer
    • Handle errors gracefully with helpful messages
    • Respect --quiet/--verbose flags if they exist
    • Use proper exit codes (0 = success, 1 = error, 2 = usage error)
  6. Create tests

    • Path: according to convention
    • Test cases:
      • Command executes successfully with valid args
      • Help text is correct
      • Required args validation works
      • Flag parsing works correctly
      • Error cases return proper exit codes
      • Output format is correct

Script

#!/bin/bash
# Detect CLI framework
if [ -f "go.mod" ]; then
  if grep -q "cobra" go.mod 2>/dev/null; then
    echo "Framework: Cobra (Go)"
    echo "Command path: cmd/{{input.name}}.go"
  elif grep -q "urfave/cli" go.mod 2>/dev/null; then
    echo "Framework: urfave/cli (Go)"
  fi
elif [ -f "Cargo.toml" ]; then
  if grep -q "clap" Cargo.toml 2>/dev/null; then
    echo "Framework: Clap (Rust)"
    echo "Command path: src/commands/{{input.name}}.rs"
  fi
elif [ -f "package.json" ]; then
  if grep -q "commander" package.json 2>/dev/null; then
    echo "Framework: Commander (Node)"
  elif grep -q "yargs" package.json 2>/dev/null; then
    echo "Framework: Yargs (Node)"
  fi
elif [ -f "pyproject.toml" ] || [ -f "requirements.txt" ]; then
  if grep -q "click" pyproject.toml requirements.txt 2>/dev/null; then
    echo "Framework: Click (Python)"
  elif grep -q "typer" pyproject.toml requirements.txt 2>/dev/null; then
    echo "Framework: Typer (Python)"
  fi
fi

Validation

  • [ ] Command file created and follows existing patterns
  • [ ] Command registered and shows in --help
  • [ ] Arguments and flags parsed correctly
  • [ ] Help text is clear with usage examples
  • [ ] Error messages are helpful (not stack traces)
  • [ ] Exit codes are correct (0 success, non-zero error)
  • [ ] Tests created and passing
  • [ ] Typecheck/compile passing
  • [ ] Lint passing

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/generate-cli-command-ms2s7cuf/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/generate-cli-command-ms2s7cuf' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/generate-cli-command-ms2s7cuf/download' --output '.skill-downloads/generate-cli-command-ms2s7cuf/SKILL.md.part' && mv '.skill-downloads/generate-cli-command-ms2s7cuf/SKILL.md.part' '.skill-downloads/generate-cli-command-ms2s7cuf/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/generate-cli-command-ms2s7cuf/SKILL.md' && test -s '.skill-downloads/generate-cli-command-ms2s7cuf/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/scaffold-cli' && cp -R '.skill-downloads/generate-cli-command-ms2s7cuf' '.claude/skills/scaffold-cli'

Cursor
test -f '.skill-downloads/generate-cli-command-ms2s7cuf/SKILL.md' && test -s '.skill-downloads/generate-cli-command-ms2s7cuf/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/scaffold-cli' && cp -R '.skill-downloads/generate-cli-command-ms2s7cuf' '.cursor/skills/scaffold-cli'

Codex
test -f '.skill-downloads/generate-cli-command-ms2s7cuf/SKILL.md' && test -s '.skill-downloads/generate-cli-command-ms2s7cuf/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/scaffold-cli' && cp -R '.skill-downloads/generate-cli-command-ms2s7cuf' '.agents/skills/scaffold-cli'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/generate-cli-command-ms2s7cuf'

openskills read 'generate-cli-command-ms2s7cuf'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/generate-cli-command-ms2s7cuf/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills