commander
Use when building CLI tools with Commander.js - commands, options, arguments, and help text for Node.js command-line applications
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Use when building CLI tools with Commander.js - commands, options, arguments, and help text for Node.js command-line applications
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Use when writing or editing .omg.md files - the human-first DSL for API specification that compiles to OpenAPI 3.1
Use when parsing or generating Markdown following the CommonMark specification - AST structure, block/inline elements, and extensions
Use when creating GitHub Actions workflows for CI/CD - testing, building, publishing npm packages, and automating repository tasks
Use when working with JSON Schema for validation, OpenAPI schemas, type definitions, and data structure specification
Use when implementing Language Server Protocol features - diagnostics, completions, hover, go-to-definition, and editor integration
Use when managing npm workspaces monorepos - package dependencies, build ordering, cross-package development, and publishing workflows
| name | commander |
| description | Use when building CLI tools with Commander.js - commands, options, arguments, and help text for Node.js command-line applications |
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();
| Pattern | Syntax | Description |
|---|---|---|
| Required arg | <name> | Must be provided |
| Optional arg | [name] | Can be omitted |
| Variadic | <files...> | Multiple values |
| Option value | -o, --out <file> | Option with value |
| Boolean flag | -v, --verbose | True when present |
| Negatable | --no-cache | Sets cache=false |
const build = program.command('build');
build
.command('dev')
.description('Development build')
.action(() => { /* ... */ });
build
.command('prod')
.description('Production build')
.action(() => { /* ... */ });
// 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) });
program.parse() at the end, or program.parseAsync() for asyncprogram.args.alias('b') for command shortcuts.addHelpText('after', 'Examples:\n $ mycli build src/')