| name | commander-js-scaffolder |
| description | Generate Commander.js CLI project structure with TypeScript, commands, options, and best practices. Creates a complete scaffolded CLI application ready for development. |
| allowed-tools | Read, Write, Edit, Bash, Glob, Grep |
| graph | {"domains":["domain:software-engineering"],"specializations":["specialization:cli-mcp-development"],"skillAreas":["skill-area:cli-design","skill-area:cli-tooling"],"roles":["role:backend-engineer","role:platform-engineer"],"workflows":["workflow:feature-development"],"topics":["topic:developer-experience"]} |
Commander.js Scaffolder
Generate a complete Commander.js CLI application with TypeScript, proper project structure, and best practices.
Capabilities
- Generate TypeScript-based Commander.js CLI projects
- Create command structure with subcommands and options
- Set up proper argument parsing with type coercion
- Configure help text generation
- Implement version management
- Set up build and development workflows
Usage
Invoke this skill when you need to:
- Bootstrap a new CLI application using Commander.js
- Create a TypeScript CLI with proper structure
- Set up command hierarchies with subcommands
- Configure CLI options and arguments
Inputs
| Parameter | Type | Required | Description |
|---|
| projectName | string | Yes | Name of the CLI project (kebab-case) |
| description | string | Yes | Short description of the CLI |
| commands | array | No | List of commands to scaffold |
| typescript | boolean | No | Use TypeScript (default: true) |
| packageManager | string | No | npm, yarn, or pnpm (default: npm) |
Command Structure
{
"commands": [
{
"name": "init",
"description": "Initialize a new project",
"options": [
{ "flags": "-t, --template <name>", "description": "Template to use" },
{ "flags": "-f, --force", "description": "Overwrite existing files" }
],
"arguments": [
{ "name": "<directory>", "description": "Target directory" }
]
}
]
}
Output Structure
<projectName>/
โโโ package.json
โโโ tsconfig.json
โโโ .gitignore
โโโ README.md
โโโ src/
โ โโโ index.ts # Entry point with shebang
โ โโโ cli.ts # Main CLI setup
โ โโโ commands/
โ โ โโโ index.ts # Command exports
โ โ โโโ <command>.ts # Individual commands
โ โโโ utils/
โ โ โโโ logger.ts # Logging utilities
โ โ โโโ config.ts # Configuration helpers
โ โโโ types/
โ โโโ index.ts # Type definitions
โโโ bin/
โ โโโ <projectName> # Compiled binary entry
โโโ tests/
โโโ commands/
โโโ <command>.test.ts
Generated Code Patterns
Main CLI Entry (src/cli.ts)
import { Command } from 'commander';
import { version } from '../package.json';
const program = new Command();
program
.name('<projectName>')
.description('<description>')
.version(version, '-v, --version', 'Display version number');
program.addCommand(initCommand);
program.addCommand(buildCommand);
program
.option('-d, --debug', 'Enable debug mode')
.option('-q, --quiet', 'Suppress output');
program.exitOverride();
try {
program.parse();
} catch (err) {
}
Command Template (src/commands/.ts)
import { Command } from 'commander';
export const <name>Command = new Command('<name>')
.description('<description>')
.argument('<required>', 'Required argument description')
.argument('[optional]', 'Optional argument description')
.option('-o, --option <value>', 'Option description', 'default')
.action(async (required, optional, options) => {
});
Dependencies
{
"dependencies": {
"commander": "^12.0.0"
},
"devDependencies": {
"@types/node": "^20.0.0",
"typescript": "^5.0.0",
"tsx": "^4.0.0",
"vitest": "^1.0.0"
}
}
Workflow
- Validate inputs - Check project name, commands structure
- Create directory structure - Set up folders and base files
- Generate package.json - Configure project metadata and scripts
- Generate tsconfig.json - TypeScript configuration
- Create CLI entry point - Main program setup
- Generate commands - Individual command files
- Create utilities - Logger, config helpers
- Set up tests - Test structure for commands
- Initialize git - Optional git initialization
Best Practices Applied
- TypeScript strict mode enabled
- Proper error handling with exitOverride
- Consistent command naming conventions
- Help text formatting standards
- Version flag configuration
- Debug/verbose mode support
- Graceful error messages
References
Target Processes
- cli-application-bootstrap
- cli-command-structure-design
- argument-parser-setup