node-cli
Build a Node.js CLI tool with Commander.js, interactive prompts, colored terminal output, and pnpm packaging. Use when creating a command-line interface for a Node.js project. Triggers include "CLI tool", "command line", "Commander.js", "terminal interface", "interactive prompts", or any task requiring a Node.js CLI.
Best use case
node-cli is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Build a Node.js CLI tool with Commander.js, interactive prompts, colored terminal output, and pnpm packaging. Use when creating a command-line interface for a Node.js project. Triggers include "CLI tool", "command line", "Commander.js", "terminal interface", "interactive prompts", or any task requiring a Node.js CLI.
Teams using node-cli should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/node-cli/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How node-cli Compares
| Feature / Agent | node-cli | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Build a Node.js CLI tool with Commander.js, interactive prompts, colored terminal output, and pnpm packaging. Use when creating a command-line interface for a Node.js project. Triggers include "CLI tool", "command line", "Commander.js", "terminal interface", "interactive prompts", or any task requiring a Node.js CLI.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# node-cli
Scaffold and build Node.js CLI tools with Commander.js, interactive prompts, and formatted terminal output.
## When to Use
- Adding a CLI interface to an existing Node.js project
- Creating a standalone CLI tool distributed via npm
- Building an interactive terminal wizard
- Adding colored output and progress indicators to a script
## Prerequisites
- Node.js 20+
- pnpm
## Quick Start
```bash
mkdir my-cli && cd my-cli
pnpm init
pnpm add commander @inquirer/prompts chalk
```
## Package Setup
`package.json`:
```json
{
"name": "my-cli",
"version": "1.0.0",
"type": "module",
"bin": {
"my-cli": "./dist/cli.js"
},
"scripts": {
"build": "tsc",
"dev": "tsx src/cli.ts",
"typecheck": "tsc --noEmit",
"lint": "eslint src"
}
}
```
## Commander.js Pattern
```typescript
import { Command } from 'commander';
const program = new Command();
program
.name('my-cli')
.description('Tool description')
.version('1.0.0');
program
.command('generate')
.description('Generate something')
.option('--domain <name>', 'Domain name')
.option('--output <file>', 'Output file', 'output.conf')
.action(async (opts) => {
// implementation
});
program.parse();
```
## Interactive Prompts with @inquirer/prompts
```typescript
import { input, select, confirm, checkbox } from '@inquirer/prompts';
const domain = await input({
message: 'Server name:',
default: 'example.com',
});
const serverType = await select({
message: 'Server type:',
choices: [
{ value: 'proxy', name: 'Reverse Proxy' },
{ value: 'static', name: 'Static Files' },
],
});
const ssl = await confirm({
message: 'Enable SSL?',
default: true,
});
```
## Colored Terminal Output
Use a log.ts utility. Do not use raw ANSI codes in business logic.
```typescript
// src/lib/log.ts
const c = {
green: (s: string) => `\x1b[32m${s}\x1b[0m`,
red: (s: string) => `\x1b[31m${s}\x1b[0m`,
yellow: (s: string) => `\x1b[33m${s}\x1b[0m`,
cyan: (s: string) => `\x1b[36m\x1b[4m${s}\x1b[0m`,
dim: (s: string) => `\x1b[2m${s}\x1b[0m`,
bold: (s: string) => `\x1b[1m${s}\x1b[0m`,
};
export const log = {
ok: (msg: string) => console.log(`${c.green('ok')} ${msg}`),
info: (label: string, value: string) => console.log(`${c.dim('--')} ${label.padEnd(10)} ${value}`),
warn: (msg: string) => console.log(`${c.yellow('*')} ${msg}`),
error: (msg: string) => console.log(`${c.red('x')} ${msg}`),
path: (p: string) => c.cyan(p),
};
```
## Standard Output Format
```
tool-name v1.0.0
ok operation completed
-- label value
-- file ./output.conf
Press Ctrl+C to exit.
```
Rules:
- `ok` in green for success
- `--` in dim for metadata/info lines
- `x` in red for errors
- `*` in yellow for warnings
- Labels right-padded with spaces to align values
- File paths in cyan with underline
## Distribution
To publish as a global npm package:
```bash
pnpm build
npm publish --access public
```
Users install with:
```bash
npm install -g my-cli
```
## tsconfig.json
```json
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"outDir": "dist",
"strict": true,
"noUncheckedIndexedAccess": true
},
"include": ["src"]
}
```
## Dependencies
| Package | Purpose |
|---|---|
| `commander` | Argument parsing, subcommands, help generation |
| `@inquirer/prompts` | Interactive prompts (input, select, confirm, checkbox) |
| `tsx` | Run TypeScript directly in development |
| `typescript` | TypeScript compiler |Related Skills
Skill: Network scanning with Node.js net.Socket
## When to use
Skill: Uptime Monitoring
## Overview
Skill: Status Page
## Overview
Skill: unit-conversion
## Overview
Skill: recipe-scaler
## Overview
reading-list
Operate the reading-list API to save, manage, tag, search, and export articles.
email-digest
Configure, test, and troubleshoot the reading-list daily email digest delivered via nodemailer.
websocket-realtime
Use the WebSocket connection in poll-builder to receive live vote updates. Use when you need to stream real-time poll results, monitor a poll for new votes, or build a live dashboard. Triggers include "live results", "real-time updates", "stream votes", "watch poll", or "WebSocket".
poll-builder
Self-hosted poll creation tool with real-time results. Use when you need to create a poll, check vote counts, close a poll, export results, or get the shareable link for a poll. Triggers include "create poll", "vote", "poll results", "survey", "collect votes", "share poll", or any task involving polling or voting.
Skill: personal-finance
## Overview
Skill: csv-import
## Overview
Skill: Syntax Highlighting
## Purpose