commander-patterns_skill

This skill provides battle-tested Commander.js patterns and templates to build robust Node.js CLIs with TypeScript support.
  • Python

0

GitHub Stars

1

Bundled Files

3 weeks ago

Catalog Refreshed

2 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstart where the catalogue uses aiagentskills.

npx veilstart add skill vanman2024/cli-builder --skill commander-patterns

  • SKILL.md11.5 KB

Overview

This skill provides battle-tested Commander.js patterns and TypeScript templates for building robust Node.js CLIs. It bundles examples for Command class usage, options, arguments, nested subcommands, and the Option class for advanced validation. Use it to scaffold maintainable, testable command-line tools with clear help and error handling.

How this skill works

The skill supplies ready-to-use templates and pattern recipes that show how to instantiate Command, add options and arguments, and wire action handlers. It demonstrates Option class features (choices, parsers, defaults, mandatory flags), nested subcommands, variadic/parsed arguments, global options, and exit/error handling. Scripts and templates automate scaffolding, validation, and testing of CLI commands.

When to use it

  • Building a new Node.js CLI with Commander.js and TypeScript
  • Adding options, arguments, or complex parsers to commands
  • Creating nested subcommands or multi-level command hierarchies
  • Enforcing option validation and mutually exclusive flags
  • Scaffolding commands and automating CLI tests

Best practices

  • Use the Option class for complex options (choices, parsers, defaults) to improve validation and typing
  • Keep action handlers thin—delegate business logic to separate modules for testability
  • Declare clear descriptions so auto-generated help is useful
  • Provide sensible defaults and use global options for shared settings
  • Call program.parse() after building the command tree and use program.exitOverride() for controlled error handling

Example use cases

  • Scaffold a multi-command TypeScript CLI with a config group (get/set/list/delete)
  • Create a deploy command with environment choices, force flag, and replica count parsed as integer
  • Build interactive setup flows by combining Commander.js with Inquirer.js prompts
  • Implement a batch command accepting variadic items and custom parsers for each argument
  • Write unit and integration tests using provided test scripts to validate option parsing and help output

FAQ

Use Option.makeOptionMandatory() or call .requiredOption on a command to force a value for that option.

How do I access global options from a subcommand?

Inside a subcommand action, read command.parent?.opts() or use program.opts() to access global values.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational