adding-a-command

Create a new CLI command with Commander.js registration and tests.

1.2k|119|Updated Mar 10, 2026
One-click install
npx skills add https://github.com/caliber-ai-org/ai-setup --skill adding-a-command
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: adding-a-command
Source: https://github.com/caliber-ai-org/ai-setup/tree/main/.cursor/skills/adding-a-command
Command: npx skills add https://github.com/caliber-ai-org/ai-setup --skill adding-a-command

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Automates creation of a new CLI command following the Commander.js pattern.

Core Features & Use Cases

  • Commands MUST be registered in src/cli.ts using .command() and .action() with the tracked() wrapper for telemetry.
  • Command file MUST be in src/commands/{commandName}.ts and export a default async function with the signature: async (options: any, ctx: CLIContext) => Promise<void>.
  • Always use tracked(commandName, ...) in src/cli.ts to enable telemetry tracking.
  • Test file MUST be in src/commands/tests/{commandName}.test.ts with at least one happy-path test.

Quick Start

Create a new command file in src/commands/{commandName}.ts, register it in src/cli.ts with tracked('commandName', handler), and add a test file at src/commands/tests/{commandName}.test.ts to cover the happy path.

Frequently Asked Questions about adding-a-command

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new CLI command with Commander.js and telemetry tracking?

To add a CLI command, create a file in src/commands, register it in src/cli.ts using the .command() and .action() methods wrapped with tracked() for telemetry, and export a default async function with the CLIContext signature.

What is the required file structure for a Commander.js command with telemetry?

The required structure places the command file at src/commands/{commandName}.ts and its test at src/commands/__tests__/{commandName}.test.ts. The command must be registered in src/cli.ts to enable telemetry tracking via the tracked() wrapper.

Do I need to write tests when scaffolding a new CLI command?

Yes, you must add a test file at src/commands/__tests__/{commandName}.test.ts. This test file needs to include at least one happy-path test to validate the command's behavior and ensure reliable telemetry before the command is fully integrated.

Can I use a different function signature for my CLI command handler?

No, the command handler must export a default async function with the signature async (options: any, ctx: CLIContext) => Promise<void>. This specific signature is required for proper registration and telemetry tracking within the CLI.

Why does my new CLI command lack telemetry tracking?

Telemetry tracking is missing if the command is not registered in src/cli.ts using the tracked(commandName, ...) wrapper. Always applying this wrapper around the handler ensures telemetry data is properly collected during command execution.