From principled-implementation
Top-level orchestrator for DDD plan execution. Decomposes a plan into tasks, iterates through phases respecting dependencies, spawns worktree-isolated agents, validates implementations, and merges results. Runs inline to coordinate multiple sub-agent spawns. Use for automated end-to-end plan execution.
How this skill is triggered — by the user, by Claude, or both
Slash command
/principled-implementation:orchestrateThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Execute a complete DDD plan from decomposition through validation and merge, managing the entire lifecycle automatically.
Execute a complete DDD plan from decomposition through validation and merge, managing the entire lifecycle automatically.
/orchestrate <plan-path> [--phase <N>] [--continue] [--dry-run]
| Argument | Required | Description |
|---|---|---|
<plan-path> | Yes | Path to DDD plan file |
--phase <N> | No | Execute only phase N (skip earlier completed phases) |
--continue | No | Resume from existing manifest (skip decomposition) |
--dry-run | No | Decompose and plan but do not execute |
The orchestrator supports two execution modes, selected automatically at runtime:
When CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS is not set, tasks within a phase execute sequentially via /spawn. This is the proven, stable execution path.
When CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 is set, independent tasks within a phase execute concurrently via agent teams. The orchestrator becomes the team lead, spawning one teammate per independent task.
Dual state model: The agent teams task list drives coordination (claiming, dependencies, completion), while .impl/manifest.json remains the persistent record. The lead synchronizes between the two.
See ADR-016 for the architectural decision and orchestration-guide.md for detailed documentation.
Check for existing manifest. If --continue and .impl/manifest.json exists, load it and skip to Stage 2. Report: "Resuming from existing manifest."
Verify the plan. Read <plan-path> and confirm status is active.
Extract plan metadata and tasks. Run:
bash scripts/parse-plan.sh --file <plan-path> --metadata
bash scripts/parse-plan.sh --file <plan-path> --tasks
Initialize manifest.
mkdir -p .impl
bash scripts/task-manifest.sh --init \
--plan-path <plan-path> \
--plan-number <number> \
--plan-title "<title>"
Populate all tasks. For each extracted task:
bash scripts/task-manifest.sh --add-task \
--task-id <id> --phase <N> --description "<desc>" \
--depends-on "<deps>" --bounded-contexts "<BCs>"
Report decomposition. Display phase/task summary. If --dry-run, stop here.
For each phase (in numerical order, or just --phase <N> if specified):
Check phase readiness. A phase is ready when all tasks in its dependency phases have status merged or abandoned. Run:
bash scripts/task-manifest.sh --phase-status --phase <dep>
If any dependency phase has non-terminal tasks, wait or report the blocker.
Identify pending tasks in the current phase:
bash scripts/task-manifest.sh --list-tasks --phase <N> --status pending
For each task in the phase:
Update manifest to in_progress.
bash scripts/task-manifest.sh --update-status \
--task-id <id> --status in_progress
Invoke /spawn <task-id>. This forks to the impl-worker agent in an isolated worktree. The agent:
impl/<plan-number>/<task-id>)Parse agent output. Extract:
Update manifest to validating.
bash scripts/task-manifest.sh --update-status \
--task-id <id> --status validating \
--branch <branch-name>
Run validation. Discover the worktree path and run checks:
bash scripts/run-checks.sh --discover --cwd <worktree-path>
bash scripts/run-checks.sh --execute --cwd <worktree-path>
If checks pass:
passed/merge-work <task-id> to merge branch and clean up worktreemergedIf checks fail: Decide based on failure type:
failed, increment retries, re-spawn with failure context appendedabandoned, continue with remaining tasks--continue instructionsDetect agent teams. Check if CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS is set. If not, fall back to sequential mode above.
Populate task list. For each pending task in the current phase, add it to the agent teams task list with dependency information from the manifest.
Spawn teammates. The orchestrator (team lead) spawns one teammate per independent task. Teammates self-claim tasks via the task list's file-lock mechanism.
Each teammate executes. Same as sequential steps 1-6, but running concurrently in separate context windows. The TaskCompleted hook (gate-task-completion.sh) enforces quality checks.
Handle idle teammates. When a teammate finishes and others are still running, reassign to review or cleanup work via TeammateIdle handling.
Synchronize state. As teammates complete tasks, the lead synchronizes the agent teams task list with the .impl/manifest.json. Team task completion triggers manifest updates.
Merge sequentially. After all tasks in the phase complete, the lead merges branches sequentially (same as sequential mode) to avoid complex conflict resolution.
Check phase status. After all tasks in the phase are processed:
bash scripts/task-manifest.sh --phase-status --phase <N>
Report phase results. Display: tasks merged, failed, abandoned.
Advance to next phase. Return to Stage 2 for the next phase.
Final summary. Run:
bash scripts/task-manifest.sh --summary
Report:
Clean up remaining worktrees. For any worktrees still present:
git worktree list
Remove worktrees for merged or abandoned tasks.
--continue after manual resolution.abandoned.--continue to resume from the last known manifest state.scripts/parse-plan.sh — Plan parsing (copy from decompose)scripts/task-manifest.sh — Manifest CRUD (copy from decompose)scripts/run-checks.sh — Check runner (copy from check-impl)templates/claude-task.md — Sub-agent instructions (copy from spawn)npx claudepluginhub alexnodeland/principled --plugin principled-implementationExecutes implementation plans by dispatching tasks to implementer and reviewer subagents. Tracks progress per-task and coordinates sequential phases.
Orchestrates multi-phase implementation from plan documents using sub-agents with auto-detected parallel/sequential strategies based on dependencies.
Executes implementation plans using parallel TDD workers for autonomous task completion. Invoke via /plan-orchestrate or triggers like 'run the plan' after plan-create.