perf(execute-plan): convert to orchestrator pattern

execute-plan.md command now spawns subagent instead of executing directly:
- Loads only subagent-task-prompt template (~100 lines vs ~2200)
- Subagent loads full execute-plan workflow, summary, checkpoints, tdd
- Handles checkpoint returns with resume flow
- ~80% context reduction for orchestrator

Also updated subagent-task-prompt.md description to clarify it's used by
both execute-phase (parallel) and execute-plan (single) orchestrators.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Lex Christopherson
2026-01-13 17:38:52 -06:00
parent 965d936709
commit 8ed6a8fa50
2 changed files with 66 additions and 92 deletions

View File

@@ -4,126 +4,100 @@ description: Execute a PLAN.md file
argument-hint: "[path-to-PLAN.md]" argument-hint: "[path-to-PLAN.md]"
allowed-tools: allowed-tools:
- Read - Read
- Write
- Edit
- Bash
- Glob - Glob
- Grep - Grep
- Bash
- Task - Task
- TodoWrite
- AskUserQuestion - AskUserQuestion
- SlashCommand
--- ---
<objective> <objective>
Execute a PLAN.md file with per-task atomic commits, create SUMMARY.md, update project state. Execute a single PLAN.md file by spawning a subagent.
Commit strategy: Orchestrator stays lean: validate plan, spawn subagent, handle checkpoints, report completion. Subagent loads full execute-plan workflow and handles all execution details.
- Each task → 1 commit immediately after completion (feat/fix/test/refactor)
- Plan completion → 1 metadata commit (docs: SUMMARY + STATE + ROADMAP)
Uses intelligent segmentation: Context budget: ~15% orchestrator, 100% fresh for subagent.
- Plans without checkpoints → spawn subagent for full autonomous execution </objective>
- Plans with verify checkpoints → segment execution, pause at checkpoints
- Plans with decision checkpoints → execute in main context
</objective>
<execution_context> <execution_context>
@~/.claude/get-shit-done/workflows/execute-plan.md @~/.claude/get-shit-done/templates/subagent-task-prompt.md
@~/.claude/get-shit-done/templates/summary.md
@~/.claude/get-shit-done/references/checkpoints.md
@~/.claude/get-shit-done/references/tdd.md
</execution_context> </execution_context>
<context> <context>
Plan path: $ARGUMENTS Plan path: $ARGUMENTS
**Load project state first:**
@.planning/STATE.md @.planning/STATE.md
@.planning/config.json (if exists)
**Load workflow config:**
@.planning/config.json
</context> </context>
<process> <process>
1. Check .planning/ directory exists (error if not - user should run /gsd:new-project) 1. **Validate plan exists**
2. Verify plan at $ARGUMENTS exists - Confirm file at $ARGUMENTS exists
3. Check if SUMMARY.md already exists (plan already executed?) - Error if not found: "Plan not found: {path}"
4. Load workflow config for mode (interactive/yolo)
5. Follow execute-plan.md workflow: 2. **Check if already executed**
- Parse plan and determine execution strategy (A/B/C) - Derive SUMMARY path from plan path (replace PLAN.md with SUMMARY.md)
- Execute tasks (via subagent or main context as appropriate) - If SUMMARY exists: "Plan already executed. SUMMARY: {path}"
- Handle checkpoints and deviations - Offer: re-execute or exit
- Create SUMMARY.md
- Update STATE.md 3. **Parse plan identifiers**
- Commit changes Extract from path like `.planning/phases/03-auth/03-02-PLAN.md`:
- phase_number: `03`
- phase_name: `auth`
- plan_number: `02`
- plan_path: full path
4. **Fill and spawn subagent**
- Fill subagent-task-prompt template with extracted values
- Spawn: `Task(prompt=filled_template, subagent_type="general-purpose")`
5. **Handle subagent return**
- If contains "## CHECKPOINT REACHED": Execute checkpoint_handling
- If contains "## PLAN COMPLETE": Verify SUMMARY exists, report success
6. **Report completion**
- Show SUMMARY path
- Show commits from subagent return
- Offer next steps
</process> </process>
<execution_strategies> <checkpoint_handling>
**Strategy A: Fully Autonomous** (no checkpoints) When subagent returns with checkpoint:
- Spawn subagent to execute entire plan **1. Parse return:**
- Subagent creates SUMMARY.md and commits ```
- Main context: orchestration only (~5% usage) ## CHECKPOINT REACHED
**Strategy B: Segmented** (has verify-only checkpoints) **Type:** [human-verify | decision | human-action]
**Plan:** {phase}-{plan}
**Progress:** {completed}/{total} tasks complete
- Execute in segments between checkpoints [Checkpoint content]
- Subagent for autonomous segments
- Main context for checkpoints
- Aggregate results → SUMMARY → commit
**Strategy C: Decision-Dependent** (has decision checkpoints) **Awaiting:** [Resume signal]
```
- Execute in main context **2. Present to user:**
- Decision outcomes affect subsequent tasks Display the checkpoint content exactly as returned by subagent.
- Quality maintained through small scope (2-3 tasks per plan)
</execution_strategies>
<deviation_rules> **3. Collect response:**
During execution, handle discoveries automatically: Wait for user input:
- human-verify: "approved" or description of issues
- decision: option selection
- human-action: "done" when complete
1. **Auto-fix bugs** - Fix immediately, document in Summary **4. Resume subagent:**
2. **Auto-add critical** - Security/correctness gaps, add and document ```
3. **Auto-fix blockers** - Can't proceed without fix, do it and document Task(resume="{agent_id}", prompt="User response: {user_input}")
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. **5. Repeat:**
</deviation_rules> Continue handling returns until "## PLAN COMPLETE" or user stops.
</checkpoint_handling>
<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.**
See ~/.claude/get-shit-done/references/git-integration.md for full commit strategy.
</commit_rules>
<success_criteria> <success_criteria>
- [ ] Plan executed (SUMMARY.md created)
- [ ] All tasks executed - [ ] All checkpoints handled
- [ ] Each task committed individually (feat/fix/test/refactor) - [ ] User informed of completion and next steps
- [ ] SUMMARY.md created with substantive content and commit hashes </success_criteria>
- [ ] STATE.md updated (position, decisions, issues, session)
- [ ] ROADMAP updated (plan count, phase status)
- [ ] Metadata committed with docs({phase}-{plan}): complete [plan-name] plan
- [ ] User informed of next steps
</success_criteria>

View File

@@ -1,6 +1,6 @@
# Subagent Task Prompt Template # Subagent Task Prompt Template
Template for spawning plan execution agents from execute-phase orchestrator. Template for spawning plan execution agents. Used by execute-phase (parallel) and execute-plan (single) orchestrators.
--- ---