---
phase: 12-phase-task-decomposition
plan: 06
type: execute
wave: 3
depends_on: ["12-04", "12-05"]
files_modified:
  - src/cli/index.ts
autonomous: true
---

<objective>
Add CLI commands for plan management and architect decompose workflow.

Purpose: Enable users to list plans, create plans, and spawn architect agents to decompose plans into tasks via the CLI.

Output: CLI commands for `cw plan` and `cw architect decompose`.
</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

# Depends on Plans 04, 05
@.planning/phases/12-phase-task-decomposition/12-04-SUMMARY.md
@.planning/phases/12-phase-task-decomposition/12-05-SUMMARY.md

# Pattern reference from Phase 11 (CLI commands)
@.planning/phases/11-architect-agent/11-06-SUMMARY.md

# CLI reference
@src/cli/index.ts
</context>

<tasks>

<task type="auto">
  <name>Task 1: Add plan CLI commands</name>
  <files>src/cli/index.ts</files>
  <action>
Add plan command group following pattern of initiative commands:

```typescript
const plan = program.command('plan').description('Plan management');

plan
  .command('list')
  .description('List plans in a phase')
  .requiredOption('--phase <id>', 'Phase ID')
  .action(async (options) => {
    const client = createTRPCClient();
    const plans = await client.listPlans.query({ phaseId: options.phase });
    console.table(plans.map(p => ({
      id: p.id,
      number: p.number,
      name: p.name,
      status: p.status,
    })));
  });

plan
  .command('create')
  .description('Create a plan in a phase')
  .requiredOption('--phase <id>', 'Phase ID')
  .requiredOption('--name <name>', 'Plan name')
  .option('--description <desc>', 'Plan description')
  .action(async (options) => {
    const client = createTRPCClient();
    const plan = await client.createPlan.mutate({
      phaseId: options.phase,
      name: options.name,
      description: options.description,
    });
    console.log(`Created plan: ${plan.id} (${plan.name})`);
  });

plan
  .command('get')
  .description('Get plan details')
  .argument('<id>', 'Plan ID')
  .action(async (id) => {
    const client = createTRPCClient();
    const plan = await client.getPlan.query({ id });
    console.log(JSON.stringify(plan, null, 2));
  });

plan
  .command('tasks')
  .description('List tasks in a plan')
  .argument('<id>', 'Plan ID')
  .action(async (id) => {
    const client = createTRPCClient();
    const tasks = await client.listTasks.query({ planId: id });
    console.table(tasks.map(t => ({
      id: t.id,
      order: t.order,
      name: t.name,
      type: t.type,
      status: t.status,
    })));
  });
```
  </action>
  <verify>npm run build passes, cw plan --help shows commands</verify>
  <done>Plan CLI commands: list, create, get, tasks</done>
</task>

<task type="auto">
  <name>Task 2: Add architect decompose command</name>
  <files>src/cli/index.ts</files>
  <action>
Add decompose command to architect command group:

```typescript
architect
  .command('decompose')
  .description('Spawn architect to decompose plan into tasks')
  .requiredOption('--name <name>', 'Agent name')
  .requiredOption('--plan <id>', 'Plan ID to decompose')
  .option('--context <text>', 'Additional context for decomposition')
  .action(async (options) => {
    const client = createTRPCClient();
    const result = await client.spawnArchitectDecompose.mutate({
      name: options.name,
      planId: options.plan,
      context: options.context,
    });
    console.log(`Spawned decompose agent: ${result.name} (${result.id})`);
    console.log(`Working on plan: ${options.plan}`);
    console.log(`Mode: decompose`);
  });
```

This follows the pattern of architect discuss and architect breakdown commands.
  </action>
  <verify>npm run build passes, cw architect decompose --help shows options</verify>
  <done>cw architect decompose command spawns agent in decompose mode</done>
</task>

</tasks>

<verification>
Before declaring plan complete:
- [ ] npm run build succeeds
- [ ] cw plan --help shows: list, create, get, tasks
- [ ] cw architect --help shows: discuss, breakdown, decompose
- [ ] Commands follow existing CLI patterns (error handling, output format)
</verification>

<success_criteria>
- All tasks completed
- All verification checks pass
- No errors or warnings introduced
- Full CLI for plan management and decompose workflow
</success_criteria>

<output>
After completion, create `.planning/phases/12-phase-task-decomposition/12-06-SUMMARY.md`
</output>
