Execute implementation plan with progress tracking and post-completion actions
Executes implementation plans with parallel task execution, two-stage reviews, and automated branch finishing.
/plugin marketplace add pproenca/dot-claude/plugin install dev-workflow@pproencaplan-fileExecute implementation plan with TodoWrite tracking and mandatory post-completion actions.
Model Requirements:
$ARGUMENTS
If empty or file not found: Stop with error "Plan file not found or not specified"
Check if working in main repo or already in a worktree:
source "${CLAUDE_PLUGIN_ROOT}/scripts/worktree-manager.sh"
# Check if in main repo (not already in a worktree)
if is_main_repo; then
echo "IN_MAIN_REPO=true"
else
echo "IN_MAIN_REPO=false"
CURRENT_DIR="$(pwd)"
echo "Already in worktree: ${CURRENT_DIR##*/}"
fi
Skip worktree creation. The current session is the isolated executor. Proceed to Step 1b: Orchestrator Role.
AskUserQuestion:
header: "Worktree"
question: "Create isolated worktree session for this work?"
multiSelect: false
options:
- label: "Yes - create worktree (Recommended)"
description: "Creates ../repo--branch, switches to it in current session"
- label: "No - work in main repo"
description: "Execute directly in main repo (not recommended)"
If user selects "Yes - create worktree":
Create worktree and switch to it in current session:
source "${CLAUDE_PLUGIN_ROOT}/scripts/worktree-manager.sh"
PLAN_FILE="$ARGUMENTS"
# Extract filename from path (avoid nested command substitutions)
PLAN_BASENAME="${PLAN_FILE##*/}"
PLAN_BASENAME="${PLAN_BASENAME%.md}"
# Remove date prefix using sed
BRANCH_NAME="$(echo "$PLAN_BASENAME" | sed 's/^[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-//')"
# Create sibling worktree
WORKTREE_PATH="$(create_worktree "$BRANCH_NAME")"
echo "Created worktree: $WORKTREE_PATH"
echo "Branch: $BRANCH_NAME"
# Change to worktree (plan file accessible via shared .git)
cd "$WORKTREE_PATH" && pwd
Report and CONTINUE to Step 1b:
Worktree created and activated.
Location: $WORKTREE_PATH
Branch: $BRANCH_NAME
Proceeding with plan execution in current session...
CONTINUE to Step 1b. The current session continues as orchestrator.
If user selects "No - work in main repo":
Continue in current directory. Proceed to Step 1b.
ROLE: ORCHESTRATOR
You are the ORCHESTRATOR for this plan execution.
Your responsibilities:
If you find yourself writing implementation code, STOP. Implementation is done by Task agents, not by you.
Proceed to Step 2.
Read the plan file and extract tasks:
PLAN_FILE="$ARGUMENTS"
# Verify plan exists
if [[ ! -f "$PLAN_FILE" ]]; then
echo "ERROR: Plan file not found: $PLAN_FILE"
exit 1
fi
# Extract task list from plan
grep -E "^### Task [0-9]+(\.[0-9]+)?:" "$PLAN_FILE" | sed 's/^### Task \([0-9.]*\): \(.*\)/Task \1: \2/'
Create TodoWrite with all tasks as pending, plus "Code Review" and "Finish Branch" at the end.
Tasks are grouped by file dependencies - tasks with no file overlap can run in parallel.
source "${CLAUDE_PLUGIN_ROOT}/scripts/hook-helpers.sh"
PLAN_FILE="$ARGUMENTS"
# Group tasks by file dependencies (max 5 per group)
GROUPS=$(group_tasks_by_dependency "$PLAN_FILE" 5)
# Output format: "group1:1,2,3|group2:4,5|group3:6"
echo "Task groups: $GROUPS"
FOR EACH group in GROUPS:
in_progress in TodoWriterun_in_background: true:# Launch ALL group tasks in SINGLE message for true parallelism
# Example: Group has tasks 1, 2, 3
Task:
subagent_type: general-purpose
model: opus
description: "Execute Task 1"
prompt: |
[Task 1 content from plan]
## Instructions
[Same instructions as below]
run_in_background: true
Task:
subagent_type: general-purpose
model: opus
description: "Execute Task 2"
prompt: |
[Task 2 content from plan]
## Instructions
[Same instructions as below]
run_in_background: true
Task:
subagent_type: general-purpose
model: opus
description: "Execute Task 3"
prompt: |
[Task 3 content from plan]
## Instructions
[Same instructions as below]
run_in_background: true
# Collect results (order doesn't matter - all run in parallel)
TaskOutput:
task_id: task_1_id
block: true
TaskOutput:
task_id: task_2_id
block: true
TaskOutput:
task_id: task_3_id
block: true
completed in TodoWriteIMPORTANT: If a worktree was created, include the WORKTREE_PATH in the prompt so the agent knows where to execute commands.
Task:
subagent_type: general-purpose
model: opus
description: "Execute Task [N]"
prompt: |
Execute Task [N] from the implementation plan.
## Working Directory
WORKTREE_PATH="{{WORKTREE_PATH}}"
**CRITICAL:** All bash commands MUST use this pattern:
```bash
cd "$WORKTREE_PATH" && <your-command>
```
All file paths should be absolute, e.g., `{{WORKTREE_PATH}}/src/file.py`
If WORKTREE_PATH is empty or not set, work in the current directory.
## Task Instructions
[Read task section from plan file and include here]
## Before You Begin
If anything is unclear about requirements, approach, or dependencies:
**Ask questions now.** Raise concerns before starting work.
## Your Job
1. Follow each Step exactly as written in the task instructions
2. After each "Run test" step, verify the expected output matches
3. Commit after tests pass
## While Working
If you encounter something unexpected or blockers, **ask for clarification**.
It's always OK to pause and clarify rather than guess.
**DO NOT:**
- Guess at unclear requirements
- Make assumptions about intent
- Add features not in the spec
- Skip verification steps
## Before Reporting Back: Self-Review (MANDATORY)
**Completeness:**
- Did I fully implement everything in the spec?
- Did I miss any requirements?
**Quality:**
- Is this my best work?
- Are names clear and accurate?
**Discipline:**
- Did I avoid overbuilding (YAGNI)?
- Did I follow existing patterns?
**Testing:**
- Do tests verify BEHAVIOR, not mocks?
- Did I watch each test fail first?
**Fix any issues before reporting.**
## Report Format
- Task completed
- What you implemented (specific changes)
- Files changed (with paths)
- Test results (command and output)
- Self-review findings
run_in_background: true
# DON'T DO THIS - defeats parallelism!
for each task:
task_id = Task(agent, run_in_background: true)
result = TaskOutput(task_id, block: true) # Blocks immediately!
# DO THIS - launch all, then collect all
task_1_id = Task(agent, Task 1, run_in_background: true)
task_2_id = Task(agent, Task 2, run_in_background: true)
task_3_id = Task(agent, Task 3, run_in_background: true)
# All three running simultaneously
result_1 = TaskOutput(task_1_id, block: true)
result_2 = TaskOutput(task_2_id, block: true)
result_3 = TaskOutput(task_3_id, block: true)
After implementer completes, run two-stage review before marking task complete.
Stage 1: Spec Compliance Review
Verify implementer built exactly what was requested.
Task:
subagent_type: general-purpose
model: opus
description: "Spec review Task [N]"
prompt: |
You are reviewing whether an implementation matches its specification.
## What Was Requested
[Task content from plan]
## What Implementer Claims They Built
[From implementer's report]
## CRITICAL: Do Not Trust the Report
**DO:**
- Read the actual code they wrote
- Compare implementation to requirements line by line
- Check for missing pieces
- Look for extra features not requested
## Report
✅ SPEC COMPLIANT - All requirements met, no extras, no missing items.
❌ SPEC ISSUES - List specifically:
- Missing: [requirement] not implemented
- Extra: [feature] added but not in spec
If spec issues found: Dispatch implementer to fix, then re-run spec review.
Stage 2: Code Quality Review
After spec compliance passes:
Task:
subagent_type: general-purpose
model: opus
description: "Quality review Task [N]"
prompt: |
Review code quality for Task [N]. Spec compliance already verified.
## Quality Criteria
**Code Structure:**
- Functions focused and single-purpose?
- Follows existing codebase patterns?
**Naming:**
- Names describe WHAT, not HOW?
**Testing:**
- Tests verify BEHAVIOR, not mocks?
## Report
✅ APPROVED - No critical or important issues.
⚠️ ISSUES FOUND:
- Critical: [issue] at [file:line]
- Important: [issue] at [file:line]
If critical/important issues found: Dispatch implementer to fix, then re-run quality review.
Mark task completed in TodoWrite. Continue to next task.
After ALL tasks complete:
Mark "Code Review" in_progress in TodoWrite.
Task:
subagent_type: dev-workflow:code-reviewer
model: opus
run_in_background: true
description: "Review all changes"
prompt: |
Review all changes from plan execution.
Run: git diff main..HEAD
Focus on cross-cutting concerns and consistency.
Wait for results:
TaskOutput:
task_id: <code-reviewer-task-id>
block: true
Use Skill("dev-workflow:receiving-code-review") to process feedback.
Mark "Code Review" completed.
Mark "Finish Branch" in_progress in TodoWrite.
Use Skill("dev-workflow:finishing-a-development-branch").
Mark "Finish Branch" completed.
If a task fails:
AskUserQuestion:
header: "Blocker"
question: "Task N failed. What to do?"
multiSelect: false
options:
- label: "Skip"
description: "Continue to next task"
- label: "Retry"
description: "Re-run the failed task"
- label: "Stop"
description: "Pause workflow, resume later"
If session ends unexpectedly:
/dev-workflow:execute-plan [plan-file]Commands: