--- name: ck-ccs-delegation description: > Orchestrates parallel and sequential agent delegation via Manager Surface. Activate when user says 'delegate this task', 'run agents in parallel', 'spawn subagents', 'coordinate multiple agents', 'parallel execution', or 'multi-agent workflow'. Accepts task descriptions, dependency graphs, and parallelization strategies. --- ## Overview Defines patterns for decomposing work across multiple agents using the Manager Surface. Handles parallel dispatch, sequential chaining, dependency management, and result aggregation. ## When to Use - Task can be split into independent subtasks that benefit from parallel execution - Complex workflows requiring sequential agent chaining (plan → implement → test → review) - Research tasks needing multiple specialized agents working simultaneously - Large implementation broken into non-conflicting file ownership zones - Orchestrating plan phases across parallel developer agents ## Don't Use When - Task is simple and fits within a single agent's context - Subtasks have tight coupling making parallelization harmful - Sequential dependency chain is unavoidable and short - Debugging a single focused issue (use ck-debug instead) ## Steps / Instructions ### 1. Decompose the Work Identify parallelizable vs sequential segments: ``` Sequential chain (dependencies): Research → Plan → Implement → Test → Review Parallel dispatch (independent): Phase 1A: auth module ─┐ Phase 1B: data models ─┼─ all start simultaneously Phase 1C: API routes ─┘ Phase 2: integration tests (after 1A, 1B, 1C complete) ``` ### 2. Define File Ownership Each parallel agent must own non-overlapping files: ```markdown Agent A owns: - src/auth/** - src/middleware/auth.ts Agent B owns: - src/models/** - prisma/schema.prisma Agent C owns: - src/routes/** - src/controllers/** ``` ### 3. Dispatch Parallel Agents via Manager Surface For independent parallel tasks, dispatch all at once: ``` Manager Surface dispatch: Agent 1: "Implement authentication module. Work context: /path/to/project. File ownership: src/auth/**, src/middleware/auth.ts Reports: /path/to/project/plans/reports/" Agent 2: "Implement data models. Work context: /path/to/project. File ownership: src/models/**, prisma/schema.prisma Reports: /path/to/project/plans/reports/" Agent 3: "Implement API routes. Work context: /path/to/project. File ownership: src/routes/**, src/controllers/** Reports: /path/to/project/plans/reports/" ``` ### 4. Sequential Chaining Pattern Pass outputs between agents: ``` Step 1: dispatch researcher agent → researcher writes report to plans/reports/research-report.md Step 2: dispatch planner agent (after researcher completes) → planner reads research report, creates plan in plans/ Step 3: dispatch parallel developer agents (after planner completes) → each developer reads their phase file from plans/ Step 4: dispatch tester agent (after all developers complete) → tester runs full test suite Step 5: dispatch reviewer agent (after tests pass) → reviewer reads changed files and reports ``` ### 5. Delegation Prompt Template Always include in each agent's prompt: 1. **Work context path** — git root of the project 2. **Reports path** — where to write output reports 3. **Plans path** — where plan files live 4. **File ownership** — explicit list of owned files 5. **Phase file** — path to the phase spec the agent implements ```markdown Task: Implement Phase 2 - Database Models Work context: /path/to/project Reports: /path/to/project/plans/reports/ Plans: /path/to/project/plans/ Phase file: /path/to/project/plans/260216-1400-feature/phase-02-models.md File ownership (modify ONLY these): - src/models/user.ts - src/models/post.ts - prisma/schema.prisma Dependencies complete: Phase 1 (env setup) is done. ``` ### 6. Aggregate Results After all parallel agents complete: 1. Read each agent's report from `plans/reports/` 2. Check for file ownership violations 3. Verify success criteria from each phase 4. Run integration tests across all implemented modules 5. Dispatch reviewer if all tests pass ### 7. Conflict Resolution If agents report file conflicts: 1. Stop all dependent phases 2. Identify which agents touched overlapping files 3. Assign clear ownership to one agent 4. Re-run the affected phase with corrected ownership ## Notes - Always include work context and reports path in delegation prompts - File ownership boundaries prevent merge conflicts - Parallel agents should never read files owned by sibling parallel agents - Report aggregation is the orchestrator's responsibility, not individual agents