Adding A Command logo

Adding A Command

OrganizationPopular
caliber-ai-org
adding-a-command

Creates a new CLI command following the Commander.js pattern in src/commands/. Handles command registration in src/cli.ts, telemetry tracking via tracked() wrapper, and option parsing. Use when user says add command, new CLI command, create subcommand, or adds files to src/commands/. Do NOT use for modifying existing commands or fixing bugs in existing commands.

Overview

Publishercaliber-ai-org
Repositoryai-setup
Skill nameadding-a-command
Stars
1.3K
Forks
124
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by caliber-ai-org on GitHub. Read the source before you install it.

Installation

Install the Adding A Command AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/caliber-ai-org/ai-setup.git /tmp/ai-setup
mkdir -p .claude/skills
cp -r /tmp/ai-setup/skills/adding-a-command .claude/skills/adding-a-command
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Adding A Command in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Adding A Command on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Adding A Command is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

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.
  4. Define options (if needed):

    • Add .option() chains before .action(): .option('--flag', 'Description') or .option('--opt <value>', 'Description')
    • For parsed options (like comma-separated agents), add a parse function: .option('--opt <value>', 'Description', parseFunction)
    • Pass options to handler: .action(tracked('name', (opts) => command(opts)))
    • Define TypeScript interface for the options object.
    • Verify option names use camelCase (Commander converts kebab-case flags to camelCase).
  5. Verify before proceeding:

    • Function exports correctly and is imported in cli.ts.
    • Command is registered with tracked() wrapper.
    • Output uses chalk for colors, not plain console.log.
    • Error paths throw new Error('__exit__') for user errors.

Examples

Example 1: Simple command (status)

User says: "Add a command to show config status"

Actions taken:

  1. Create src/commands/status.ts with statusCommand() export
  2. Import and register in src/cli.ts with tracked() wrapper

Result: caliber status displays config status; caliber status --json outputs JSON.

Code example:

typescript
import chalk from 'chalk';
import { loadConfig } from '../llm/config.js';

export async function statusCommand(options?: { json?: boolean }) {
  const config = loadConfig();
  
  if (options?.json) {
    console.log(JSON.stringify({ configured: !!config }, null, 2));
    return;
  }
  
  console.log(chalk.bold('Status'));
  console.log(`  LLM: ${chalk.green(config?.provider || 'Not configured')}`);
}

Registration in src/cli.ts:

typescript
import { statusCommand } from './commands/status.js';
program
  .command('status')
  .description('Show config status')
  .option('--json', 'Output as JSON')
  .action(tracked('status', statusCommand));

Example 2: Subcommand with arguments

User says: "Add a sources add subcommand"

Actions taken:

  1. Create src/commands/sources.ts with sourcesAddCommand() export
  2. Register under sources group with tracked('sources:add', ...)

Result: caliber sources add ../lib adds a source.

Code example:

typescript
export async function sourcesAddCommand(sourcePath: string) {
  if (!fs.existsSync(sourcePath)) {
    console.log(chalk.red(`Path not found: ${sourcePath}`));
    throw new Error('__exit__');
  }
  const existing = loadSourcesConfig(process.cwd());
  existing.push({ type: 'repo', path: sourcePath });
  writeSourcesConfig(process.cwd(), existing);
  console.log(chalk.green(`Added ${sourcePath}`));
}

Registration:

typescript
const sources = program.command('sources');
sources
  .command('add')
  .argument('<path>', 'Path to add')
  .action(tracked('sources:add', sourcesAddCommand));

Example 3: Command with option parsing

User says: "Add init with --agent flag supporting comma-separated values"

Actions taken:

  1. Create parseAgentOption() parser in src/cli.ts
  2. Create src/commands/init.ts with initCommand(options)
  3. Register with custom parser

Result: caliber init --agent claude,cursor passes parsed array to handler.

Parser code:

typescript
function parseAgentOption(value: string) {
  const agents = value.split(',').map(s => s.trim().toLowerCase());
  if (agents.length === 0) {
    console.error('Invalid agent');
    process.exit(1);
  }
  return agents;
}

program.command('init')
  .option('--agent <type>', 'Agents (comma-separated)', parseAgentOption)
  .action(tracked('init', initCommand));

Common Issues

Issue: "SyntaxError: The requested module does not provide an export named 'myCommand'"

  • Cause: Function not exported or exported as default instead of named.
  • Fix: Use export async function myCommand(...) (not export default).

Issue: Command appears in help but crashes when run

  • Cause: Handler not wrapped with tracked() or function import mismatch.
  • Fix: Verify import name matches function export. Wrap with tracked('command-name', handler).

Issue: "Error: exit" appears in output for user errors

  • Cause: Throwing generic error instead of using error exit pattern.
  • Fix: Use console.error(chalk.red('message')); throw new Error('__exit__'); for user-facing errors.

Issue: --dry-run flag not recognized

  • Cause: Option not declared with .option() or wrong camelCase in interface.
  • Fix: Add .option('--dry-run', 'Description') and ensure options interface has dryRun?: boolean.

Issue: Subcommand crashes but parent command works

  • Cause: Using program.command() instead of groupVar.command() for subcommands.
  • Fix: Register on group: const sources = program.command('sources'); sources.command('add')...

Issue: Telemetry not appearing

  • Cause: Handler not wrapped with tracked() or wrong command name.
  • Fix: Ensure .action(tracked('{kebab-case}', handler)) wraps handler. Use colon for subcommands like 'sources:add'.

Issue: "Cannot find module" with relative imports

  • Cause: Using .ts extension in imports.
  • Fix: Always use .js extension: import { x } from '../lib/file.js' (required for ESM).

Frequently asked questions

What does the Adding A Command AI skill do?

Creates a new CLI command following the Commander.js pattern in src/commands/. Handles command registration in src/cli.ts, telemetry tracking via tracked() wrapper, and option parsing. Use when user says add command, new CLI command, create subcommand, or adds files to src/commands/. Do NOT use for modifying existing commands or fixing bugs in existing commands.

Why use Adding A Command on TypingMind?

Because you install it once and use it with any model. Adding A Command is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Adding A Command in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/caliber-ai-org/ai-setup/tree/master/skills/adding-a-command. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Adding A Command?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Adding A Command?

As many as you like. As long as a model supports skills, you can use Adding A Command with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Adding A Command AI skill free?

Yes. It is published on GitHub by caliber-ai-org under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇