---
name: swarm-orchestration
description: >-
  Designs dynamic multi-agent swarms by moving orchestration into a generated script rather than a static, hand-listed fan-out chain — scaling from a handful of parallel agents up to hundreds or thousands of fresh-context sub-agents on demand. Defines the complexity budget (concurrency limits, per-worker timeouts, retry policy, hard cost ceiling), the evidence contract sub-agents must return, and the reducer/evaluator that resolves their output, all fixed before fan-out begins. Use this whenever the user wants to design a multi-agent workflow, build a swarm of parallel agents, scale an orchestration beyond a fixed set of calls, or have an orchestrator write its own fan-out script. Trigger on phrases like "build a swarm," "orchestrate a bunch of agents in parallel," "have the orchestrator generate the fan-out," "scale this to hundreds of workers," "design a multi-agent pipeline," or "how do I fan this out safely." The natural companion to ratchet-loop (single-agent, sequential, metric-driven) and power-law-engineering (why parallel bets beat one deep attempt, and how to defend against cascade failure at scale).
title: swarm-orchestration
canonical_url: https://skilld.dev/gh/mb1810/bergerskills/swarm-orchestration
last_updated: 2026-10-06T00:04:53.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install mb1810/bergerskills/swarm-orchestration`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/swarm-orchestration`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/mb1810/bergerskills/swarm-orchestration) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/swarm-orchestration`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/swarm-orchestration --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/swarm-orchestration --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Swarm Orchestration Skill

## Overview
A static fan-out — the orchestrator hand-listing N agent calls — works fine for a handful of parallel tasks. It stops working the moment the right number of workers is unknown in advance, or needs to scale to hundreds or thousands: nobody hand-writes a thousand agent calls.

This skill moves orchestration up a level of abstraction. Instead of the orchestrator calling agents directly, it writes a **script** (JavaScript or similar) that spawns sub-agents programmatically — with concurrency limits, timeouts, and retries as parameters in that script rather than judgment calls made fresh each time. That script can spawn 3 workers or 1,000 with the same shape of logic. The orchestrator's job shifts from "call agents" to "write and parameterize the program that calls agents."

The core tension this skill manages: parallel workers are how you cover a lot of ground fast, but because they all descend from the same originating prompt, they can fail together instead of independently. A swarm is not automatically safer than a single agent just because it has more workers — it's safer only if it's designed to avoid correlated failure and bounded against runaway cost.

## When to Use
- The right number of parallel workers isn't known in advance, or is large enough that hand-listing each call doesn't scale
- A search, audit, or generation task has enough surface area that many independent attempts beat one deep attempt (see `power-law-engineering`)
- The task can be split into genuinely independent units of work with a well-defined way to combine results afterward
- You want the orchestration logic itself (concurrency, retries, timeouts) to be explicit and reviewable, not implicit in a chain of manual tool calls

## When Not to Use
- A small, fixed number of parallel tasks (2-5) where a static fan-out is simpler and the scripting overhead isn't worth it
- Work with real sequential dependencies between units — a swarm is for independent parallel bets, not a disguised sequential pipeline
- No way to define a reducer/evaluator for the outputs — if you can't say how conflicting worker results get resolved, the swarm will just produce noise faster

## Core Operating Rules

### 1. Dynamic Script, Not Static Fan-Out
The orchestrator writes an actual script that spawns workers programmatically (loops, conditionals, dynamic worker counts) rather than the model manually invoking N agent calls one by one. This is what makes the pattern scale-invariant — the same script shape handles 3 workers or 1,000; only the input list size changes.

### 2. Complexity Budget — Fixed Before Fan-Out, All Four Numbers Stated
Define these explicitly before any worker spawns, not adjusted mid-run:
- **Concurrency limit**: max workers running at once
- **Per-worker timeout**: hard ceiling on how long any one worker can run before being killed and treated as failed
- **Retry policy**: how many retries per worker, and what counts as a retryable vs. terminal failure
- **Hard cost ceiling**: total budget (tokens, dollars, or wall-clock) for the entire swarm — the run stops when this is hit, regardless of how many workers haven't finished

"Reasonable limits" is not a spec. If the user hasn't stated numbers, propose defaults explicitly and state them before proceeding rather than leaving them implicit.

### 3. Evidence Contract for the Synthesizer
Every worker must return output in a fixed, structured shape (a schema), not free-form text. This turns the synthesizer's job into reducing known-shaped evidence rather than parsing N different essays and hoping the important parts survive.
- Define the schema before fan-out: what fields, what format, what a "found nothing" result looks like (never silently omit — an explicit empty result is different from a worker that failed)
- A worker whose output doesn't fit the contract is either retried or marked failed — it does not get silently reinterpreted by the synthesizer

### 4. Reducer/Evaluator Defined Before Fan-Out Begins
Decide, in advance, how the swarm's outputs get combined:
- Majority vote, weighted scoring, adversarial refute-and-kill, or first-past-a-threshold — name the mechanism explicitly
- Defining this after results are already in hand invites picking whichever reducer makes the results look best — the reducer is a commitment made blind to the actual outputs, not a post-hoc fit
- State what happens on a tie or genuine disagreement among workers (escalate to human, run a tie-breaker round, default to the conservative answer) — don't leave this undefined until it happens

### 5. Cascade Defense Against Correlated Error (default ON)
Because every worker descends from the same orchestrating prompt, the default risk is not independent random failure — it's every worker being confidently wrong in the same way, because they all inherited the same flawed premise. Treat this as the primary failure mode to design against, not an edge case:
- Default to **deliberate diversity across workers** — different lenses, different sub-prompts, different angles of attack — rather than N identical clones of one prompt running for raw speed
- If the user wants pure identical-clone parallelism (e.g., simple map over a list of independent items), that's fine — but state explicitly that correlated-error defense doesn't apply here because there's no shared judgment call, only a shared mechanical step
- When the swarm's job involves judgment, synthesis, or verification (not just mechanical parallel lookups), diversity is the guardrail — call it out if a user's plan skips it, the same way `ratchet-loop`'s guardrail defaults on unless explicitly waived

### 6. Output Requirements
Always deliver, in this order:
1. The complexity budget (concurrency, timeout, retries, cost ceiling) — stated as numbers
2. The evidence contract (schema) each worker must return
3. The reducer/evaluator mechanism, including the tie/disagreement rule
4. The diversity strategy across workers, or an explicit statement that pure parallelism is safe here and why
5. After the run: workers spawned vs. budget used, failure/retry counts, and how the reducer resolved disagreement — the audit trail, not just the final synthesized answer

## Worked Example

**Input**: "I want to check 200 vendor contracts for a specific liability clause. Some have it, some don't, some are ambiguous. Build me a swarm for this."

**Setup**:
- Concurrency limit: 15 workers at once; per-worker timeout: 2 minutes; retries: 1 retry on timeout or malformed output, then mark failed; cost ceiling: stop spawning new workers if total spend crosses a stated token budget, finish in-flight workers, then stop
- Evidence contract: each worker returns `{contract_id, clause_found: true/false/ambiguous, quote, confidence}` — no free text allowed outside those fields
- Reducer: no vote needed since each contract is independent (one worker, one contract) — the reducer here is just aggregation: bucket by `clause_found` value, flag every `ambiguous` result for human review rather than guessing
- Diversity: not needed — this is mechanical parallel lookup, not shared judgment, so 200 structurally-identical workers each reading a different contract is correctly safe. Called out explicitly rather than assumed.

**Output at the end**: aggregation of 200 results (kept/failed/retried counts), a bucketed list (has clause / doesn't / ambiguous), and the ambiguous bucket surfaced first since that's where a human needs to look.

## Advanced Techniques
- **Pairing with power-law-engineering**: use that skill's tail-aware metrics to judge the swarm's own performance across runs (p50/p90 worker quality, not just average) rather than treating every worker as equally informative.
- **Pairing with ratchet-loop**: a swarm can generate many candidate changes in parallel, then hand the winner into a ratchet-loop for sequential refinement — swarm explores broadly, loop exploits narrowly.
- **Tiered swarms**: a first cheap, high-concurrency pass to narrow a large space, followed by a second smaller, higher-quality pass (fewer workers, longer per-worker budget) only on what survived — trades one big expensive swarm for two cheaper staged ones.
- **Adversarial reducer**: for judgment-heavy tasks, make the reducer itself a second swarm of skeptics whose job is to refute the first swarm's majority answer — survives only if it holds up against dedicated attack, not just a headcount.

## Quality Checklist (run before fan-out)
- [ ] Concurrency limit, per-worker timeout, retry policy, and hard cost ceiling all stated as numbers
- [ ] Evidence contract (schema) defined, including what an explicit "found nothing" result looks like
- [ ] Reducer/evaluator named before any worker output exists, including the tie/disagreement rule
- [ ] Diversity-across-workers decided explicitly — either applied, or waived with a stated reason (pure mechanical parallelism, no shared judgment call)
- [ ] Cost ceiling behavior defined: what happens to in-flight workers when the ceiling is hit
- [ ] Audit trail (spawned vs. budget, failures/retries, reducer resolution) is part of the deliverable, not just the final answer
