---
phase: 01-core-infrastructure
plan: 02
type: execute
wave: 2
depends_on: ["01-01"]
files_modified: [src/bin/cw.ts, src/cli/index.ts, src/cli/commands/index.ts]
autonomous: true
---

<objective>
Create CLI foundation with commander, help system, and version display.

Purpose: Establish the `cw` command as the user-facing entry point for all operations.
Output: Working CLI with `cw --help` and `cw --version` that can be globally installed.
</objective>

<execution_context>
@~/.claude/get-shit-done/workflows/execute-plan.md
@~/.claude/get-shit-done/templates/summary.md
</execution_context>

<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
@.planning/phases/01-core-infrastructure/01-01-SUMMARY.md
</context>

<tasks>

<task type="auto">
  <name>Task 1: Create CLI with commander</name>
  <files>src/cli/index.ts, src/bin/cw.ts</files>
  <action>
    Create src/cli/index.ts:
    - Import { Command } from 'commander'
    - Create program with name('cw'), description, version from package.json
    - Add placeholder commands: 'status', 'agent', 'task' (just stubs that log "not implemented")
    - Export createCli() function that returns configured program

    Update src/bin/cw.ts:
    - Import createCli from '../cli/index.js'
    - Call program.parse(process.argv)
    - Handle uncaught errors gracefully (log and exit 1)

    Read version from package.json using import with assert { type: "json" } or createRequire pattern.
  </action>
  <verify>npm run build succeeds, node dist/bin/cw.js --help shows commands</verify>
  <done>CLI shows help with status/agent/task placeholders, version displays correctly</done>
</task>

<task type="auto">
  <name>Task 2: Enable global installation via npm link</name>
  <files>package.json, src/bin/cw.ts</files>
  <action>
    Verify package.json bin field points to correct path: "bin": { "cw": "./dist/bin/cw.js" }

    Ensure the built bin file:
    - Has correct shebang (#!/usr/bin/env node)
    - Is executable (add postbuild script to chmod if needed)

    Test npm link workflow:
    - Run npm run build
    - Run npm link
    - Verify 'cw' command available globally

    Document in comments: users can install via npm link during development or npm i -g for release.
  </action>
  <verify>After npm link, running 'cw --version' in any directory shows version</verify>
  <done>Global cw command works, help and version display correctly</done>
</task>

</tasks>

<verification>
Before declaring plan complete:
- [ ] `npm run build` succeeds
- [ ] `cw --help` displays usage with command list
- [ ] `cw --version` displays version from package.json
- [ ] `cw status` outputs "not implemented" placeholder
- [ ] Global install via npm link works
</verification>

<success_criteria>

- All tasks completed
- All verification checks pass
- CLI is the single entry point for all commands
- Foundation ready for adding real commands in later phases
</success_criteria>

<output>
After completion, create `.planning/phases/01-core-infrastructure/01-02-SUMMARY.md`
</output>
