commander
Commander.jsを使って、コマンドラインから実行できる便利なツールを開発し、引数の解析やサブコマンドの実装、オプション設定など、開発者向けのツールを効率的に構築するSkill。
📜 元の英語説明(参考)
Build CLI tools with Commander.js. Use when creating command-line applications, parsing arguments, implementing subcommands, or building developer tools with flags and options.
🇯🇵 日本人クリエイター向け解説
Commander.jsを使って、コマンドラインから実行できる便利なツールを開発し、引数の解析やサブコマンドの実装、オプション設定など、開発者向けのツールを効率的に構築するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o commander.zip https://jpskill.com/download/14772.zip && unzip -o commander.zip && rm commander.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/14772.zip -OutFile "$d\commander.zip"; Expand-Archive "$d\commander.zip" -DestinationPath $d -Force; ri "$d\commander.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
commander.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
commanderフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Commander.js
概要
Commander は、Node.js CLI を構築するための標準ライブラリです。引数の解析、サブコマンドの定義、ヘルプテキストの生成、およびオプションの処理を行います。create-react-app、eslint、prisma を含む数千の CLI を強化します。
手順
ステップ 1: 基本的な CLI
// cli.ts — コマンドとオプションを持つ CLI
import { Command } from 'commander'
const program = new Command()
.name('mytools')
.description('開発者の生産性向上ツールキット')
.version('1.0.0')
program
.command('init')
.description('新しいプロジェクトを初期化します')
.argument('<name>', 'プロジェクト名')
.option('-t, --template <type>', 'プロジェクトテンプレート', 'default')
.option('--no-git', 'git の初期化をスキップします')
.option('-d, --dry-run', '作成される内容を表示します')
.action(async (name, opts) => {
console.log(`プロジェクトを作成中: ${name}`)
console.log(`テンプレート: ${opts.template}`)
if (opts.dryRun) { console.log('(dry run)'); return }
await createProject(name, opts)
})
program
.command('deploy')
.description('本番環境にデプロイします')
.option('-e, --env <environment>', 'ターゲット環境', 'production')
.option('--force', '確認をスキップします')
.action(async (opts) => {
if (!opts.force) {
const ok = await confirm(`Deploy to ${opts.env}?`)
if (!ok) process.exit(0)
}
await deploy(opts.env)
})
program.parse()
ステップ 2: パッケージの設定
{
"name": "mytools",
"bin": { "mytools": "./dist/cli.js" },
"scripts": {
"build": "tsc",
"dev": "tsx src/cli.ts"
}
}
# 開発
npx tsx src/cli.ts init my-project --template react
# ビルド + npm link 後
mytools init my-project --template react
mytools deploy --env staging
mytools --help
ガイドライン
- Commander は、コマンド定義から
--helpを自動生成します。 - 必須の位置引数には
argument()を、フラグにはoption()を使用します。 --no-*フラグは、自動的にブール値の否定を作成します (例:--no-git→opts.git === false)。- 終了コード: 成功の場合は 0、エラーの場合は 1 です。Commander は解析エラーを自動的に処理します。
- インタラクティブなプロンプトには、Inquirer または @clack/prompts と組み合わせて使用します。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Commander.js
Overview
Commander is the standard library for building Node.js CLIs. Parse arguments, define subcommands, generate help text, and handle options. Powers thousands of CLIs including create-react-app, eslint, and prisma.
Instructions
Step 1: Basic CLI
// cli.ts — CLI with commands and options
import { Command } from 'commander'
const program = new Command()
.name('mytools')
.description('Developer productivity toolkit')
.version('1.0.0')
program
.command('init')
.description('Initialize a new project')
.argument('<name>', 'project name')
.option('-t, --template <type>', 'project template', 'default')
.option('--no-git', 'skip git initialization')
.option('-d, --dry-run', 'show what would be created')
.action(async (name, opts) => {
console.log(`Creating project: ${name}`)
console.log(`Template: ${opts.template}`)
if (opts.dryRun) { console.log('(dry run)'); return }
await createProject(name, opts)
})
program
.command('deploy')
.description('Deploy to production')
.option('-e, --env <environment>', 'target environment', 'production')
.option('--force', 'skip confirmation')
.action(async (opts) => {
if (!opts.force) {
const ok = await confirm(`Deploy to ${opts.env}?`)
if (!ok) process.exit(0)
}
await deploy(opts.env)
})
program.parse()
Step 2: Package Setup
{
"name": "mytools",
"bin": { "mytools": "./dist/cli.js" },
"scripts": {
"build": "tsc",
"dev": "tsx src/cli.ts"
}
}
# Development
npx tsx src/cli.ts init my-project --template react
# After build + npm link
mytools init my-project --template react
mytools deploy --env staging
mytools --help
Guidelines
- Commander auto-generates
--helpfrom your command definitions. - Use
argument()for required positional args,option()for flags. --no-*flags automatically create boolean negations (e.g.,--no-git→opts.git === false).- Exit codes: 0 for success, 1 for errors. Commander handles parse errors automatically.
- For interactive prompts, pair with Inquirer or @clack/prompts.