Team Skill - Reactive Wave Orchestration
Use reactive team orchestration where waves emerge from task completions, not predefined schedules.
The Pattern
User: "extract all code, go through iterations until done"
│
▼
[TEAM LEAD]
│
├── Analyze task → Create all tasks with dependencies
│
├── Spawn workers for ALL initially unblocked tasks (Wave 1)
│
├── MONITOR LOOP (until all tasks done)
│ ├── receive_messages → check for completions
│ ├── task_list → check which tasks are now unblocked
│ └── For each newly unblocked task:
│ └── Spawn worker for that task
│
└── When all tasks complete → Shutdown workers
How It Works
- Create all tasks upfront with
blockedBydependencies - Spawn workers for all tasks that have no blockers
- Monitor - poll for completions and newly unblocked tasks
- React - spawn workers for newly unblocked tasks
- Repeat until all tasks complete
This means you tell the lead: "Keep iterating until X is done" and it will keep spawning workers as tasks become available.
Example: Document Codebase
User: "document all code, keep working until TYPELESS-FEATURE-MAP.md is complete"
│
▼
Lead: Create tasks with dependencies:
- Task 1 (beautifier): no blockers
- Task 2 (renderer): blocked by 1
- Task 3 (main-doc): no blockers
- Task 4 (koffi-doc): no blockers
- Task 5 (native-doc): no blockers
- Task 6 (feature-doc): blocked by 2,3,4,5
Lead: Spawn workers for initially unblocked (1,3,4,5)
MONITOR LOOP:
├─ Beautifier completes → Task 2 unblocked → Spawn worker for Task 2
├─ Main-doc completes → (no new unblocked)
├─ Koffi-doc completes → (no new unblocked)
├─ Native-doc completes → (no new unblocked)
├─ Renderer-doc completes → Task 6 unblocked → Spawn worker for Task 6
└─ Feature-doc completes → ALL DONE → Shutdown
Result: TYPELESS-FEATURE-MAP.md is complete!
Execution Steps
Step 1: Create Team
team_create({ "teamName": "doc-team" })
Step 2: Create ALL Tasks with Dependencies
// No blockers - will spawn immediately
task_create({ "teamName": "doc-team", "subject": "Beautify JS", "description": "..." })
// Blocked by beautifier
task_create({ "teamName": "doc-team", "subject": "Renderer analysis", "description": "...", "blockedBy": ["beautifier-task-id"] })
// No blockers
task_create({ "teamName": "doc-team", "subject": "IPC handlers", "description": "..." })
// Blocked by multiple
task_create({ "teamName": "doc-team", "subject": "Feature map", "description": "...", "blockedBy": ["renderer-id", "main-doc-id", ...] })
Step 3: Spawn Initial Workers (All Unblocked Tasks)
// For each unblocked task, spawn a worker
task_list({ "teamName": "doc-team", "status": "pending" })
// Then spawn workers for those tasks
team_spawn_worker({ "teamName": "doc-team", "workerName": "beautifier", "agentType": "executor", "taskId": "task-1-id" })
team_spawn_worker({ "teamName": "doc-team", "workerName": "main-doc", "agentType": "executor", "taskId": "task-3-id" })
// etc.
Step 4: Monitor Loop
The lead monitors and reacts:
// Check for completions
receive_messages({ "teamName": "doc-team", "recipient": "team-lead", "clear": false })
// Check which tasks are now unblocked and pending
task_list({ "teamName": "doc-team", "status": "pending" })
// Spawn worker for newly unblocked task
team_spawn_worker({ "teamName": "doc-team", "workerName": "renderer-doc", "agentType": "executor", "taskId": "task-2-id" })
Step 5: Continue Until Done
// Check completion
task_list({ "teamName": "doc-team", "status": "completed" })
// If all done: shutdown
// If more pending: go to step 4
Monitoring Commands
| Check | Command |
|---|---|
| Pending tasks (available to spawn) | task_list({ "teamName": "x", "status": "pending" }) |
| In progress tasks | task_list({ "teamName": "x", "status": "in_progress" }) |
| Completed tasks | task_list({ "teamName": "x", "status": "completed" }) |
| Worker messages | receive_messages({ "teamName": "x", "recipient": "team-lead" }) |
| Full status | team_status({ "teamName": "x" }) |
Progress Report Format
## Team Progress
**Completed:**
- Task 1 (beautifier) - Done
- Task 3 (main-doc) - Done
**In Progress:**
- Task 4 (koffi-doc) - worker-2 working
**Unblocked (spawn now):**
- Task 2 (renderer) - ready to spawn
**Blocked (waiting):**
- Task 6 (feature-doc) - blocked by 2,3,4,5
**Next Action:** Spawn worker for Task 2
Key Insight: Reactive vs Predefined
| Approach | How it works |
|---|---|
| Predefined waves | You decide waves upfront, spawn in batches |
| Reactive (this skill) | You create all tasks, lead spawns workers as tasks become unblocked |
The reactive approach is better when:
- User says "keep iterating until done"
- Dependencies are complex
- You don't know exactly how many iterations
Example User Prompt
"Use team orchestration to document this codebase. Create tasks for:
1. Beautify all JS bundles
2. Document renderer architecture (after beautifier)
3. Document main process IPC handlers
4. Analyze Koffi FFI bindings
5. Analyze native modules and preload
6. Write TYPELESS-FEATURE-MAP.md (after all above)
Spawn workers, monitor completions, and keep spawning newly unblocked tasks until Task 6 is complete."
Complete Workflow
// 1. Create team
team_create({ "teamName": "doc-team" })
// 2. Create ALL tasks with dependencies
task_create({ "teamName": "doc-team", "subject": "Beautify", "description": "..." })
task_create({ "teamName": "doc-team", "subject": "Renderer", "description": "...", "blockedBy": ["beautifier-id"] })
// ... more tasks
// 3. Spawn workers for unblocked tasks
// Check task_list for pending tasks, spawn workers for each
// 4. MONITOR LOOP (execute repeatedly):
// - receive_messages to check completions
// - task_list to find newly unblocked tasks
// - team_spawn_worker for each newly unblocked task
// - When all completed, shutdown and report
// 5. Shutdown when done
team_delete({ "teamName": "doc-team" })