AgentSkillsCN

orchestrator

协调多位并行工作者,共同推进某项功能计划的落地实施。当您需要统筹调度、协调各路工作人员、并行执行多项任务,或落实多轨道并行计划时,此技能将为您提供有力支持。

SKILL.md
--- frontmatter
name: orchestrator
description: Coordinate multiple parallel workers to execute a feature plan. Use when asked to orchestrate, coordinate workers, run parallel tasks, or execute a multi-track plan.

Orchestrator - Multi-Agent Coordination

A specialized orchestration skill for coordinating multiple parallel workers to execute feature plans efficiently.

code
┌─────────────────────────────────────────────────────────────────┐
│                   ORCHESTRATOR PIPELINE                         │
├─────────────────────────────────────────────────────────────────┤
│  Load Plan → Spawn Workers → Monitor → Sync → Verify            │
└─────────────────────────────────────────────────────────────────┘

Pipeline Phases

Phase 1: Load Execution Plan

Goal: Parse and validate the execution plan.

InputOutput
history/<feature>/execution-plan.mdParsed track/bead structure

Steps:

  1. Read execution-plan.md
  2. Validate all tracks have non-overlapping file scopes
  3. Identify dependency graph
  4. Determine initial beads (no dependencies)

Phase 2: Spawn Workers

Goal: Launch parallel sub-agents for each track.

InputOutput
Track definitionsRunning Task agents

Spawning Strategy:

code
For each track with no blocking dependencies:
  1. Prepare worker context (track scope, beads, acceptance criteria)
  2. Spawn Task with worker skill loaded
  3. Track worker status

Worker Assignment Template:

markdown
## Worker Assignment: <Track Name>

### Your Scope
Files you may modify: <file glob patterns>

### Beads to Complete
1. **<Bead Title>**: <description>
   - Acceptance: <criteria>
   - Dependencies: <none or list>

2. **<Bead Title>**: <description>
   ...

### Rules
- Only modify files within your scope
- Complete beads in order respecting dependencies
- Report completion after each bead
- Stop and report if you encounter blockers

Phase 3: Monitor Progress

Goal: Track worker progress and handle blockers.

Monitoring Loop:

code
While beads remain:
  1. Check for completed beads
  2. Unblock dependent beads when prerequisites complete
  3. Handle errors and blockers
  4. Spawn additional workers as tracks become unblocked
  5. Log progress

Status Tracking:

StatusMeaning
⏳ PendingNot yet started, may have dependencies
🔄 In ProgressWorker actively working
✅ CompleteFinished and verified
❌ BlockedWaiting on dependency or error
⚠️ ErrorFailed, needs intervention

Phase 4: Synchronization Points

Goal: Coordinate cross-track integration.

Sync Rules:

  • When tracks need to integrate, pause workers
  • Review changes from all tracks
  • Resolve any conflicts
  • Run integration tests
  • Resume workers

Phase 5: Final Verification

Goal: Ensure all work is complete and correct.

InputOutput
All completed beadsVerification report

Verification Checklist:

markdown
## Verification Report: <Feature Name>

### Track Completion
- [x] Track 1: <name> - All beads complete
- [x] Track 2: <name> - All beads complete
...

### Quality Checks
- [ ] TypeScript: No errors (`tsc -b`)
- [ ] Lint: Clean (`yarn lint`)
- [ ] Tests: Passing (`yarn test`)
- [ ] Build: Successful (`yarn build`)

### Manual Verification
- [ ] <criterion 1>
- [ ] <criterion 2>

### Issues Found
- <issue description and resolution>

Coordination Patterns

Pattern 1: Independent Tracks

code
Track A: ○──○──○
Track B: ○──○──○    (no dependencies, full parallel)
Track C: ○──○──○
  • Spawn all workers simultaneously
  • No coordination needed until final sync

Pattern 2: Sequential Dependencies

code
Track A: ○──○──○
              ↓
Track B:      ○──○──○
  • Track B waits for Track A completion
  • Spawn Track B worker when Track A completes

Pattern 3: Shared Dependency

code
Track A: ○──○─┐
              ├──▶ Integration ──▶ Final
Track B: ○──○─┘
  • Both tracks run in parallel
  • Integration phase waits for both
  • Final phase after integration

Pattern 4: Cross-Track Sync Points

code
Track A: ○──○──┃──○──○
Track B: ○──○──┃──○──○
              sync
  • Pause at sync point
  • Verify integration
  • Resume both tracks

Error Handling

Worker Failure

  1. Log the error with context
  2. Assess if bead can be retried
  3. If retryable, respawn worker with additional context
  4. If not, mark as blocked and continue other tracks
  5. Report blockers at end

Conflict Detection

  1. Check file modification overlap
  2. If overlap detected, pause conflicting workers
  3. Resolve conflict manually
  4. Update file scopes if needed
  5. Resume workers

Dependency Cycle

  1. Detect cycles during plan validation
  2. Break cycles by reordering or merging beads
  3. Update execution plan
  4. Proceed with corrected plan

Best Practices

  1. Maximize Parallelism: Spawn workers as soon as dependencies clear
  2. Minimize Communication: Workers should be self-sufficient within their scope
  3. Verify Continuously: Run checks after each bead, not just at the end
  4. Log Everything: Maintain audit trail of all worker activities
  5. Fail Fast: Stop workers early if fundamental issues detected

Tools to Use

  • Task: Spawn sub-agent workers
  • Read: Check execution plan and worker outputs
  • get_diagnostics: Verify no errors after each phase
  • Bash: Run tests and build commands

Quick Reference

PhaseActionKey Question
LoadParse planIs the plan valid and executable?
SpawnLaunch workersWhich tracks can start now?
MonitorTrack progressAre workers making progress?
SyncCoordinateDo tracks integrate correctly?
VerifyFinal checkIs the feature complete and working?