// Orchestrate multi-phase project implementation using background Claude agents for isolated development, review, and integration.
| name | project-orchestrator |
| description | Orchestrate multi-phase project implementation using background Claude agents for isolated development, review, and integration. |
This skill orchestrates the complete implementation of a project plan by delegating all work to background Claude agents. The orchestrator manages the process but NEVER writes code directly.
Use this skill when:
BANNED:
REQUIRED:
claude --dangerously-skip-permissions -p "..."Every phase gets its own isolated branch:
<current-branch>/<phase-name>No phase advances without passing review:
# Find the project plan
PROJECT_PLAN=$(find docs/specs -name "PROJECT_PLAN.md" -type f | head -1)
# If user provided specific path, use that
# Otherwise find most recent in docs/specs/
# Read the plan
cat "$PROJECT_PLAN"
Parse the "Implementation Roadmap" section:
## Implementation Roadmap
[High-level phases or milestones for implementation]
### Phase 1: [Phase Name]
[Description of what gets built]
### Phase 2: [Phase Name]
[Description of what gets built]
YOU MUST:
Add to PROJECT_PLAN.md:
## Orchestration Status
**Started:** [YYYY-MM-DD HH:MM]
**Orchestrator Branch:** [current branch name]
**Status:** In Progress
### Phase Tracking
| Phase | Branch | Status | Started | Completed | Review Status |
|-------|--------|--------|---------|-----------|---------------|
| Phase 1: [name] | [branch] | โณ Pending | - | - | - |
| Phase 2: [name] | [branch] | โณ Pending | - | - | - |
# Get current branch (this is the integration branch)
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "Orchestrating from branch: $CURRENT_BRANCH"
# Verify no uncommitted changes
if [[ -n $(git status -s) ]]; then
echo "โ Uncommitted changes detected. Commit or stash before orchestrating."
exit 1
fi
# Create directory for orchestration artifacts
ORCH_DIR="docs/specs/$(basename $(dirname $PROJECT_PLAN))/orchestration"
mkdir -p "$ORCH_DIR/logs"
mkdir -p "$ORCH_DIR/reviews"
For each phase in the Implementation Roadmap:
# Get phase name (slugified)
PHASE_NAME="phase-1-foundation" # Example from plan
PHASE_BRANCH="${CURRENT_BRANCH}/${PHASE_NAME}"
# Create and switch to phase branch
git checkout -b "$PHASE_BRANCH"
# Update PROJECT_PLAN.md status
# Mark phase as "๐ In Progress"
Update PROJECT_PLAN.md:
| Phase 1: Foundation | feature/proj/phase-1-foundation | ๐ In Progress | 2025-11-17 14:30 | - | - |
Craft the implementation prompt:
# Create implementation task file
cat > "$ORCH_DIR/logs/phase-1-task.md" <<EOF
# Implementation Task: Phase 1 - Foundation
## Context
You are implementing Phase 1 of the project plan located at:
$PROJECT_PLAN
## Your Branch
You are working in branch: $PHASE_BRANCH
## Phase Requirements
[Copy relevant section from PROJECT_PLAN.md]
## Your Job
1. Read the PROJECT_PLAN.md completely to understand context
2. Implement ONLY what is described in Phase 1
3. Follow all patterns in AGENTS.md and api/tests/AGENTS.md
4. Use test-writer skill for ALL test code
5. Use test-runner skill to validate your work
6. Commit your changes to this branch when complete
7. DO NOT merge or push - just commit locally
## Success Criteria
- All phase 1 requirements implemented
- Tests pass (just test-all-mocked)
- Code follows project patterns
- Changes committed to $PHASE_BRANCH
## Important
- You are in an isolated branch
- Do NOT modify PROJECT_PLAN.md
- Do NOT merge this branch
- Focus ONLY on Phase 1 scope
EOF
# Spawn background agent
echo "๐ Spawning implementation agent for Phase 1..."
claude --dangerously-skip-permissions -p "$(cat $ORCH_DIR/logs/phase-1-task.md)" \
> "$ORCH_DIR/logs/phase-1-implementation.log" 2>&1 &
IMPL_PID=$!
echo "Implementation agent PID: $IMPL_PID"
# Wait for implementation agent to complete
# Max timeout: 30 minutes (1800 seconds)
TIMEOUT=1800
START_TIME=$(date +%s)
while kill -0 $IMPL_PID 2>/dev/null; do
ELAPSED=$(($(date +%s) - START_TIME))
if [ $ELAPSED -gt $TIMEOUT ]; then
echo "โ ๏ธ Implementation agent timeout (30 min)"
kill $IMPL_PID
# Handle timeout - may need user intervention
break
fi
echo "โณ Implementation in progress... ${ELAPSED}s elapsed"
sleep 30 # Check every 30 seconds
done
# Wait for process to fully complete
wait $IMPL_PID
IMPL_EXIT_CODE=$?
echo "โ
Implementation agent completed with exit code: $IMPL_EXIT_CODE"
# Show tail of implementation log
echo "=== Last 50 lines of implementation log ==="
tail -50 "$ORCH_DIR/logs/phase-1-implementation.log"
# Check that agent committed changes
if [[ -z $(git log --oneline ${CURRENT_BRANCH}..${PHASE_BRANCH}) ]]; then
echo "โ No commits found in phase branch"
echo "Implementation agent may have failed"
# Return to orchestrator branch
git checkout "$CURRENT_BRANCH"
exit 1
fi
echo "โ
Implementation commits found:"
git log --oneline ${CURRENT_BRANCH}..${PHASE_BRANCH}
# Create review task
cat > "$ORCH_DIR/logs/phase-1-review-task.md" <<EOF
# Code Review Task: Phase 1 - Foundation
## Your Job
Execute the /review-code command to review the implementation in branch:
$PHASE_BRANCH
## Context
Review the changes against the requirements in:
$PROJECT_PLAN
Focus on Phase 1 requirements only.
## Output Required
Generate a comprehensive review markdown file at:
$ORCH_DIR/reviews/phase-1-review.md
Follow the review checklist format from /review-code.
## Critical
- Mark status as APPROVED, NEEDS_CHANGES, or BLOCKED
- Categorize all issues as CRITICAL, HIGH, MEDIUM, or LOW
- Be thorough but fair
EOF
# Spawn review agent
echo "๐ Spawning review agent for Phase 1..."
claude --dangerously-skip-permissions -p "$(cat $ORCH_DIR/logs/phase-1-review-task.md)" \
> "$ORCH_DIR/logs/phase-1-review.log" 2>&1 &
REVIEW_PID=$!
# Wait for review (similar timeout logic)
wait $REVIEW_PID
echo "โ
Review agent completed"
# Check if review file exists
REVIEW_FILE="$ORCH_DIR/reviews/phase-1-review.md"
if [[ ! -f "$REVIEW_FILE" ]]; then
echo "โ Review file not generated"
exit 1
fi
# Extract review status
REVIEW_STATUS=$(grep "^### Status:" "$REVIEW_FILE" | awk '{print $3}')
echo "Review Status: $REVIEW_STATUS"
# Check for critical/high priority issues
CRITICAL_COUNT=$(grep -c "Priority: CRITICAL" "$REVIEW_FILE" || echo "0")
HIGH_COUNT=$(grep -c "Priority: HIGH" "$REVIEW_FILE" || echo "0")
echo "Critical issues: $CRITICAL_COUNT"
echo "High priority issues: $HIGH_COUNT"
if [[ "$REVIEW_STATUS" == "APPROVED" ]] && [[ $CRITICAL_COUNT -eq 0 ]] && [[ $HIGH_COUNT -eq 0 ]]; then
echo "โ
Review PASSED - proceeding to merge"
REVIEW_PASSED=true
else
echo "โ ๏ธ Review FAILED - spawning fix agent"
REVIEW_PASSED=false
fi
if [[ "$REVIEW_PASSED" == "false" ]]; then
# Spawn fix agent
cat > "$ORCH_DIR/logs/phase-1-fix-task.md" <<EOF
# Fix Task: Address Review Comments for Phase 1
## Your Branch
You are working in: $PHASE_BRANCH
## Review Comments
The code review identified issues that must be fixed.
Review file location: $REVIEW_FILE
## Your Job
1. Read the review comments carefully
2. Address ALL critical and high priority issues
3. Consider medium/low priority suggestions
4. Commit your fixes to $PHASE_BRANCH
5. DO NOT merge
## Success Criteria
- All critical issues resolved
- All high priority issues resolved
- Tests still pass
- Changes committed to branch
EOF
echo "๐ง Spawning fix agent for Phase 1..."
claude --dangerously-skip-permissions -p "$(cat $ORCH_DIR/logs/phase-1-fix-task.md)" \
> "$ORCH_DIR/logs/phase-1-fix.log" 2>&1 &
FIX_PID=$!
wait $FIX_PID
echo "โ
Fix agent completed"
# Re-run review (recursive - go back to Step 4.1)
echo "๐ Re-running review after fixes..."
# Loop back to 4.1
fi
YOU MUST:
# Switch back to orchestrator branch
git checkout "$CURRENT_BRANCH"
# Merge phase branch (should be fast-forward or clean)
echo "๐ Merging phase branch: $PHASE_BRANCH โ $CURRENT_BRANCH"
git merge "$PHASE_BRANCH" --no-ff -m "Merge Phase 1: Foundation
Orchestrated implementation completed successfully.
Review passed with no critical/high issues.
Phase branch: $PHASE_BRANCH
Review: $REVIEW_FILE"
if [[ $? -ne 0 ]]; then
echo "โ Merge conflict detected"
echo "Manual intervention required"
exit 1
fi
echo "โ
Phase branch merged successfully"
| Phase 1: Foundation | feature/proj/phase-1-foundation | โ
Completed | 2025-11-17 14:30 | 2025-11-17 15:45 | โ
Approved |
Add completion notes:
### Phase 1: Foundation - COMPLETED
**Completed:** 2025-11-17 15:45
**Review:** `docs/specs/project-name/orchestration/reviews/phase-1-review.md`
**Implementation Log:** `docs/specs/project-name/orchestration/logs/phase-1-implementation.log`
**Summary:**
- Implemented [list key deliverables]
- All tests passing
- Review approved with 0 critical/high issues
**Commits:**
[git log output from phase branch]
# Optionally delete phase branch after successful merge
# git branch -d "$PHASE_BRANCH"
# Or keep for audit trail
echo "Phase branch preserved for audit: $PHASE_BRANCH"
Loop through remaining phases:
For each subsequent phase:
## Orchestration Status
**Started:** 2025-11-17 14:30
**Completed:** 2025-11-17 18:45
**Orchestrator Branch:** feature/new-project
**Status:** โ
Complete
### Summary
- Total Phases: 3
- Successful: 3
- Failed: 0
- Total Time: 4h 15m
### Deliverables
- All implementation phases completed
- All reviews passed
- All changes merged to integration branch
- Tests passing
- Documentation updated
# Orchestration Report: [Project Name]
## Project
**Plan:** $PROJECT_PLAN
**Integration Branch:** $CURRENT_BRANCH
**Duration:** [start] - [end]
## Phases Completed
### Phase 1: Foundation
- **Status:** โ
Completed
- **Branch:** feature/proj/phase-1-foundation
- **Review:** Approved (0 critical, 0 high)
- **Iterations:** 1 (first pass)
### Phase 2: Integration
- **Status:** โ
Completed
- **Branch:** feature/proj/phase-2-integration
- **Review:** Approved (0 critical, 0 high)
- **Iterations:** 2 (1 fix cycle)
### Phase 3: Polish
- **Status:** โ
Completed
- **Branch:** feature/proj/phase-3-polish
- **Review:** Approved (0 critical, 0 high)
- **Iterations:** 1 (first pass)
## Artifacts
- Implementation logs: `$ORCH_DIR/logs/`
- Review reports: `$ORCH_DIR/reviews/`
- Project plan: `$PROJECT_PLAN` (updated with completion status)
## Next Steps
- [ ] Create PR from integration branch to main
- [ ] Final human review
- [ ] Merge to main when approved
โ
Project orchestration complete!
๐ Project: [Name]
๐ฟ Integration Branch: $CURRENT_BRANCH
๐ Phases: 3/3 completed
โ
All phases implemented
โ
All reviews passed
โ
All tests passing
โ
Documentation updated
๐ Orchestration artifacts: $ORCH_DIR
๐ Updated plan: $PROJECT_PLAN
Next: Review the integration branch and create PR to main
Wrong:
# Orchestrator directly editing files
vim api/src/new_feature.py
Right:
# Orchestrator spawning agent to write code
claude --dangerously-skip-permissions -p "Implement feature X in branch Y"
Wrong:
# Merge immediately after implementation
git merge $PHASE_BRANCH
Right:
# Always review before merge
spawn_review_agent()
wait_for_approval()
then_merge()
Wrong:
# No iteration limit
while review_fails; do
spawn_fix_agent
done
Right:
# Max 5 iterations per phase
for i in {1..5}; do
if review_passes; then break; fi
spawn_fix_agent
done
if ! review_passes; then
escalate_to_user
fi
Wrong:
# Complete phase without updating plan
merge_and_continue
Right:
# Always update PROJECT_PLAN.md
update_plan_with_completion_status
add_summary_and_artifacts
then_merge_and_continue
Cause: Agent takes > 30 minutes Solution:
# Increase timeout for complex phases
TIMEOUT=3600 # 1 hour for complex phases
# Or split phase into smaller sub-phases
Cause: Issues not being fixed properly, or review is too strict Solution:
# After 5 iterations, escalate
if [[ $ITERATION_COUNT -ge 5 ]]; then
echo "โ Review failed after 5 iterations"
echo "Manual intervention required"
exit 1
fi
Cause: Phase branch diverged from integration branch Solution:
# Before each phase, ensure integration branch is up to date
git checkout $CURRENT_BRANCH
git pull
# When creating phase branch, branch from latest
git checkout -b $PHASE_BRANCH
Cause: Agent crashed or failed Solution:
# Check agent log for errors
tail -100 "$ORCH_DIR/logs/phase-1-implementation.log"
# Common issues:
# - Missing dependencies
# - Syntax errors in task prompt
# - Permission issues
You've successfully orchestrated a project when:
claude --dangerously-skip-permissions -p "Implement Phase X according to $PROJECT_PLAN in branch $PHASE_BRANCH. Commit when done." > log.txt 2>&1 &
claude --dangerously-skip-permissions -p "Run /review-code on branch $PHASE_BRANCH. Output to $REVIEW_FILE." > log.txt 2>&1 &
claude --dangerously-skip-permissions -p "Address review comments from $REVIEW_FILE in branch $PHASE_BRANCH. Commit fixes." > log.txt 2>&1 &
PID=$!
while kill -0 $PID 2>/dev/null; do
sleep 30
done
wait $PID