---
phase: 12-phase-task-decomposition
plan: 05
subsystem: api
tags: [trpc, agent, prompts, decompose, spawn, architect]

# Dependency graph
requires:
  - phase: 12-03
    provides: handleDecomposeOutput method in ClaudeAgentManager
  - phase: 12-04
    provides: PlanRepository in tRPC context, Plan CRUD procedures
provides:
  - buildDecomposePrompt function for decompose mode agent prompts
  - spawnArchitectDecompose tRPC procedure for spawning decompose agents
affects: [cli-decompose-commands, 12-06, 12-08]

# Tech tracking
tech-stack:
  added: []
  patterns:
    - "Decompose prompt follows breakdown prompt pattern with plan/phase context"
    - "Architect spawn procedure validates entity existence before spawning"

key-files:
  created: []
  modified:
    - src/agent/prompts.ts
    - src/agent/index.ts
    - src/trpc/router.ts

key-decisions:
  - "buildDecomposePrompt takes Plan and Phase (not Initiative) to provide plan-level context"
  - "spawnArchitectDecompose associates with planId (not initiativeId) matching decompose scope"

patterns-established:
  - "Architect mode prompts: discuss/breakdown work on Initiative, decompose works on Plan"

# Metrics
duration: 4min
completed: 2026-02-01
---

# Phase 12 Plan 05: Decompose Prompts & Spawn Procedure Summary

**Added buildDecomposePrompt function and spawnArchitectDecompose tRPC procedure for spawning architect agents in decompose mode**

## Performance

- **Duration:** 4 min
- **Started:** 2026-02-01T10:46:30Z
- **Completed:** 2026-02-01T10:50:38Z
- **Tasks:** 3
- **Files modified:** 3

## Accomplishments

- Created comprehensive buildDecomposePrompt function explaining task breakdown rules and output format
- Exported buildDecomposePrompt from agent module public API
- Added spawnArchitectDecompose tRPC procedure with plan/phase validation
- All 402 tests pass with no regressions

## Task Commits

Each task was committed atomically:

1. **Task 1: Create buildDecomposePrompt function** - `48336ec` (feat)
2. **Task 2: Export buildDecomposePrompt from agent index** - `7ff979b` (feat)
3. **Task 3: Add spawnArchitectDecompose tRPC procedure** - `1fcbdf5` (feat)

## Files Created/Modified

- `src/agent/prompts.ts` - Added buildDecomposePrompt function with Plan/Phase types import
- `src/agent/index.ts` - Added buildDecomposePrompt to public exports
- `src/trpc/router.ts` - Added spawnArchitectDecompose procedure and buildDecomposePrompt import

## Decisions Made

1. **12-05: buildDecomposePrompt signature** - Takes Plan and Phase parameters (not Initiative) since decompose operates at plan level, providing plan name/description and phase context
2. **12-05: spawnArchitectDecompose taskId** - Associates spawned agent with planId (not initiativeId) to match the decompose scope

## Deviations from Plan

None - plan executed exactly as written.

## Issues Encountered

None

## User Setup Required

None - no external service configuration required.

## Next Phase Readiness

- Decompose prompts and spawn procedure ready for CLI integration
- Ready for 12-06 (Decompose CLI Commands)
- MockAgentManager already supports decompose_complete scenarios (from 12-03)
- Full decompose workflow can now be invoked via tRPC

---
*Phase: 12-phase-task-decomposition*
*Completed: 2026-02-01*
