---
phase: 12-phase-task-decomposition
plan: 01
type: execute
wave: 1
depends_on: []
files_modified:
  - src/agent/types.ts
  - src/agent/schema.ts
  - src/db/schema.ts
  - src/db/repositories/drizzle/test-helpers.ts
autonomous: true
---

<objective>
Add decompose agent mode for breaking phases into individual tasks.

Purpose: Enable Architect agents to take a phase and produce a list of tasks with dependencies, types, and descriptions. This is the final piece of the initiative→phase→plan→task breakdown chain.

Output: AgentMode type extended with 'decompose', decompose output schema with Zod and JSON Schema versions, TaskBreakdown type.
</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

# Prior phase context (mode schemas from Phase 11)
@.planning/phases/11-architect-agent/11-01-SUMMARY.md

# Source files to modify
@src/agent/types.ts
@src/agent/schema.ts
@src/db/schema.ts
</context>

<tasks>

<task type="auto">
  <name>Task 1: Extend AgentMode with 'decompose'</name>
  <files>src/agent/types.ts, src/db/schema.ts, src/db/repositories/drizzle/test-helpers.ts</files>
  <action>
1. In src/agent/types.ts:
   - Update AgentMode type to include 'decompose': `'execute' | 'discuss' | 'breakdown' | 'decompose'`

2. In src/db/schema.ts:
   - Update agents table mode column enum to include 'decompose'

3. In src/db/repositories/drizzle/test-helpers.ts:
   - Update CREATE_TABLES_SQL agents table to include 'decompose' in mode column enum
  </action>
  <verify>npm run build passes, npm test passes</verify>
  <done>AgentMode type includes 'decompose', database schema updated</done>
</task>

<task type="auto">
  <name>Task 2: Create decompose output schema</name>
  <files>src/agent/schema.ts</files>
  <action>
1. Create TaskBreakdown type (similar to PhaseBreakdown):
   ```typescript
   const taskBreakdownSchema = z.object({
     number: z.number().int().positive(),
     name: z.string().min(1),
     description: z.string(),
     type: z.enum(['auto', 'checkpoint:human-verify', 'checkpoint:decision', 'checkpoint:human-action']).default('auto'),
     dependencies: z.array(z.number().int()).optional().default([]),
   });
   export type TaskBreakdown = z.infer<typeof taskBreakdownSchema>;
   ```

2. Create decomposeOutputSchema discriminated union:
   - 'questions' status with questions array (for clarification)
   - 'decompose_complete' status with tasks array
   - 'unrecoverable_error' status with error string

3. Create decomposeOutputJsonSchema (JSON Schema version for Claude CLI --json-schema)

4. Export all types and schemas from the file
  </action>
  <verify>npm run build passes, types exported correctly</verify>
  <done>decomposeOutputSchema and TaskBreakdown type exported, JSON schema version available</done>
</task>

</tasks>

<verification>
Before declaring plan complete:
- [ ] npm run build succeeds
- [ ] npm test passes all tests
- [ ] AgentMode type includes 'decompose'
- [ ] decomposeOutputSchema exported from src/agent/schema.ts
- [ ] decomposeOutputJsonSchema exported from src/agent/schema.ts
- [ ] TaskBreakdown type exported
</verification>

<success_criteria>
- All tasks completed
- All verification checks pass
- No errors or warnings introduced
- Decompose mode schema ready for manager implementation
</success_criteria>

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