SKILL.md (1863B)
1 # Skill: CLI Command Wiring 2 3 **Bug class:** Commands implemented in `packages/squad-cli/src/cli/commands/` but never routed in `cli-entry.ts`. 4 5 ## Checklist — Adding a New CLI Command 6 7 1. **Create command file** in `packages/squad-cli/src/cli/commands/<name>.ts` 8 - Export a `run<Name>(cwd, options)` async function (or class with static methods for utility modules) 9 10 2. **Add routing block** in `packages/squad-cli/src/cli-entry.ts` inside `main()`: 11 ```ts 12 if (cmd === '<name>') { 13 const { run<Name> } = await import('./cli/commands/<name>.js'); 14 // parse args, call function 15 await run<Name>(process.cwd(), options); 16 return; 17 } 18 ``` 19 20 3. **Add help text** in the help section of `cli-entry.ts` (search for `Commands:`): 21 ```ts 22 console.log(` ${BOLD}<name>${RESET} <description>`); 23 console.log(` Usage: <name> [flags]`); 24 ``` 25 26 4. **Verify both exist** — the recurring bug is doing step 1 but missing steps 2-3. 27 28 ## Wiring Patterns by Command Type 29 30 | Type | Example | How to wire | 31 |------|---------|-------------| 32 | Standard command | `export.ts`, `build.ts` | `run*()` function, parse flags from `args` | 33 | Placeholder command | `loop`, `hire` | Inline in cli-entry.ts, prints pending message | 34 | Utility/check module | `rc-tunnel.ts`, `copilot-bridge.ts` | Wire as diagnostic check (e.g., `isDevtunnelAvailable()`) | 35 | Subcommand of another | `init-remote.ts` | Already used inside parent + standalone alias | 36 37 ## Common Import Pattern 38 39 ```ts 40 import { BOLD, RESET, DIM, RED, GREEN, YELLOW } from './cli/core/output.js'; 41 ``` 42 43 Use dynamic `await import()` for command modules to keep startup fast (lazy loading). 44 45 ## History 46 47 - **#237 / PR #244:** 4 commands wired (rc, copilot-bridge, init-remote, rc-tunnel). aspire, link, loop, hire were already present.