Claude-skill-registry commander
Use when building CLI tools with Commander.js - commands, options, arguments, and help text for Node.js command-line applications
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/commander" ~/.claude/skills/majiayu000-claude-skill-registry-commander && rm -rf "$T"
manifest:
skills/data/commander/SKILL.mdsource content
Commander.js CLI Framework
Quick Start
import { Command } from 'commander'; const program = new Command(); program .name('mycli') .version('1.0.0') .description('My CLI tool'); program .command('build <input>') .description('Build the project') .option('-o, --output <file>', 'Output file', 'output.json') .option('-w, --watch', 'Watch mode') .option('-v, --verbose', 'Verbose output') .action((input, options) => { console.log(`Building ${input} to ${options.output}`); if (options.watch) startWatcher(); }); program.parse();
Command Patterns
| Pattern | Syntax | Description |
|---|---|---|
| Required arg | | Must be provided |
| Optional arg | | Can be omitted |
| Variadic | | Multiple values |
| Option value | | Option with value |
| Boolean flag | | True when present |
| Negatable | | Sets cache=false |
Subcommands
const build = program.command('build'); build .command('dev') .description('Development build') .action(() => { /* ... */ }); build .command('prod') .description('Production build') .action(() => { /* ... */ });
Key Features
// Default values .option('-p, --port <number>', 'Port', '3000') // Coercion .option('-n, --number <n>', 'A number', parseInt) // Required options .requiredOption('-c, --config <path>', 'Config file') // Choices .option('-e, --env <env>', 'Environment').choices(['dev', 'prod']) // Error handling program.exitOverride(); // Throw instead of process.exit program.configureOutput({ writeErr: (str) => logger.error(str) });
Tips
- Use
at the end, orprogram.parse()
for asyncprogram.parseAsync() - Access args via action callback or
program.args - Use
for command shortcuts.alias('b') - Add examples with
.addHelpText('after', 'Examples:\n $ mycli build src/')