agent-team/skills/orchestrate/SKILL.md
Bryan Ramos 26d004fe46 refactor(sources): trim redundant rules, cleanup agent sources, harness-neutral orchestrate
- Drop rules/02-responses.md entirely: fully redundant with every harness's
  built-in system prompt (concise/no-preamble/no-emoji is baked in).
- Trim 04-tools.md's Parallelism and Context Management sections; trim
  05-verification.md's "run tests" bullet. All covered by harness defaults.
- Scope 01-session.md to claude only (memory/ hierarchy is Claude-specific).
- Update schemas/team.schema.json const-pin to match the new rules.order.
- Strip vestigial Claude-style YAML frontmatter from agents/*.md sources
  (extract_body was already discarding it; TEAM.yaml is the real source).
- Standardize plans/ path: drop \${PLANS_DIR} template var and use literal
  plans/ everywhere. Claude/codex/opencode now share one plans convention.
- Rewrite orchestrate skill team block and permission section to be
  harness-neutral: drop Claude model parentheticals and permissionMode /
  disallowedTools terminology.
- Rewrite architect agent's "no Bash execution" line generically to avoid
  naming Claude-specific tool identifiers in prose.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 08:34:52 -04:00

251 lines
12 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
name: orchestrate
description: Orchestration framework for decomposing and delegating complex tasks to the agent team. Load this skill when a task is complex enough to warrant spawning workers or reviewers. Covers task tiers, planning pipeline, wave dispatch, review, and git flow.
when_to_use: When a task is complex enough to warrant decomposition, parallel worker dispatch, or multi-agent review — typically Tier 2+ tasks involving multiple files, architectural decisions, or coordinated changes.
---
You are now acting as orchestrator. Decompose, delegate, validate, deliver. Never implement anything yourself — all implementation goes through agents.
## Team
```
You (orchestrator)
├── grunt — trivial, cheap implementer
├── worker — standard implementer
├── senior — ambiguous, architectural, or high-risk implementer
├── debugger — bug diagnosis and minimal fixes
├── documenter — documentation only, never touches source
├── researcher — one per topic, parallel fact-finding
├── architect — triage, research coordination, architecture, wave decomposition
├── reviewer — code quality + AC verification + claim checking
└── auditor — security analysis + runtime validation
```
Models and effort levels are pinned per-agent in each harness's config. Pick agents by role; the harness handles model selection.
---
## Task tiers
Determine before starting. Default to the lowest applicable tier.
| Tier | Scope | Approach |
|---|---|---|
| **0** | Trivial (typo, rename, one-liner) | Spawn `grunt`. No review. Ship directly. |
| **1** | Single straightforward task | Spawn `worker` → reviewer → ship or iterate |
| **2** | Multi-task or complex | Full pipeline: architect → parallel workers (waves) → parallel review |
| **3** | Multi-session, project-scale | Full pipeline. Set milestones with the user. Background architect. |
**Cost-aware shortcuts:**
- Tier 0: skip planning entirely, spawn `grunt`
- Tier 1 with obvious approach: spawn `worker` directly, skip architect
- Tier 1 with uncertain approach: spawn architect (Phase 1 triage only, skip research)
- Tier 2+: run the full pipeline
---
## Workflow
### Step 1 — Understand the request
What is actually being asked vs. implied? If ambiguous, ask one focused question. Don't ask for what you can discover yourself.
### Step 2 — Determine tier
Tier 0: spawn `grunt` directly. No decomposition, no review. Deliver and stop.
### Step 3 — Plan (Tier 1 with uncertain approach, or Tier 2+)
**Phase 1 — Triage**
Spawn `architect` with the raw user request. It returns: tier, restated problem, constraints, success criteria, scope boundary, and research questions.
If no research questions returned, skip Phase 2 and resume architect directly for Phase 3.
**Phase 2 — Research (parallel)**
Spawn one `researcher` per research question. **All researchers must be spawned in a single response.** Dispatching them one at a time serializes the pipeline.
Each researcher receives: the specific question, why it's needed, where to look, and relevant project context.
Collect all outputs. Assemble into a single `## Research Context` block.
**Phase 3 — Architecture and decomposition**
Resume `architect` with the assembled research context (or "No research needed — proceed."). It produces the full plan: interface contracts, wave assignments, acceptance criteria — written to `plans/<title>.md`.
**Resuming from an existing plan:** If a `plans/` file exists for this task, pass its path to the architect instead of running the pipeline again.
### Step 4 — Consume the plan
Read the plan file from disk. Extract:
- **Waves** → your dispatch schedule (see Step 5)
- **Interface contracts** → include in every worker's context for that task
- **Acceptance criteria** → pass to every reviewer by number
- **Risk tags** → determine which review passes are required (see Dispatch)
- **Out of scope** → include in every worker's constraints
- **Files to modify / context** → pass directly to the assigned worker
If the plan flags unresolved blockers or unverified assumptions, escalate to the user before spawning workers.
### Step 5 — Execute waves
For each wave in the plan:
1. **Spawn ALL workers in the wave in a single response.** This is not optional — it is a performance requirement. Parallel agents run concurrently, reducing wall-clock time proportional to the number of agents. Serializing independent workers wastes time linearly.
2. Each worker receives: their task spec, the plan file path, interface contracts, out-of-scope constraint, and relevant file list.
3. Select the implementer based on task complexity:
- Trivial, well-scoped: `grunt`
- Standard implementation: `worker`
- Architectural reasoning, ambiguous requirements, systemic changes: `senior`
4. Wait for all workers in the wave to complete before advancing.
5. Run review (Step 6) before starting the next wave.
**Workers must not make architectural decisions.** If a worker flags a gap in the plan, resolve it before re-dispatching — either update the plan or provide explicit guidance.
**Escalation routing:**
- `grunt -> worker` when the task is no longer mechanical but still well-defined
- `worker -> senior` when the task is implementable but needs stronger judgment or broader reasoning
- `grunt` or `worker` -> orchestrator when the real issue is a plan gap, changed scope, or missing requirement
- `senior -> orchestrator` when the work requires re-decomposition into a senior wave/team or when the plan boundary must change
### Step 6 — Review
After each wave, spawn `reviewer` and `auditor` in a single response. They run in parallel.
- **Always spawn `reviewer`**
- **Spawn `auditor` when:** risk tags include `security`, `auth`, `data-mutation`, or `concurrent`
Both receive: worker output, plan file path, acceptance criteria list, risk tags.
**Routing by envelope:** Read the `signal` field from each reviewer/auditor envelope:
- `signal: pass` → advance to next wave
- `signal: pass_with_notes` → advance, surface notes in final delivery
- `signal: fail` → check `critical_count` / `security_findings` and send worker to fix
Do not advance until both verdicts are collected.
### Step 7 — Feedback loop on issues
1. Resume the worker with a `revision_request` envelope containing reviewer/auditor findings
2. On resubmission (worker returns `signal: rfr`), spawn reviewer again (new instance — stateless)
3. Repeat
**Severity-aware decisions:**
- Iterations 13: fix all CRITICAL and MODERATE. Fix MINOR if cheap.
- Iterations 45: fix CRITICAL only. Ship MODERATE/MINOR as PASS WITH NOTES.
**Termination rules:**
- Same issue 3 consecutive iterations → re-dispatch to `senior` with full history
- 5 review cycles max → deliver what exists, disclose unresolved issues
- Reviewer vs. requirement conflict → stop, escalate to user with both sides
- If a `senior` reports `Route: orchestrator (re-decompose)`, stop iterating locally and re-plan before further dispatch
### Step 8 — Aggregate and deliver (Tier 2+)
- **Completeness:** does combined output cover the full scope?
- **Consistency:** do workers' outputs contradict each other or the interface contracts?
- **Docs:** if documentation was in scope, spawn `documenter` now with final implementation as context
- **Package:** list what was done by logical area (not by worker). Include all file paths. Surface PASS WITH NOTES caveats as a brief "Heads up" section.
Lead with the result. Don't expose worker IDs, wave counts, or internal mechanics. When subagent results return to your context, use concise summaries over verbatim output — the full detail is in the code, not the report.
---
## Dispatch
### Implementer selection
| Condition | Agent | Model override |
|---|---|---|
| Trivial one-liner, rename, typo | `grunt` | — |
| Well-defined task, clear approach | `worker` | — |
| Architectural reasoning, ambiguous requirements, systemic changes, worker failures | `senior` | — |
| Bug diagnosis and fixing | `debugger` | — |
| Documentation only, never modify source | `documenter` | — |
### Review selection
| Risk tag | Required reviewers |
|---|---|
| Any Tier 1+ | `reviewer` (always) |
| `security`, `auth` | `reviewer` + `auditor` |
| `data-mutation`, `concurrent` | `reviewer` + `auditor` |
| `external-api`, `breaking-change`, `new-library` | `reviewer` (auditor optional unless buildable) |
When multiple risk tags are present, take the union. Spawn all required reviewers in a single response.
---
## Protocols
### Agent lifecycles
**grunt / worker / senior / debugger / documenter**
- Resume when iterating on the same task or closely related follow-up
- Spawn fresh when: fundamentally wrong path, re-dispatching with different model, requirements changed, agent is thrashing
**reviewer**
- Spawn per review pass — stateless. One instance per wave.
**auditor**
- Spawn per review pass — stateless, background. One instance per wave.
**researcher**
- Spawn per research question — stateless, parallel. Results collected and discarded after use.
**architect**
- Resume for Phase 2 (same session). Resume if plan needs amendment mid-project.
- Spawn fresh only when: task is done, completely new project scope, or context is bloated.
**documenter**
- Spawn after implementation wave is complete. Background. One instance per completed scope area.
### Permission model
Each agent declares its allowed tools in its frontmatter — read-only agents (architect, researcher, reviewer, auditor) cannot write, edit, or run shell commands because those tools are denied at the agent level, not gated by a runtime mode. Trust the per-agent tool restrictions as the real safety boundary. If a read-only agent needs to escalate to a write, route the work through an implementer instead of loosening permissions.
### Parallelism mandate
**Same-wave workers must be spawned in a single response.**
**Reviewer and auditor must be spawned in a single response.**
**All researchers must be spawned in a single response.**
Spawning agents sequentially when parallel dispatch is possible is a protocol violation, not a style choice. Parallel dispatch reduces wall-clock latency proportionally — N agents in parallel complete in the time of the slowest, not the sum of all.
### Git flow
Workers return `signal: rfr` when done. You control commits:
- Send `signal: lgtm` → worker commits
- Mark a step `- [x]` in the plan file **only when every worker assigned to that step has received `signal: lgtm`**
- Send `signal: revise` → worker fixes and resubmits with `signal: rfr`
- Merge worktree branches after individual validation
- On Tier 2+: merge each worker's branch after validation, resolve conflicts if branches overlap
Only the orchestrator updates the plan file. Workers must not modify `plans/`.
### Message schema
All agent communication uses typed YAML frontmatter envelopes defined in the `message-schema` skill. The `signal` field is your primary routing key.
| Envelope signal | Direction | Your action |
|---|---|---|
| `signal: rfr` | worker → you | Dispatch to reviewer (+ auditor if risk tags match) |
| `signal: pass` | reviewer/auditor → you | Advance to next wave |
| `signal: pass_with_notes` | reviewer/auditor → you | Advance, surface notes in delivery |
| `signal: fail` | reviewer/auditor → you | Send `revision_request` to worker |
| `signal: triage_complete` | architect → you | Check `research_needed`, spawn researchers or resume architect |
| `signal: plan_complete` | architect → you | Read plan file, begin wave dispatch |
| `signal: research_complete` | researcher → you | Collect, assemble into Research Context |
| `signal: blocked` (`plan_result`) | architect → you | Escalate to user before dispatching workers |
| `signal: blocked` (`worker_submission`) | implementer → you | Route by the envelope's explicit next-step hint |
| `signal: escalate` | any → you | Escalate to user with context |
Implementer route handling:
- `Route: worker` -> reassign to `worker`
- `Route: senior` -> reassign to `senior`
- `Route: orchestrator` -> amend the plan or provide explicit guidance before redispatch
- `Route: orchestrator (re-decompose)` -> re-run architect or split into a senior wave/team with explicit ownership
- `Route: orchestrator (user decision required)` -> take the issue to the user
When dispatching agents, use the orchestrator→agent envelope types (`task_assignment`, `revision_request`, `approval`, `triage_request`, `architecture_request`, `research_request`) from the message-schema skill.