10. Deep Read: commands.ts

What This File Really Is

commands.ts is not just a list of slash commands. It is the command control plane for the whole product. It combines built-in commands, bundled skills, plugin commands, workflow-generated commands, dynamic skills, and feature-gated internal commands.

Important Design Patterns

  • Expensive command loading is memoized by current working directory.
  • Availability is checked separately from isEnabled(), so auth/provider changes can take effect immediately.
  • Dynamic skills are inserted into the final command list after plugin skills but before built-in commands.
  • Internal-only commands are isolated rather than interleaved into the main list.

Why It Matters

This file teaches a practical lesson: once a CLI becomes a platform, command discovery is a merge problem. You are no longer shipping a fixed command set. You are composing command sources from core code, plugins, workflows, skills, and environment-dependent features.

What To Copy

Keep command loading separate from command filtering. Load once if possible. Recompute only what depends on live auth state, provider state, or feature settings.

Source Navigation

Recommended Source Files

  • source/commands.ts
  • source/commands
  • source/main.tsx
  • source/skills/bundled/index.ts
  • source/services/plugins/pluginCliCommands.ts

Next Files to Read

  • source/tools.ts
  • source/Tool.ts
  • source/services/api/bootstrap.ts