refactor(execute-phase): wave-based blocking execution

Replace background agents + polling with blocking Task calls.
Orchestrator stays lean (~15% context), subagents load full workflow.

- Archive old execute-phase command and workflow
- Add subagent-task-prompt.md template (orchestrator→subagent contract)
- Rewrite execute-phase with wave-based parallelization
- Dependency analysis groups plans into execution waves
- Parallel Task calls within waves, sequential across waves
- No TaskOutput polling - Task blocks until completion

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Lex Christopherson
2026-01-13 16:06:17 -06:00
parent a97c567b01
commit e30e387c00
5 changed files with 1356 additions and 904 deletions

View File

@@ -0,0 +1,120 @@
---
name: gsd:execute-phase
description: Execute all plans in a phase with intelligent parallelization
argument-hint: "<phase-number>"
allowed-tools:
- Read
- Write
- Edit
- Bash
- Glob
- Grep
- Task
- TaskOutput
- AskUserQuestion
- SlashCommand
---
<objective>
Execute all unexecuted plans in a phase with parallel agent spawning.
Analyzes plan dependencies to identify independent plans that can run concurrently.
Spawns background agents for parallel execution, each agent commits its own tasks atomically.
**Critical constraint:** One subagent per plan, always. This is for context isolation, not parallelization. Even strictly sequential plans spawn separate subagents so each starts with fresh 200k context at 0%.
Use this command when:
- Phase has 2+ unexecuted plans
- Want "walk away, come back to completed work" execution
- Plans have clear dependency boundaries
</objective>
<execution_context>
@~/.claude/get-shit-done/workflows/execute-plan.md
@~/.claude/get-shit-done/workflows/execute-phase.md
@~/.claude/get-shit-done/templates/summary.md
@~/.claude/get-shit-done/references/checkpoints.md
@~/.claude/get-shit-done/references/tdd.md
</execution_context>
<context>
Phase number: $ARGUMENTS (required)
@.planning/STATE.md
@.planning/config.json
</context>
<process>
1. Validate phase exists in roadmap
2. Find all PLAN.md files without matching SUMMARY.md
3. If 0 or 1 plans: suggest /gsd:execute-plan instead
4. If 2+ plans: follow execute-phase.md workflow
5. Monitor parallel agents until completion
6. Present results and next steps
</process>
<execution_strategies>
**Strategy A: Fully Autonomous** (no checkpoints)
- Spawn subagent to execute entire plan
- Subagent creates SUMMARY.md and commits
- Main context: orchestration only (~5% usage)
**Strategy B: Segmented** (has verify-only checkpoints)
- Execute in segments between checkpoints
- Subagent for autonomous segments
- Main context for checkpoints
- Aggregate results → SUMMARY → commit
**Strategy C: Decision-Dependent** (has decision checkpoints)
- Execute in main context
- Decision outcomes affect subsequent tasks
- Quality maintained through small scope (2-3 tasks per plan)
</execution_strategies>
<deviation_rules>
During execution, handle discoveries automatically:
1. **Auto-fix bugs** - Fix immediately, document in Summary
2. **Auto-add critical** - Security/correctness gaps, add and document
3. **Auto-fix blockers** - Can't proceed without fix, do it and document
4. **Ask about architectural** - Major structural changes, stop and ask user
5. **Log enhancements** - Nice-to-haves, log to ISSUES.md, continue
Only rule 4 requires user intervention.
</deviation_rules>
<commit_rules>
**Per-Task Commits:**
After each task completes:
1. Stage only files modified by that task
2. Commit with format: `{type}({phase}-{plan}): {task-name}`
3. Types: feat, fix, test, refactor, perf, chore
4. Record commit hash for SUMMARY.md
**Plan Metadata Commit:**
After all tasks complete:
1. Stage planning artifacts only: PLAN.md, SUMMARY.md, STATE.md, ROADMAP.md
2. Commit with format: `docs({phase}-{plan}): complete [plan-name] plan`
3. NO code files (already committed per-task)
**NEVER use:**
- `git add .`
- `git add -A`
- `git add src/` or any broad directory
**Always stage files individually.**
</commit_rules>
<success_criteria>
- [ ] All independent plans executed in parallel
- [ ] Dependent plans executed after dependencies complete
- [ ] Each task committed individually (feat/fix/test/refactor)
- [ ] All SUMMARY.md files created
- [ ] Metadata committed by orchestrator
- [ ] Phase progress updated
</success_criteria>

View File

@@ -1,120 +1,113 @@
---
name: gsd:execute-phase
description: Execute all plans in a phase with intelligent parallelization
description: Execute all plans in a phase with wave-based parallelization
argument-hint: "<phase-number>"
allowed-tools:
- Read
- Write
- Edit
- Bash
- Glob
- Grep
- Bash
- Task
- TaskOutput
- TodoWrite
- AskUserQuestion
- SlashCommand
---
<objective>
Execute all unexecuted plans in a phase with parallel agent spawning.
Execute all plans in a phase using wave-based parallel execution.
Analyzes plan dependencies to identify independent plans that can run concurrently.
Spawns background agents for parallel execution, each agent commits its own tasks atomically.
Orchestrator stays lean: discover plans, analyze dependencies, group into waves, spawn subagents, collect results. Each subagent loads the full execute-plan context and handles its own plan.
**Critical constraint:** One subagent per plan, always. This is for context isolation, not parallelization. Even strictly sequential plans spawn separate subagents so each starts with fresh 200k context at 0%.
Use this command when:
- Phase has 2+ unexecuted plans
- Want "walk away, come back to completed work" execution
- Plans have clear dependency boundaries
Context budget: ~15% orchestrator, 100% fresh per subagent.
</objective>
<execution_context>
@~/.claude/get-shit-done/workflows/execute-plan.md
@~/.claude/get-shit-done/workflows/execute-phase.md
@~/.claude/get-shit-done/templates/summary.md
@~/.claude/get-shit-done/references/checkpoints.md
@~/.claude/get-shit-done/references/tdd.md
@~/.claude/get-shit-done/templates/subagent-task-prompt.md
</execution_context>
<context>
Phase number: $ARGUMENTS (required)
Phase: $ARGUMENTS
@.planning/ROADMAP.md
@.planning/STATE.md
@.planning/config.json
</context>
<process>
1. Validate phase exists in roadmap
2. Find all PLAN.md files without matching SUMMARY.md
3. If 0 or 1 plans: suggest /gsd:execute-plan instead
4. If 2+ plans: follow execute-phase.md workflow
5. Monitor parallel agents until completion
6. Present results and next steps
1. **Validate phase exists**
- Find phase directory matching argument
- Count PLAN.md files
- Error if no plans found
2. **Discover plans**
- List all *-PLAN.md files in phase directory
- Check which have *-SUMMARY.md (already complete)
- Build list of incomplete plans
3. **Analyze dependencies**
- Read each plan's `<context>` section
- Detect cross-references to other plans' outputs
- Build dependency graph
4. **Group into waves**
- Wave 1: Plans with no dependencies
- Wave N: Plans depending only on earlier waves
- Report wave structure to user
5. **Execute waves**
For each wave:
- Fill subagent-task-prompt template for each plan
- Spawn all agents in wave simultaneously (parallel Task calls)
- Wait for completion (Task blocks)
- Verify SUMMARYs created
- Proceed to next wave
6. **Aggregate results**
- Collect summaries from all plans
- Report phase completion status
- Update ROADMAP.md
7. **Offer next steps**
- More phases → `/gsd:plan-phase {next}`
- Milestone complete → `/gsd:complete-milestone`
</process>
<execution_strategies>
**Strategy A: Fully Autonomous** (no checkpoints)
<wave_execution>
**Parallel spawning:**
- Spawn subagent to execute entire plan
- Subagent creates SUMMARY.md and commits
- Main context: orchestration only (~5% usage)
Spawn all plans in a wave with a single message containing multiple Task calls:
**Strategy B: Segmented** (has verify-only checkpoints)
```
Task(prompt=filled_template_for_plan_01, subagent_type="general-purpose")
Task(prompt=filled_template_for_plan_02, subagent_type="general-purpose")
Task(prompt=filled_template_for_plan_03, subagent_type="general-purpose")
```
- Execute in segments between checkpoints
- Subagent for autonomous segments
- Main context for checkpoints
- Aggregate results → SUMMARY → commit
All three run in parallel. Task tool blocks until all complete.
**Strategy C: Decision-Dependent** (has decision checkpoints)
**No polling.** No background agents. No TaskOutput loops.
</wave_execution>
- Execute in main context
- Decision outcomes affect subsequent tasks
- Quality maintained through small scope (2-3 tasks per plan)
</execution_strategies>
<checkpoint_detection>
Before adding a plan to a parallel wave, scan for checkpoints:
<deviation_rules>
During execution, handle discoveries automatically:
```bash
grep -c 'type="checkpoint' {plan_path}
```
1. **Auto-fix bugs** - Fix immediately, document in Summary
2. **Auto-add critical** - Security/correctness gaps, add and document
3. **Auto-fix blockers** - Can't proceed without fix, do it and document
4. **Ask about architectural** - Major structural changes, stop and ask user
5. **Log enhancements** - Nice-to-haves, log to ISSUES.md, continue
**If checkpoints > 0:**
- Plan requires user interaction
- Execute in main context OR as solo subagent (not parallel)
- User interaction flows through normally
Only rule 4 requires user intervention.
</deviation_rules>
<commit_rules>
**Per-Task Commits:**
After each task completes:
1. Stage only files modified by that task
2. Commit with format: `{type}({phase}-{plan}): {task-name}`
3. Types: feat, fix, test, refactor, perf, chore
4. Record commit hash for SUMMARY.md
**Plan Metadata Commit:**
After all tasks complete:
1. Stage planning artifacts only: PLAN.md, SUMMARY.md, STATE.md, ROADMAP.md
2. Commit with format: `docs({phase}-{plan}): complete [plan-name] plan`
3. NO code files (already committed per-task)
**NEVER use:**
- `git add .`
- `git add -A`
- `git add src/` or any broad directory
**Always stage files individually.**
</commit_rules>
**If checkpoints = 0:**
- Fully autonomous
- Safe for parallel wave execution
</checkpoint_detection>
<success_criteria>
- [ ] All independent plans executed in parallel
- [ ] Dependent plans executed after dependencies complete
- [ ] Each task committed individually (feat/fix/test/refactor)
- [ ] All SUMMARY.md files created
- [ ] Metadata committed by orchestrator
- [ ] Phase progress updated
- [ ] All incomplete plans in phase executed
- [ ] Each plan has SUMMARY.md
- [ ] STATE.md reflects phase completion
- [ ] ROADMAP.md updated
- [ ] User informed of next steps
</success_criteria>