adding-a-command

A coding guide for adding new command-line commands to a TypeScript app that uses Commander.js, a library for building command-line tools.

In plain words
What is it for?
Use it when creating a command or subcommand, especially when adding a file under src/commands/.
Why use it?
It keeps new commands consistent with the app’s registration, options, error handling, and usage tracking rules.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/caliber-ai-org/ai-setup/adding-a-command
Any agent
npx skills add caliber-ai-org/ai-setup --skill adding-a-command
Clone the repo
git clone --depth 1 https://github.com/caliber-ai-org/ai-setup

Made for: Claude Code, Codex.

Per session 76 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,851 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00076 $0.01851
Opus 5 $0.00038 $0.00925
Sonnet 5 $0.00015 $0.00370
Haiku 4.5 $0.00008 $0.00185

Measured 2d ago against content hash 73e93413cd36, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

adding-a-command scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.agents/skills/adding-a-command/SKILL.md · 181 lines

How it starts

The opening of the file, as written. The whole thing — 181 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Adding a Command

Critical

  • Export pattern: Command must export a named async function: export async function myCommand(options?: OptionType). Never use default exports.
  • Registration in cli.ts: Every command must be imported and registered with .command() chain in src/cli.ts, wrapped with tracked() for telemetry.
  • Error signaling: Use throw new Error('__exit__') to exit gracefully without printing the error message. Use chalk for user-facing messages.
  • Options typing: Commands receiving options must define a TypeScript interface for those options. Pass options as a destructured object parameter.

Instructions

  1. Create the command file at src/commands/{commandName}.ts with named async export.

    • Signature: export async function {commandName}Command(options?: { optionName?: optionType }) { ... }
    • Import only what you need (avoid kitchen-sink imports).
    • Return void (handle all output via console.log or chalk).
    • Verify the file follows the naming convention: camelCase function + "Command" suffix.
  2. Handle errors consistently: Wrap error-prone operations in try/catch. Distinguish between user errors and system errors:

    • User error (bad input): console.error(chalk.red('message')); throw new Error('__exit__');
    • System error (missing dependency): throw new Error('Detailed error message'); — this will print and exit with code 1.
    • Parse-like errors: Use ora spinner with .fail() before throwing.
    • This step prevents double error printing in bin.ts.
  3. Import and register in src/cli.ts in the correct location:

    • Add import at the top: import { {commandName}Command } from './commands/{commandName}.js';
    • Register the command in the appropriate section (main commands, or nested under a group like sources).
    • For main commands: .command('{kebab-name}').description('...').option(...).action(tracked('{kebab-name}', {commandName}Command))
    • For subcommands (like sources add): sources.command('add').description(...).action(tracked('sources:add', sourcesAddCommand))
    • Key: Wrap handler with tracked('{command-name}', handler) for automatic telemetry.
    • Verify the command name in tracked() uses kebab-case for main commands and colon-separated for subcommands.

Read the full file on GitHub · 181 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 181 lines · 76 tokens per session scan A 73e93413cd36

Subscribe to this mod's changes

adding-a-command is a skill published in the GitHub repository caliber-ai-org/ai-setup (1,259 stars, last pushed 1mo ago), licensed MIT. It adds 76 tokens to every session and 1,851 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

bridge

Use when the user wants hyperflow's behavioral rules to apply outside the terminal CLI — in Claude Code Desktop, claude.ai web, or IDE extensions that don't load CLI plugins. Writes a managed doctrine block into the project's CLAUDE.md so autonomy + intent-routing + commit cadence + role separation + file-first rules…

jeremylongshore/tons-of-skills-marketplace · 126 tokens

prompt-optimization

Use this skill when the user wants to optimize, modify, or improve the system prompt of an AI agent. This includes requests like 'optimize the prompt', 'make the AI more focused on X', 'change the system prompt', 'improve the agent behavior', or 'modify how the AI responds'.

wecode-ai/Wegent · 62 tokens

fable-method

A step-by-step problem-solving loop (classify the ask, define done, gather evidence, decide, act surgically, verify by observation, report outcome-first). Use when the user says "/fable-method", "use the fable method", or "approach this like Fable", or proactively when starting any multi-step task that no…

Sahir619/fable-method · 105 tokens

fable-domain

Discuss a domain with the user, research it from real sources, then generate a trusted skill bundle for it - a step-by-step workflow with a flowchart, a domain adapter, a trap fixture, and a smoke eval. Use when the user says "/fable-domain ", "make a skill for ", "add a domain to the fable method", or "give a lesser…

Sahir619/fable-method · 115 tokens

fable-judge

Adversarial verification of finished work. Treats any "done" as a set of claims, then re-runs the claimed verifications, diffs what actually changed, detects weakened tests and false completion claims, and delivers an evidence-based verdict (VERIFIED / VERIFIED WITH CAVEATS / REFUTED). Use after any agent or model…

Sahir619/fable-method · 125 tokens

fable-loop

End-to-end orchestrated workflow that runs a task the way Fable ran sessions - parallel evidence subagents, one committed plan, surgical execution with an intent gate, adversarial verification agents, honest outcome-first report. Use for non-trivial multi-step tasks when the user says "/fable-loop", "run the fable…

Sahir619/fable-method · 111 tokens