Skip to content
Back to skills

Commander

ASecurity

Use when building CLI tools with Commander.js - commands, options, arguments, and help text for Node.js command-line applications

  • 666 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added February 8, 2026
developmenttypescriptnode

Works with

  • cli

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill commander --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Commander?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Commander
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-commander/badge)](https://www.skillsdirectory.com/skills/majiayu000-commander)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: commander
# prettier-ignore
description: Use when building CLI tools with Commander.js - commands, options, arguments, and help text for Node.js command-line applications
---

# Commander.js CLI Framework

## Quick Start

```typescript
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 | `<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 |

## Subcommands

```typescript
const build = program.command('build');

build
  .command('dev')
  .description('Development build')
  .action(() => { /* ... */ });

build
  .command('prod')
  .description('Production build')
  .action(() => { /* ... */ });
```

## Key Features

```typescript
// 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 `program.parse()` at the end, or `program.parseAsync()` for async
- Access args via action callback or `program.args`
- Use `.alias('b')` for command shortcuts
- Add examples with `.addHelpText('after', 'Examples:\n  $ mycli build src/')`

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.