From ai-workflow
Orchestrates multi-phase implementation from plan documents using sub-agents with auto-detected parallel/sequential strategies based on dependencies.
npx claudepluginhub charlesjones-dev/claude-code-plugins-dev --plugin ai-workflowThis skill uses the workspace's default tool permissions.
Analyzes phases from a plan document and orchestrates implementation using sub-agents with optimal execution strategy.
Generates detailed phased implementation plans from approved designs, with codebase grounding via grep/glob and investigator queries for agent assignments.
Orchestrates execution of implementation plans with independent tasks by dispatching implementers and reviewers, tracking granular progress per task and phase.
Executes implementation plans from plan.md files via Superpower Loop phases: task creation, batch execution with verification, git commits. Use after plan ready or on 'execute the plan'.
Share bugs, ideas, or general feedback.
Analyzes phases from a plan document and orchestrates implementation using sub-agents with optimal execution strategy.
/workflow-implement-phases # Search docs/plans/ and pick one
/workflow-implement-phases @path/to/plan.md
/workflow-implement-phases @path/to/plan.md --phases=1,2,3
/workflow-implement-phases @path/to/plan.md --strategy=parallel|sequential|auto
plan_file (optional): Path to the plan document. If omitted, searches docs/plans/ for existing plans--phases: Comma-separated list of specific phases to implement (default: all)--strategy: Force execution strategy. Default is auto (analyzed)Read the plan file passed as an argument (e.g., @docs/plans/my-plan.md) and proceed with the workflow.
docs/plans/ directory/workflow-plan-phases to create one firstMANDATORY: Every phase MUST be implemented via a Task() sub-agent.
This skill provides the methodology for analyzing plan documents, determining optimal execution strategies, and coordinating phase implementation through sub-agents.
When implementing phases from a plan document, the orchestrator must:
YOU MUST USE THE TASK TOOL TO SPAWN A SUB-AGENT FOR EVERY PHASE IMPLEMENTATION.
This is a non-negotiable requirement. The orchestrator (main agent) is ONLY responsible for:
The orchestrator MUST NOT:
Why this matters:
Correct pattern:
# For each phase (or group of parallel phases), spawn Task() sub-agents
Task(
subagent_type="general-purpose",
prompt="[Phase implementation prompt with full spec and acceptance criteria]",
description="Implement phase-1: [name]"
)
WRONG pattern (never do this):
# Never implement phases directly
Edit(file_path="src/feature.ts", ...) # WRONG - orchestrator should not edit files
Write(file_path="src/new-file.ts", ...) # WRONG - orchestrator should not create files
Extract from the plan file:
phases = [
{
id: "phase-1",
name: "Human-readable name",
spec: "Full specification text",
acceptance_criteria: ["criterion 1", "criterion 2"],
explicit_dependencies: ["phase-0"] // if stated
},
...
]
Look for phase definitions in these formats:
## Phase 1:, ### Phase 1 -, **Phase 1**# Step 1, ## Step 1:1., 1), (1)Extract acceptance criteria from:
- [ ] criterionPatterns that indicate explicit ordering:
Data/Schema Dependencies
DEPENDENT if Phase B:
- References database tables created in Phase A
- Uses migrations from Phase A
- Queries data that Phase A populates
API/Interface Dependencies
DEPENDENT if Phase B:
- Calls endpoints defined in Phase A
- Imports services/modules created in Phase A
- Uses types/interfaces exported by Phase A
File Dependencies
DEPENDENT if Phase B:
- Modifies files created in Phase A
- Extends classes defined in Phase A
- Imports from paths that Phase A creates
Configuration Dependencies
DEPENDENT if Phase B:
- Requires environment variables Phase A documents
- Uses config keys Phase A introduces
- Needs secrets/credentials Phase A sets up
Build Dependencies
DEPENDENT if Phase B:
- Requires compiled output from Phase A
- Uses generated code from Phase A
- Needs artifacts (bundles, images) from Phase A
High confidence parallel candidates:
for each phase_b in phases:
for each phase_a in phases where phase_a != phase_b:
# Check explicit
if phase_b.spec mentions phase_a.id as dependency:
add_dependency(phase_b, phase_a, confidence=HIGH)
# Check implicit - file paths
files_created_by_a = extract_file_paths(phase_a.spec)
files_referenced_by_b = extract_file_paths(phase_b.spec)
if intersection(files_created_by_a, files_referenced_by_b):
add_dependency(phase_b, phase_a, confidence=MEDIUM)
# Check implicit - imports/types
exports_from_a = extract_exports(phase_a.spec)
imports_in_b = extract_imports(phase_b.spec)
if intersection(exports_from_a, imports_in_b):
add_dependency(phase_b, phase_a, confidence=MEDIUM)
# Check implicit - keywords
if phase_b.spec contains "after {phase_a.name}":
add_dependency(phase_b, phase_a, confidence=HIGH)
if phase_b.spec contains "using {artifact from phase_a}":
add_dependency(phase_b, phase_a, confidence=MEDIUM)
PARALLEL - All phases run simultaneously:
Conditions:
- No dependencies between any phases
- Phases operate on isolated code paths
- No shared files being modified
- Low risk of merge conflicts
Benefits:
- Fastest total execution time
- Maximum context isolation
Risks:
- Potential merge conflicts if analysis missed shared files
SEQUENTIAL - Phases run one after another:
Conditions:
- Linear dependency chain exists
- Each phase depends on previous
- Shared state or files across phases
- High integration complexity
Benefits:
- Safest execution
- Each phase has full context from prior phases
- Easier debugging
Risks:
- Slowest execution
- Context may still accumulate if not managed
MIXED - Parallel groups with sequential ordering between groups:
Conditions:
- Some phases are independent (parallel within group)
- Some phases have dependencies (sequential between groups)
Algorithm:
1. Build dependency graph
2. Topologically sort into levels
3. Phases at same level (no dependencies on each other) run parallel
4. Wait for level to complete before starting next level
Example:
Level 0: [phase-1, phase-3] # No dependencies, run parallel
Level 1: [phase-2] # Depends on phase-1
Level 2: [phase-4, phase-5] # Both depend on phase-2
Present to user before executing:
## Phase Execution Plan
### Phases Analyzed
| Phase | Description | Dependencies | Level |
|-------|-------------|--------------|-------|
| phase-1 | Create user model | None | 0 |
| phase-3 | Add logging | None | 0 |
| phase-2 | Authentication | phase-1 | 1 |
| phase-4 | User API | phase-2 | 2 |
| phase-5 | Admin API | phase-2 | 2 |
### Execution Strategy: **MIXED**
Level 0 (parallel): phase-1 -+- phase-3 | Level 1 (sequential): phase-2 <+ | Level 2 (parallel): phase-4 -+- phase-5
### Dependency Reasoning
- phase-1 <-> phase-3: Independent (separate directories)
- phase-2 -> phase-1: Uses User model (import dependency)
- phase-4 -> phase-2: Uses auth middleware (API dependency)
- phase-5 -> phase-2: Uses auth middleware (API dependency)
- phase-4 <-> phase-5: Independent (separate route files)
### Estimated Execution
- 3 sub-agent cycles (parallel reduces from 5 sequential)
Proceed? [Y/n/modify]
REMINDER: You MUST use Task() sub-agents for ALL phase implementations. Never implement directly.
mkdir -p .claude/phase-coordination/{artifacts,results}
When spawning Task() for each phase (REQUIRED for every phase):
## Phase Implementation Task
**Phase ID**: {phase_id}
**Phase Name**: {phase_name}
### Specification
{full_phase_spec}
### Acceptance Criteria
{acceptance_criteria_list}
### Context from Prior Phases
{if sequential or mixed, include summary from dependency phases}
Read artifacts from: `.claude/phase-coordination/artifacts/`
Write your artifacts to: `.claude/phase-coordination/artifacts/{phase_id}/`
### Required Outputs
1. **Implement the phase** according to specification
2. **Create results file** at `.claude/phase-coordination/results/{phase_id}.md`:
```markdown
# {phase_id} Results
## Summary
[2-3 sentences on what was implemented]
## Files Changed
- `path/to/file` - [description]
## Key Decisions
- [Decision]: [Rationale]
## Interfaces Exposed
[Types, functions, or contracts for downstream phases]
## Deviations
[Any deviations from spec with justification]
## Verification
[How to verify this phase works]
### Parallel Execution Pattern
**Use multiple Task() calls in a SINGLE message to execute phases in parallel:**
Task( subagent_type="general-purpose", prompt=build_phase_prompt(phase_1), description="Implement phase-1: [name]" ) Task( subagent_type="general-purpose", prompt=build_phase_prompt(phase_2), description="Implement phase-2: [name]" ) Task( subagent_type="general-purpose", prompt=build_phase_prompt(phase_3), description="Implement phase-3: [name]" )
### Sequential Execution Pattern
**Each phase STILL requires its own Task() sub-agent, just called one at a time:**
for phase in topologically_sorted_phases:
dependency_context = "" for dep in phase.dependencies: dep_results = read(f".claude/phase-coordination/results/{dep.id}.md") dependency_context += f"\n### Context from {dep.id}\n{dep_results}"
Task( subagent_type="general-purpose", prompt=build_phase_prompt(phase, dependency_context), description="Implement {phase.id}: {phase.name}" )
verify_phase_results(phase)
---
## Step 5: Error Handling
### Phase Failure
If a phase fails:
### Dependency Conflict
If sub-agent reports unexpected dependency:
### Uncertain Dependencies
When confidence is low:
---
## Step 6: Results Aggregation
### Final Summary Template
```markdown
## Implementation Complete
### Execution Summary
| Phase | Status | Files | Duration |
|-------|--------|-------|----------|
| phase-1 | Done | 3 | ~1 cycle |
| phase-3 | Done | 1 | ~1 cycle |
| phase-2 | Done | 4 | ~1 cycle |
| phase-4 | Done | 2 | ~1 cycle |
| phase-5 | Partial | 1 | ~1 cycle |
### Strategy Used
Mixed parallel/sequential across 3 levels
### All Files Modified
- `src/models/user.ts` (phase-1)
- `src/middleware/logging.ts` (phase-3)
- `src/middleware/auth.ts` (phase-2)
- `src/routes/users.ts` (phase-4)
- `src/routes/admin.ts` (phase-5, incomplete)
### Key Decisions Across Phases
[Aggregated from phase results]
### Integration Points to Verify
- [ ] User model imports correctly in auth
- [ ] Auth middleware registered in app
- [ ] Logging captures auth events
### Issues Encountered
- phase-5: Admin role enum not defined, implemented basic version
### Recommended Next Steps
1. Run test suite: `npm test`
2. Manually verify integration points
3. Review phase-5 partial implementation
4. Address any flagged deviations
### Artifacts Location
Full details: `.claude/phase-coordination/results/`
Shared artifacts: `.claude/phase-coordination/artifacts/`
After user confirms completion:
# Option to preserve for debugging
mv .claude/phase-coordination .claude/phase-coordination-{timestamp}
# Or clean up
rm -rf .claude/phase-coordination
Recommend user run /compact after completion since detailed context is persisted to files.