Orchestrate multiple independent subagents concurrently with coordinated collection
Orchestrates multiple independent subagents concurrently with coordinated collection and merging.
/plugin marketplace add cowwoc/claude-code-dog/plugin install dog@claude-code-dogThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Launch and manage multiple independent subagents simultaneously to maximize throughput. Coordinates spawning, monitoring, result collection, and merging for tasks that have no dependencies between them. Essential for efficient use of DOG's multi-agent capabilities.
Analyze task dependencies to find independent work:
# Dependency analysis
tasks:
1.2a-parser-lexer: [] # No dependencies
1.2b-parser-ast: [1.2a] # Depends on 1.2a
1.3a-formatter-core: [] # No dependencies
1.3b-formatter-wrapping: [1.3a] # Depends on 1.3a
1.4-documentation: [] # No dependencies
# Parallelizable groups
parallel_group_1: [1.2a, 1.3a, 1.4] # All independent
# After group 1 completes:
parallel_group_2: [1.2b, 1.3b] # Dependencies satisfied
Use spawn-subagent skill for each independent task:
# Spawn all independent tasks concurrently
for task in "${PARALLEL_TASKS[@]}"; do
UUID=$(uuidgen | cut -c1-8)
BRANCH="${task}-sub-${UUID}"
WORKTREE=".worktrees/${BRANCH}"
# Create worktree
git worktree add -b "${BRANCH}" "${WORKTREE}" HEAD
# Launch subagent (non-blocking)
(
cd "${WORKTREE}"
claude --prompt "Execute PLAN.md for task ${task}"
) &
# Record spawn
echo "${task}:${UUID}:${WORKTREE}" >> active_subagents.txt
done
Use monitor-subagents skill to track all active subagents:
# Monitoring loop
while has_active_subagents; do
for subagent in $(get_active_subagents); do
status=$(check_status "${subagent}")
tokens=$(get_token_usage "${subagent}")
case "${status}" in
"completed")
mark_ready_for_collection "${subagent}"
;;
"warning")
# Approaching context limit
log_warning "${subagent}" "${tokens}"
;;
"failed")
handle_failure "${subagent}"
;;
esac
done
sleep 30 # Poll interval
done
Don't wait for all to complete - collect progressively:
# Event-driven collection
while has_pending_subagents; do
for subagent in $(get_completed_subagents); do
# Use collect-results skill
collect-results "${subagent}"
# Update tracking
mark_collected "${subagent}"
# Check if any dependent tasks can now start
check_unblock_dependents "${subagent}"
done
sleep 10
done
Even for parallel execution, merge order matters:
# Merge strategy for parallel group
merge_order:
# Independent tasks can merge in any order
- 1.2a-parser-lexer # Merge first (1.2b depends on this)
- 1.3a-formatter-core # Merge second (1.3b depends on this)
- 1.4-documentation # Merge third (no dependents)
# Dependent tasks merge after their dependencies
- 1.2b-parser-ast # After 1.2a merged
- 1.3b-formatter-wrapping # After 1.3a merged
# Merge with dependency awareness
for task in "${MERGE_ORDER[@]}"; do
subagent=$(get_subagent_for_task "${task}")
# Verify dependencies are merged
for dep in $(get_dependencies "${task}"); do
verify_merged "${dep}" || error "Dependency ${dep} not yet merged"
done
# Use merge-subagent skill
merge-subagent "${subagent}"
done
Some subagents may fail while others succeed:
failure_handling:
strategy: CONTINUE_ON_FAILURE
on_failure:
- Record failure details
- Collect any partial results
- Continue with successful subagents
- Mark dependent tasks as blocked
- Report failures to orchestrator
recovery_options:
- Retry failed task with fresh subagent
- Decompose failed task into smaller pieces
- Manual intervention for complex failures
handle_failure() {
local subagent="$1"
# Collect partial results if any
collect-results "${subagent}" --partial
# Mark task as failed
update_state "${subagent}" "failed"
# Block dependent tasks
for dependent in $(get_dependents "${subagent}"); do
mark_blocked "${dependent}" "dependency ${subagent} failed"
done
# Log for orchestrator
log_failure "${subagent}" "$(get_error_details "${subagent}")"
}
Track parallel execution progress:
parallel_execution:
id: pe-001
started_at: 2026-01-10T14:00:00Z
parallel_group: 1
tasks:
- task: 1.2a-parser-lexer
subagent: a1b2c3d4
status: completed
collected: true
merged: true
- task: 1.3a-formatter-core
subagent: b2c3d4e5
status: completed
collected: true
merged: false # Pending
- task: 1.4-documentation
subagent: c3d4e5f6
status: running
tokens: 45000
aggregate_metrics:
total_tokens: 145000
elapsed_time: 1.5 hours
tasks_complete: 2
tasks_running: 1
tasks_failed: 0
# Three independent tasks
TASKS=("1.2a-parser-lexer" "1.3a-formatter-core" "1.4-documentation")
# Spawn all
for task in "${TASKS[@]}"; do
spawn-subagent "${task}"
done
# Monitor until all complete
while [ $(count_running) -gt 0 ]; do
monitor-subagents
sleep 30
done
# Collect and merge all
for task in "${TASKS[@]}"; do
collect-results "${task}"
merge-subagent "${task}"
done
execution_plan:
wave_1: # All parallel
- 1.2a-parser-lexer
- 1.3a-formatter-core
- 1.4-documentation
wave_2: # After wave_1, parallel within wave
- 1.2b-parser-ast # Needs 1.2a
- 1.3b-formatter-wrapping # Needs 1.3a
execution:
- spawn wave_1 tasks
- monitor and collect wave_1
- merge wave_1 results
- spawn wave_2 tasks (now unblocked)
- monitor and collect wave_2
- merge wave_2 results
parallel_execution:
tasks:
- 1.2a: completed
- 1.3a: FAILED
- 1.4: completed
failure_recovery:
task: 1.3a-formatter-core
action: decompose_and_retry
new_tasks:
- 1.3a1-formatter-base
- 1.3a2-formatter-indent
execution_continues:
- Merge 1.2a and 1.4
- Spawn 1.3a1 and 1.3a2
- 1.3b blocked until 1.3a1+1.3a2 complete
# ❌ Launching tasks with dependencies
spawn-subagent "1.2a-parser-lexer"
spawn-subagent "1.2b-parser-ast" # Depends on 1.2a!
# ✅ Sequence dependent tasks
spawn-subagent "1.2a-parser-lexer"
wait_for_completion "1.2a"
merge-subagent "1.2a"
spawn-subagent "1.2b-parser-ast" # Now safe
# ❌ Spawning without limit
for task in "${ALL_100_TASKS[@]}"; do
spawn-subagent "${task}" # 100 concurrent subagents!
done
# ✅ Limit concurrent subagents
MAX_CONCURRENT=5
while has_tasks; do
while [ $(count_running) -lt ${MAX_CONCURRENT} ]; do
spawn-subagent "$(next_task)"
done
sleep 30
done
# ❌ All-or-nothing approach
parallel-execute "${TASKS[@]}"
if any_failed; then
rollback_all
abort
fi
# ✅ Progressive handling
for subagent in $(get_completed); do
if is_successful "${subagent}"; then
collect-results "${subagent}"
merge-subagent "${subagent}"
else
handle_failure "${subagent}"
# Continue with others
fi
done
# ❌ Skipping collection
for subagent in $(get_completed); do
merge-subagent "${subagent}" # No metrics!
done
# ✅ Always collect first
for subagent in $(get_completed); do
collect-results "${subagent}"
merge-subagent "${subagent}"
done
# ❌ Leaving worktrees after parallel execution
# ... 5 worktrees orphaned
# ✅ Cleanup in merge step
for subagent in $(get_subagents); do
merge-subagent "${subagent}" # Includes cleanup
done
# Verify cleanup
git worktree list # Should show no -sub- worktrees
dog:spawn-subagent - Launches individual subagentsdog:monitor-subagents - Tracks all active subagentsdog:collect-results - Gathers subagent resultsdog:merge-subagent - Integrates subagent workdog:decompose-task - Creates parallelizable subtasksThis skill should be used when the user asks to "create a hookify rule", "write a hook rule", "configure hookify", "add a hookify rule", or needs guidance on hookify rule syntax and patterns.
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.