Multi-Agents
Work like a staff team, not a single thread — parallel minds, adversarial review, one verified outcome.
Orchestrates complex tasks through parallel sub-agent collaboration: analyze, spawn, review, and integrate.
Purpose
Decompose complex, high-risk, or multifaceted engineering tasks into focused, non-overlapping sub-agent roles. By executing research and analysis concurrently, enforcing independent adversarial review, and systematically reconciling findings, this skill eliminates blind spots, prevents regression loops, and delivers verified, maintainer-grade outcomes.
When to Use
- Task has multiple independent workstreams (e.g., simultaneous codebase research, bug reproduction, and prior art search)
- High-risk or breaking changes where a second perspective catches subtle security, architecture, or edge-case flaws
- User explicitly requests
multi-agents, orchestrate, parallel agents, sub-agents, or devil's advocate
- Large refactor or cross-cutting feature where a single agent pass risks missing repository conventions
- Validating reasoning, comparing architectural trade-offs, or exploring alternatives before committing
- When delegated to by
contribute for root-cause research and diff review
Keywords: multi-agent, orchestration, parallel, delegate, sub-agent, devil's advocate
Workflow
[1. Task Decomposition] ──> [2. Parallel Dispatch] ──> [3. Adversarial Critique] ──> [4. Synthesis & Dispute] ──> [5. Verification & Report]
1. Task Analysis & Role Selection
Parse requirements, scope boundaries, and acceptance criteria.
Classify workstreams:
- Independent: Can execute concurrently in parallel (e.g., root cause investigation + codebase conventions search).
- Sequential: Depends on prior stage output (e.g., implementation depends on root-cause analysis).
- Adversarial / High-Risk: Demands an independent critique pass (e.g., security, edge cases, maintainer review).
Select the minimal set of roles needed from references/role-catalog.md. Default to the Three-Role Brief:
- Root-Cause Analyst: Isolates the bug mechanism and responsible code lines.
- Codebase & Convention Researcher: Maps target files, idiomatic patterns, and existing tests.
- Devil's Advocate / Maintainer Critic: Held back until diff/plan exists to conduct an adversarial review.
When to scale:
- Trivial / single-file — collapse Analyst + Researcher into one brief; keep a light Critic pass
- Cross-cutting feature — add Documentation Scribe (#8) + QA Specialist (#7)
- Large refactor / migration — add Performance Analyst (#6) + Security Auditor (#5)
- Continuing a PR — swap Analyst for PR State Analyst: what's done, what review feedback remains
Three well-briefed agents beat five thin ones — only add roles the task actually needs.
2. Parallel Orchestration & Dispatch
3. Adversarial Collaboration & Critique
- Never let an implementation proceed without independent challenge.
- When an implementation plan or code diff is produced, dispatch the Devil's Advocate / Maintainer Critic against the concrete diff or artifact.
- Evaluate concrete failure modes: null/undefined states, race conditions, performance bottlenecks, and project style regressions.
4. Synthesis & Dispute Resolution
- Aggregate outputs using the methodology in
references/synthesis-and-dispute.md.
- Resolve contradictions:
- For competing root-cause hypotheses, run an empirical test or inspect the specific lines.
- For architectural disputes, prefer simplicity and adherence to existing project precedents.
- Enforce the Three-Cycle Hard Limit: If the Critic still rejects changes after 3 rounds, halt iteration and present structured decision options to the user.
5. Verification & Structured Reporting
- Execute local build, lint, and test suites to verify the integrated outcome.
- Optional Jev gate (skipped without
JEV_API_KEY): send task + diff +
test results to jev_review, rescore after fixes with previousEvaluation.
The Critic verdict and three-cycle cap still decide. Never send secrets.
Full protocol: contribute Jev gates.
- Produce a clear, concise handoff report:
- (a) What was accomplished: Summary of changes and decisions.
- (b) Sub-agents utilized: Role names and brief outcome from each.
- (c) Verified trade-offs & assumptions: Key architectural calls made.
- (d) Deferred work: Any secondary cleanups noted for future follow-up.
How to Invoke Sub-Agents
Adapt the dispatch call to your environment's native sub-agent tool while keeping the prompt contract and shared context intact:
Task(
subagent_type="general",
description="<Short Role Label>",
prompt="""
ROLE: <Role Name from references/role-catalog.md>
GOAL: <Specific objective>
SHARED CONTEXT:
TASK: <Verbatim task requirements>
SCOPE: <Target directories or files>
CONSTRAINTS: <Language, conventions, performance criteria>
ACCEPTANCE CRITERIA: <Definition of done>
OUTPUT FORMAT: <Follow schema defined in references/role-catalog.md>
"""
)
For complete runtime envelope specifications (OpenCode, Claude Code, Antigravity/Gemini), see references/orchestration-protocol.md.
Instructions
- Default to rigor: Parallelize discovery, hold back judgment until there is a diff, and never ship without a critic.
- Provide complete context up front: Never force sub-agents to guess repository root, conventions, or constraints. Paste the shared context block into every dispatch.
- Maintain role separation: If two agents produce identical work, refine their briefs to eliminate overlap.
- Dispatch in parallel: Independent agents must be dispatched concurrently in a single turn, not sequentially.
- Hold back the critic: The Critic / Reviewer must evaluate a concrete plan or real code diff, never a vague idea.
- Budget tokens effectively: Avoid dumping entire multi-thousand-line files into prompts; pass exact paths and line ranges.
Constraints
- Do NOT dispatch sub-agents with vague, open-ended instructions ("go investigate this repo").
- Do NOT run independent sub-agents sequentially when parallel dispatch is supported.
- Do NOT ignore findings from specialized agents; explicitly address or document trade-offs.
- Do NOT loop past 3 review cycles. Escalate persistent architectural disagreements to the user.
- Do NOT spawn unnecessary roles for trivial single-file edits where a direct pass is faster and lower-risk.
- Do NOT lose rigor if sub-agent tools are unavailable in the host runtime; execute sequential virtual roles per
references/failure-recovery.md.
Examples
Example 1 — Complex Feature with Parallel Exploration
User: "Add CSV export to src/export/ — use multi-agents."
- Decomposition: Identifies independent workstreams (research existing exporters vs. risk/streaming analysis).
- Parallel Dispatch:
- Codebase Researcher: Identifies
src/export/json.ts pattern, notes table-driven tests in export.test.ts.
- Performance & Risk Analyst: Identifies memory limits with large datasets, flags delimiter escaping and UTF-8 BOM.
- Implementation: Implements
csv.ts following json.ts idioms, incorporating streaming and escaping guards.
- Adversarial Review: Maintainer Critic reviews the diff, flags missing documentation in
docs/api.md.
- Synthesis & Handoff: Documentation updated, tests pass, delivered with structured report.
Example 2 — Bug Fix with Devil's Advocate
User: "Fix the auth bypass in src/auth/ — run multi-agents with a devil's advocate."
- Parallel Dispatch:
- Root-Cause Analyst: Reproduces bypass, isolates flaw to missing role check in
auth.ts:42.
- Codebase Researcher: Locates
auth.test.ts fixture suite and project authentication conventions.
- Implementation: Implements targeted guard in
auth.ts:42.
- Devil's Advocate: Challenges the diff: "Does this invalidate active guest sessions? What about cached JWTs?"
- Refinement: Implementer adds regression tests confirming guest sessions and token revocation behavior.
- Handoff: Passes test suite, reports verified assumptions.
Example 3 — Research-Only Fan-Out
User: "Use multi-agents to explore internal/billing/ before refactor."
- Dispatches 3x
general sub-agents in one turn, all with the Shared Context Block:
- (A) file map and responsibilities, (B) API-to-DB data flow, (C) test coverage audit.
- Synthesizes into a briefing doc with
CODEBASE RESEARCH schemas; flags contradiction A vs B via an empirical re-read of the exact lines.
- Critic verdict:
ESCALATE — billing retry path undocumented, recommend spike before refactor.
Example 4 — Single-Agent Virtual Role Fallback
User: "Analyze internal/billing/ before refactoring." (Environment lacks sub-agent spawning tool)
- Follows
references/failure-recovery.md solo fallback protocol.
- Wears Analyst Hat: Maps module dependencies and database interactions.
- Wears Researcher Hat: Audits test coverage and identifies undocumented coupling.
- Wears Critic Hat: Challenges refactoring assumptions and highlights high-risk migration paths.
- Synthesizes findings into an architectural brief.
References
references/role-catalog.md — Comprehensive catalogue of agent role prompts, objectives, and output schemas.
references/orchestration-protocol.md — Parallel dispatch mechanics, shared context blocks, and runtime envelopes.
references/synthesis-and-dispute.md — Reconciliation methodology, conflict resolution matrix, and escalation protocol.
references/failure-recovery.md — Remediation for sub-agent timeouts, hallucinated code, and single-agent virtual role execution.
- Integrates directly with
skills/contribute and skills/code-review.
1---2name: multi-agents3description: Use this skill to orchestrate complex tasks through parallel sub-agent collaboration — delegating research, implementation, and devil's-advocate review to specialized roles. Triggers on multi-agent, orchestration, delegate, complex refactors, and high-risk changes.4---56# Multi-Agents78> Work like a staff team, not a single thread — parallel minds, adversarial review, one verified outcome.910Orchestrates complex tasks through parallel sub-agent collaboration: analyze, spawn, review, and integrate.1112## Purpose1314Decompose complex, high-risk, or multifaceted engineering tasks into focused, non-overlapping sub-agent roles. By executing research and analysis concurrently, enforcing independent adversarial review, and systematically reconciling findings, this skill eliminates blind spots, prevents regression loops, and delivers verified, maintainer-grade outcomes.1516## When to Use1718- Task has multiple independent workstreams (e.g., simultaneous codebase research, bug reproduction, and prior art search)19- High-risk or breaking changes where a second perspective catches subtle security, architecture, or edge-case flaws20- User explicitly requests `multi-agents`, `orchestrate`, `parallel agents`, `sub-agents`, or `devil's advocate`21- Large refactor or cross-cutting feature where a single agent pass risks missing repository conventions22- Validating reasoning, comparing architectural trade-offs, or exploring alternatives before committing23- When delegated to by `contribute` for root-cause research and diff review2425Keywords: `multi-agent`, `orchestration`, `parallel`, `delegate`, `sub-agent`, `devil's advocate`2627## Workflow2829```30[1. Task Decomposition] ──> [2. Parallel Dispatch] ──> [3. Adversarial Critique] ──> [4. Synthesis & Dispute] ──> [5. Verification & Report]31```3233### 1. Task Analysis & Role Selection3435- Parse requirements, scope boundaries, and acceptance criteria.36- Classify workstreams:37 - **Independent**: Can execute concurrently in parallel (e.g., root cause investigation + codebase conventions search).38 - **Sequential**: Depends on prior stage output (e.g., implementation depends on root-cause analysis).39 - **Adversarial / High-Risk**: Demands an independent critique pass (e.g., security, edge cases, maintainer review).40- Select the minimal set of roles needed from [`references/role-catalog.md`](references/role-catalog.md). Default to the **Three-Role Brief**:41 1. **Root-Cause Analyst**: Isolates the bug mechanism and responsible code lines.42 2. **Codebase & Convention Researcher**: Maps target files, idiomatic patterns, and existing tests.43 3. **Devil's Advocate / Maintainer Critic**: Held back until diff/plan exists to conduct an adversarial review.4445 **When to scale:**46 - **Trivial / single-file** — collapse Analyst + Researcher into one brief; keep a light Critic pass47 - **Cross-cutting feature** — add **Documentation Scribe (#8)** + **QA Specialist (#7)**48 - **Large refactor / migration** — add **Performance Analyst (#6)** + **Security Auditor (#5)**49 - **Continuing a PR** — swap Analyst for **PR State Analyst**: what's done, what review feedback remains5051 > Three well-briefed agents beat five thin ones — only add roles the task actually needs.5253### 2. Parallel Orchestration & Dispatch5455- Formulate an immutable **Shared Context Block** per the canonical spec in [`references/orchestration-protocol.md#shared-context-block`](references/orchestration-protocol.md). Minimal fast-path shape:56 ```text57 TASK: <verbatim task requirements>58 SCOPE: <target directories or files>59 CONSTRAINTS: <language, conventions, performance criteria>60 ACCEPTANCE CRITERIA: <definition of done>61 ```62 Do not redefine fields here; that spec is canonical.63- Dispatch independent sub-agents concurrently in a **single turn** using your environment's sub-agent tool (`Task`, `browser_subagent`, etc.).64- Enforce strict role isolation: provide clear objectives and structured output schemas so sub-agents produce actionable outputs without overlapping. The orchestrator implements; sub-agents analyze, research, and critique unless an Implementation Specialist is explicitly dispatched.6566### 3. Adversarial Collaboration & Critique6768- Never let an implementation proceed without independent challenge.69- When an implementation plan or code diff is produced, dispatch the **Devil's Advocate / Maintainer Critic** against the concrete diff or artifact.70- Evaluate concrete failure modes: null/undefined states, race conditions, performance bottlenecks, and project style regressions.7172### 4. Synthesis & Dispute Resolution7374- Aggregate outputs using the methodology in [`references/synthesis-and-dispute.md`](references/synthesis-and-dispute.md).75- Resolve contradictions:76 - For competing root-cause hypotheses, run an empirical test or inspect the specific lines.77 - For architectural disputes, prefer simplicity and adherence to existing project precedents.78- Enforce the **Three-Cycle Hard Limit**: If the Critic still rejects changes after 3 rounds, halt iteration and present structured decision options to the user.7980### 5. Verification & Structured Reporting8182- Execute local build, lint, and test suites to verify the integrated outcome.83- Optional Jev gate (skipped without `JEV_API_KEY`): send task + diff +84 test results to `jev_review`, rescore after fixes with `previousEvaluation`.85 The Critic verdict and three-cycle cap still decide. Never send secrets.86 Full protocol: [`contribute Jev gates`](../contribute/references/jev-decisions.md).87- Produce a clear, concise handoff report:88 - **(a) What was accomplished**: Summary of changes and decisions.89 - **(b) Sub-agents utilized**: Role names and brief outcome from each.90 - **(c) Verified trade-offs & assumptions**: Key architectural calls made.91 - **(d) Deferred work**: Any secondary cleanups noted for future follow-up.9293## How to Invoke Sub-Agents9495Adapt the dispatch call to your environment's native sub-agent tool while keeping the prompt contract and shared context intact:9697```text98Task(99 subagent_type="general",100 description="<Short Role Label>",101 prompt="""102 ROLE: <Role Name from references/role-catalog.md>103 GOAL: <Specific objective>104 105 SHARED CONTEXT:106 TASK: <Verbatim task requirements>107 SCOPE: <Target directories or files>108 CONSTRAINTS: <Language, conventions, performance criteria>109 ACCEPTANCE CRITERIA: <Definition of done>110 111 OUTPUT FORMAT: <Follow schema defined in references/role-catalog.md>112 """113)114```115116For complete runtime envelope specifications (OpenCode, Claude Code, Antigravity/Gemini), see [`references/orchestration-protocol.md`](references/orchestration-protocol.md).117118## Instructions119120- **Default to rigor:** Parallelize discovery, hold back judgment until there is a diff, and never ship without a critic.121- **Provide complete context up front**: Never force sub-agents to guess repository root, conventions, or constraints. Paste the shared context block into every dispatch.122- **Maintain role separation**: If two agents produce identical work, refine their briefs to eliminate overlap.123- **Dispatch in parallel**: Independent agents must be dispatched concurrently in a single turn, not sequentially.124- **Hold back the critic**: The Critic / Reviewer must evaluate a concrete plan or real code diff, never a vague idea.125- **Budget tokens effectively**: Avoid dumping entire multi-thousand-line files into prompts; pass exact paths and line ranges.126127## Constraints128129- Do NOT dispatch sub-agents with vague, open-ended instructions ("go investigate this repo").130- Do NOT run independent sub-agents sequentially when parallel dispatch is supported.131- Do NOT ignore findings from specialized agents; explicitly address or document trade-offs.132- Do NOT loop past 3 review cycles. Escalate persistent architectural disagreements to the user.133- Do NOT spawn unnecessary roles for trivial single-file edits where a direct pass is faster and lower-risk.134- Do NOT lose rigor if sub-agent tools are unavailable in the host runtime; execute sequential virtual roles per [`references/failure-recovery.md`](references/failure-recovery.md).135136## Examples137138### Example 1 — Complex Feature with Parallel Exploration139140> **User**: "Add CSV export to `src/export/` — use multi-agents."1411421. **Decomposition**: Identifies independent workstreams (research existing exporters vs. risk/streaming analysis).1432. **Parallel Dispatch**:144 - *Codebase Researcher*: Identifies `src/export/json.ts` pattern, notes table-driven tests in `export.test.ts`.145 - *Performance & Risk Analyst*: Identifies memory limits with large datasets, flags delimiter escaping and UTF-8 BOM.1463. **Implementation**: Implements `csv.ts` following `json.ts` idioms, incorporating streaming and escaping guards.1474. **Adversarial Review**: Maintainer Critic reviews the diff, flags missing documentation in `docs/api.md`.1485. **Synthesis & Handoff**: Documentation updated, tests pass, delivered with structured report.149150### Example 2 — Bug Fix with Devil's Advocate151152> **User**: "Fix the auth bypass in `src/auth/` — run multi-agents with a devil's advocate."1531541. **Parallel Dispatch**:155 - *Root-Cause Analyst*: Reproduces bypass, isolates flaw to missing role check in `auth.ts:42`.156 - *Codebase Researcher*: Locates `auth.test.ts` fixture suite and project authentication conventions.1572. **Implementation**: Implements targeted guard in `auth.ts:42`.1583. **Devil's Advocate**: Challenges the diff: "Does this invalidate active guest sessions? What about cached JWTs?"1594. **Refinement**: Implementer adds regression tests confirming guest sessions and token revocation behavior.1605. **Handoff**: Passes test suite, reports verified assumptions.161162### Example 3 — Research-Only Fan-Out163164> **User**: "Use multi-agents to explore `internal/billing/` before refactor."1651661. Dispatches 3x `general` sub-agents in one turn, all with the Shared Context Block:167 - (A) file map and responsibilities, (B) API-to-DB data flow, (C) test coverage audit.1682. Synthesizes into a briefing doc with `CODEBASE RESEARCH` schemas; flags contradiction A vs B via an empirical re-read of the exact lines.1693. Critic verdict: `ESCALATE — billing retry path undocumented, recommend spike before refactor.`170171### Example 4 — Single-Agent Virtual Role Fallback172173> **User**: "Analyze `internal/billing/` before refactoring." (Environment lacks sub-agent spawning tool)1741751. Follows [`references/failure-recovery.md`](references/failure-recovery.md) solo fallback protocol.1762. Wears *Analyst Hat*: Maps module dependencies and database interactions.1773. Wears *Researcher Hat*: Audits test coverage and identifies undocumented coupling.1784. Wears *Critic Hat*: Challenges refactoring assumptions and highlights high-risk migration paths.1795. Synthesizes findings into an architectural brief.180181## References182183- [`references/role-catalog.md`](references/role-catalog.md) — Comprehensive catalogue of agent role prompts, objectives, and output schemas.184- [`references/orchestration-protocol.md`](references/orchestration-protocol.md) — Parallel dispatch mechanics, shared context blocks, and runtime envelopes.185- [`references/synthesis-and-dispute.md`](references/synthesis-and-dispute.md) — Reconciliation methodology, conflict resolution matrix, and escalation protocol.186- [`references/failure-recovery.md`](references/failure-recovery.md) — Remediation for sub-agent timeouts, hallucinated code, and single-agent virtual role execution.187- Integrates directly with [`skills/contribute`](../contribute/SKILL.md) and [`skills/code-review`](../code-review/SKILL.md).