Use when implementing phases from a plan document, executing phased implementations, orchestrating sub-agents for phase work, or when /workflow-implement-phases command is invoked. Provides dependency analysis and parallel/sequential execution strategies.
/plugin marketplace add charlesjones-dev/claude-code-plugins-dev/plugin install ai-workflow@claude-code-plugins-devThis skill inherits all available tools. When active, it can use any tool Claude has access to.
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.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.