Communitygithub.com

YepAPI/skills

Commander.js、Clack を使った対話型プロンプト、スピナー、カラーリング、設定ファイル、終了コード、npm 公開をサポートする CLI ツールのスキルです。

skills とは?

このスキルは、Node.js で堅牢で美しい CLI ツールを開発するためのベストプラクティスを提供します。Commander.js による引数解析、@clack/prompts や inquirer を使った対話型プロンプト、ora によるスピナー、chalk によるカラー出力、cosmiconfig による設定ファイルの自動検出、終了コードの正しい使い方、エラーハンドリング、npm 公開に必要な設定までをカバーしています。開発者はこのスキルに従うことで、ユーザーフレンドリーで CI/CD にも対応した CLI ツールを効率的に作成できます。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/YepAPI/skills/tree/HEAD/skills/cli-tools

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

CLI ツール

ルール

  • Commander.js で引数解析 — .command()、.option()、.argument() に説明文を付ける
  • 対話型プロンプト: @clack/prompts (モダンで美しい) または inquirer — 引数が指定されていない場合のユーザー入力に使用
  • スピナー: ora で長時間の処理を表示 — 開始、メッセージ更新、成功/失敗を表示
  • カラー: chalk でスタイル付き出力 — 控えめに使用: エラーは赤、成功は緑、警告は黄色、補足情報は薄色
  • 設定ファイル: cosmiconfig — .toolrc、.toolrc.json、tool.config.js、package.json のキーを自動検索
  • 終了コード: 成功は 0、一般エラーは 1、使用方法エラーは 2 — 常に process.exit(code) を使用
  • --help および --version フラグ: Commander が自動追加 — すべてのオプションに明確な説明を記述
  • エラーハンドリング: 最上位でエラーをキャッチし、ユーザーフレンドリーなメッセージを stderr に出力し、コード 1 で終了
  • 公開: package.json の bin フィールド、#!/usr/bin/env node シバン、"type": "module" で ESM 対応

パターン

#!/usr/bin/env node
import { Command } from "commander";
import * as p from "@clack/prompts";
import ora from "ora";
import chalk from "chalk";

const program = new Command()
  .name("my-tool")
  .description("便利なことを行う CLI")
  .version("1.0.0");

program
  .command("init")
  .description("新しいプロジェクトを初期化")
  .option("-t, --template <name>", "使用するテンプレート", "default")
  .action(async (options) => {
    p.intro(chalk.bold("プロジェクト設定"));

    const name = await p.text({ message: "プロジェクト名?", placeholder: "my-app" });
    if (p.isCancel(name)) { p.cancel("キャンセルされました。"); process.exit(0); }

    const spinner = ora("プロジェクトを作成中...").start();
    await createProject(name, options.template);
    spinner.succeed(chalk.green("プロジェクトを作成しました!"));

    p.outro(`次のコマンドを実行: ${chalk.cyan(`cd ${name} && npm install`)}`);
  });

program.parse();

// package.json: { "bin": { "my-tool": "./dist/index.js" } }

避けるべきこと

  • エラーを stdout に出力しない — エラーには console.error() または process.stderr.write() を使用
  • 失敗時にコードを指定せずに終了しない — 常に process.exit(1) を実行し、スクリプトや CI が失敗を検出できるようにする
  • フォーマットされていないテキストの壁を作らない — chalk の色、セクション、余白を使って可読性を向上
  • フラグの代替がない対話型入力を必須にしない — CI/スクリプト用に常に --flag 上書きをサポート
  • シバン #!/usr/bin/env node を忘れない — これがないと、npx やグローバルインストールが機能しない

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

YepAPI/skills

WCAG 2.1 AA — semantic HTML, keyboard navigation, screen readers.

YepAPI/skills

Experiment setup, variant splitting, statistical significance, and feature flag integration.

YepAPI/skills

CRUD generators, data tables, user management, role-based access, and bulk operations.

YepAPI/skills

Monitor what ChatGPT and Gemini say about your brand using YepAPI.

YepAPI/skills

Queue workers with BullMQ/Inngest/Trigger.dev, job retries, dead letter queues, concurrency.

YepAPI/skills

cmdk integration, Cmd+K trigger, fuzzy search, grouped actions, keyboard navigation, and dynamic action registration.

YepAPI/skills

Content planning with trend and sentiment data from YepAPI.

YepAPI/skills

Content calendar, keyword-driven planning, and content briefs.

YepAPI/skills

Theme switching with CSS variables, system preference detection, next-themes, and persistence.

YepAPI/skills

Threaded comments, @mentions, reactions, moderation queue, optimistic UI, and cursor pagination.

YepAPI/skills

Competitive analysis between domains using YepAPI.

YepAPI/skills

Layout grids, KPI cards, data tables with sorting/filtering, sidebar navigation, and responsive breakpoints.

YepAPI/skills

Data encryption — TLS everywhere, AES-256-GCM for PII, bcrypt passwords, encrypted backups.

YepAPI/skills

Chart patterns with Recharts/Nivo/D3, responsive containers, color scales, and accessibility.

YepAPI/skills

Drizzle schema definition, push vs migrate, type-safe queries, relations, transactions, and prepared statements.

YepAPI/skills

Upload handling, resize/compress, CDN delivery, blur placeholders, and next/image patterns.

YepAPI/skills

Local business and Google Maps research using YepAPI.

YepAPI/skills

Cursor-based pagination, IntersectionObserver, virtualized lists with @tanstack/react-virtual, and scroll position restoration.

YepAPI/skills

Tenant isolation (row-level vs schema), subdomain routing, per-tenant config, and data partitioning.

YepAPI/skills

Chat UI components, streaming responses with AI SDK, context window management, and RAG patterns.

関連スキル