agent-swarm
Install, self-host, deploy, operate, or use agent-swarm. Covers Docker Compose, Kubernetes, configuration, coding agents, the…
Bulk, repeat, fan-out, or data-heavy work: write and run swarm scripts (inline `script-run`, named `script-upsert`, durable `launch-script-run`). Covers the script-vs-tool rubric, the authoring contract (`args` first, `ctx` second), the seed catalog, connections and secrets,
Claude Code
$ npx -y skills add desplega-ai/agent-swarm --skill swarm-scripts --agent claude-code
Codex
$ npx skills add desplega-ai/agent-swarm --skill swarm-scripts -a codex -y
Cursor
$ npx skills add desplega-ai/agent-swarm --skill swarm-scripts -a cursor -y
Gemini CLI
$ npx skills add desplega-ai/agent-swarm --skill swarm-scripts -a gemini-cli -y
GitHub Copilot
$ npx skills add desplega-ai/agent-swarm --skill swarm-scripts -a github-copilot -y
OpenCode
$ npx skills add desplega-ai/agent-swarm --skill swarm-scripts -a opencode -y
Windsurf
$ npx skills add desplega-ai/agent-swarm --skill swarm-scripts -a windsurf -y
name: swarm-scripts description: "Bulk, repeat, fan-out, or data-heavy work: write and run swarm scripts (inline `script-run`, named `script-upsert`, durable `launch-script-run`). Covers the script-vs-tool rubric, the authoring contract (`args` first, `ctx` second), the seed catalog, connections and secrets, files and bash over the agent-fs drive (`ctx.fs`, `ctx.sh`), `db_query`, and exposing a script as an API."
A swarm script is TypeScript that runs out of process with a typed Swarm SDK. Only its return value enters your context. Use one when direct tool calls would repeat, flood your context, or need deterministic processing over many records.
| Situation | Approach | |---|---| | 1 to 9 SDK calls, result fits in context | Direct tool calls. | | 10 or more similar calls, bulk or fan-out | Script. Inline `script-run` for a one-off, a named script for reuse. | | Fetch, parse, and transform heavy data | Script. | | One large web fetch | Script with `ctx.stdlib.fetch`. Return only the part you need. | | A schedule, workflow, or API script that reads or writes drive files | Script with `ctx.fs` and `ctx.sh`. | | Multi-agent fan-out, parallel work, deterministic pipeline | Workflow. See `workflow-iterate`. | | Work that repeats on a clock | Schedule. See `scheduling`. |
Named script only when the logic will run two or more times, by you, another agent, a schedule, or a workflow. A one-off goes inline, so the catalog does not fill with scratch saves.
Reference point: a workflow triage that took about 26 tool calls returns as one result of about 4k tokens in about 13 seconds.
Pick the run mode before you author. A short inline `script-run` is for small lookups only. A job that scans a whole population or may run past the inline cap of about 30 s starts as a durable `launch-script-run` from the start. A single `ctx.step.swarmScript` step has the same cap, so collect in bounded steps: each step takes a cursor, collects one slice in well under 30 s, and returns its rows plus the next cursor. Label each step with its slice (`collect-${page}`) so the journal checkpoints it, then compute from the collected slices in a final step. Restarting a long inline run throws away the work it already did.
The script tools are deferred. Load them with your harness tool search before the first call: `script-search`, `script-run`, `script-upsert`, `script-query-types`, `script-delete`, and for durable runs `launch-script-run`, `get-script-run`, `list-script-runs`.
Run `script-query-types` before non-trivial work. It returns the live `swarm-sdk.d.ts` and stdlib declarations, including generated per-app types.
The swarm ships named scripts at global scope. Each one replaces a multi-step tool chain. `script-search` with a plain-language description finds them. Call one with `script-run` and `name` plus `args`.
| Script | Args | Use | |---|---|---| | `task-context-gathering` | `{ taskId, queries: [...] }` | the task plus a deduplicated multi-query memory recall | | `smart-recall` | `{ queries: [...] }` | multi-query memory recall without the task | | `memory-dedup-check` | `{ text, threshold? }` | near-duplicates before you store a memory | | `delegate` | `{ agentName, task, routingReason, routingNote, parentTaskId? }` | a subtask for an agent by name, returns `{ taskId }` | | `wait-for-task` | `{ taskId }` | waits up to about 25 s for a terminal state, returns `{ done, status, output }`; call again while `done` is false | | `get-child-outputs` | `{ parentTaskId }` | every child with status and output | | `complete-task` | `{ taskId, output }` | finish a task from inside a script | | `report-progress` | `{ taskId, note }` | a progress note from inside a script | | `swarm-overview` | `{}` | agents and task counts | | `schedule-health`, `task-failure-audit`, `boot-triage` | see `heartbeat-runbook` | the lead's heartbeat data gathering |
The entry point takes `args` first and `ctx` second. A one-parameter `function (ctx)` receives `args` at runtime, so every `ctx.*` access throws. This is the most common cause of a failed run.
import type { ScriptContext } from "swarm-sdk";
import * as z from "zod";
export const argsSchema = z.object({ taskId: z.string(), limit: z.number().optional() });
export default async function (args: z.infer<typeof argsSchema>, ctx: ScriptContext) {
const res = await ctx.swarm.task_get({ taskId: args.taskId });
const task = ((res as { data?: unknown }).data ?? res) as { title?: string };
return { title: task?.title };
}Install, self-host, deploy, operate, or use agent-swarm. Covers Docker Compose, Kubernetes, configuration, coding agents, the…
Rebuild the feel of a reference motion-design clip (camera, depth of field, easing, captions, outro) as an on-brand agent-swarm…
Reverse-engineer a short motion-design / product-update video (animation technique, timing and easing, composition, transitions,…
Make a design-led motion-graphics video (showreel, eval comparison, feature or bug-hunt story) from one open prompt. Claude Opus…
How to generate repo-committed video content (README hero videos, case-study clips, landing demos) with Remotion. Covers project…
Read the task-digest extension's output. Use when someone asks how many tasks completed or failed recently, or which agents did…
Use your assigned AgentMail inbox to read email tasks, explicitly send or reply, and check delivery. Provided automatically by…
Create a new Architecture Decision Record with sequential numbering and AgentDB registration