--- description: Execute tasks in parallel waves with optimal agent selection and review argument-hint: allowed-tools: Task, Read, Write, Edit, Glob, Grep, Bash, TodoWrite --- Execute these tasks in parallel waves with proper review: $ARGUMENTS ## Instructions Load the `orchestrated-execution` skill, then: ### Philosophy: Do It Right **Take your time. No shortcuts.** Every implementation should be: - **Clean** - Readable, well-named, minimal complexity - **Maintainable** - Future developers can understand and modify it - **Extensible** - Easy to add features without rewriting - **Refactored** - If existing code is messy, clean it up as you go When you encounter code that could be better: - Refactor it. Don't work around bad patterns. - Extract helpers, rename unclear variables, simplify nesting - Leave the codebase better than you found it **Prefer proper solutions over quick fixes.** A 50-line clean implementation beats a 10-line hack. ### Phase 1: Parse & Analyze 1. **Parse tasks** - From todo list or provided 2. **Analyze dependencies** - Which tasks depend on which 3. **Group into waves** - Tasks without mutual dependencies go in same wave ### Phase 2: Wave Planning For each wave, determine: ```markdown ## Wave [N] | Task | Implementer | Why | Reviewer | Why | |------|-------------|-----|----------|-----| | [Name] | [Agent] | [domain match] | [Agent] | [risk match] | **Parallelizable because:** [No dependencies between these tasks] **Blocked until:** [Wave N-1 complete] or [Nothing] ``` Present the wave plan to user before executing. ### Phase 3: Execute Each Wave ``` Wave N: ┌─────────────────────────────────────────────┐ │ 1. LAUNCH ALL IMPLEMENTERS (parallel) │ │ │ │ Task(agent1, task1) ──┐ │ │ Task(agent2, task2) ──┼── concurrent │ │ Task(agent3, task3) ──┘ │ └─────────────────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────┐ │ 2. COLLECT RESULTS │ │ Wait for all to complete │ │ Gather implementation outputs │ └─────────────────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────┐ │ 3. LAUNCH ALL REVIEWERS (parallel) │ │ │ │ Task(reviewer1, review1) ──┐ │ │ Task(reviewer2, review2) ──┼── concurrent│ │ Task(reviewer3, review3) ──┘ │ └─────────────────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────┐ │ 4. PROCESS REVIEW RESULTS │ │ │ │ PASS → mark complete │ │ NEEDS_FIX → fix loop (can parallelize) │ │ BLOCK → escalate immediately │ └─────────────────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────┐ │ 5. VERIFY WAVE COMPLETE │ │ All tasks in wave done? │ │ Any conflicts from parallel execution? │ └─────────────────────────────────────────────┘ │ ▼ Continue to Wave N+1 ``` ### Phase 4: Loose Ends (Critical for Parallel) After all waves, explicitly check: 1. **File conflicts** - Did parallel tasks modify same files? 2. **Integration gaps** - Do the pieces work together? 3. **Merge issues** - Any conflicting changes to resolve? 4. **Cross-cutting** - Consistent patterns across all tasks? 5. **Quality gate** - Full build, test, lint ### Phase 5: Final Report ```markdown ## Parallel Execution Complete ### Wave Summary | Wave | Tasks | Parallel Time | Status | |------|-------|---------------|--------| | 1 | 3 | ~2min | ✓ | | 2 | 2 | ~1min | ✓ | | 3 | 1 | ~1min | ✓ | ### Task Details | Task | Wave | Implementer | Reviewer | Issues Fixed | Status | |------|------|-------------|----------|--------------|--------| ### Loose Ends Resolved - [Conflicts fixed] - [Integration issues addressed] ### Quality Gate - Build: PASS - Tests: PASS - Lint: PASS ``` ## Dependency Detection Tasks depend on each other when: ``` Task A: "Create User model" Task B: "Add validation to User model" ← Depends on A Task A: "Implement auth backend" Task B: "Write auth tests" ← Depends on A Task A: "Update config schema" Task B: "Migrate existing configs" ← Depends on A ``` Tasks are independent when: ``` Task A: "Add logging to ingestion" Task B: "Add metrics to query" ← Different modules, independent Task A: "Write User docs" Task B: "Write Config docs" ← Different files, independent ``` ## Agent Selection ### Implementers | Task Type | Agent | |-----------|-------| | Go code, features | `go-specialist` | | Tests | `testing-strategist` | | API design | `api-designer` | | Database | `database-architect` | | K8s, deployment | `worker-specialist` | | Security, auth | `security-architect` | | Architecture | `hexagonal-architect` | | Docs | `librarian` | ### Reviewers | Risk Type | Reviewer | |-----------|----------| | Code quality | `quality-engineer` | | Security | `security-architect` | | Architecture | `hexagonal-architect` | | Test coverage | `testing-strategist` | ## Wave Progress Format ```markdown ## Wave 2 Progress ### Implementing (parallel) → Task 4: auth-backend - go-specialist → Task 5: rate-limiter - security-architect → Task 6: metrics - go-specialist ### Wave 1 Complete ✓ Task 1: user-model - go-specialist ✓ quality-engineer ✓ Task 2: config-schema - go-specialist ✓ quality-engineer ✓ Task 3: docs-update - librarian ✓ librarian ``` ## Critical Rules - NEVER put dependent tasks in same wave - ALWAYS review even in parallel mode - ALWAYS check for conflicts after parallel execution - ALWAYS run quality gate at the end - ANNOUNCE wave plan before executing - MAX 3 fix cycles per task, then escalate ## Step Back: Before Each Wave 1. **Dependencies verified?** Wave N-1 complete? 2. **No conflicts anticipated?** Parallel tasks won't clash? 3. **Right agents selected?** Re-check before launching 4. **Rollback plan?** If wave fails, how do we recover? ## Step Back: After Each Wave 1. **All tasks actually complete?** Not just "launched" 2. **Reviews actually done?** Not skipped for speed 3. **Issues actually fixed?** Not deferred 4. **No file conflicts?** From parallel writes