Skip to content
Agent Orchestration
Skill

/swarm-scripts

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,

From plugin
agent-swarm
1.1k17 skills5 agents11 commands

Claude Code

$ npx -y skills add desplega-ai/agent-swarm --skill swarm-scripts --agent claude-code

SKILL.md

swarm-scripts.SKILL.md
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."

Swarm Scripts

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.

When to script

| 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.

Loading the tools

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.

Seed catalog

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 |

Authoring contract

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 };
}
  • `args` can be `undefined` when a caller passes none. Guard with `argsSchema.safeParse(args ?? {})` or optional chaining.
  • Export a Zod `argsSchema` from every named script. `script-upsert` converts it to JSON Schema, so callers, schedules, and workflows see the input contract.
  • Both `zod` and `zod/mini` imports work. Use `import * as z from "zod/mini"` for smaller QuickJS bundles. Mini uses functional forms: `z.optional(z.string())`, `z._default(z.number(), 10)`, and `z.string().check(z.minLength(1))`; its schemas still have `.parse()` and `.safeParse()`.
  • Inline source through `script-run` runs without a typecheck. `script-upsert` typechecks before it saves. Import `ScriptContext` from `"swarm-sdk"` in inline code too, so promotion to a named script works. A worker's `script-upsert` saves at agent scope; a global-scope upsert is rejected unless you are the lead. To share a script, send the lead its name and `contentHash` to promote. When an acceptance check needs a lead-only tool, a worker cannot pass it: the worker proves the checks it can run and names the lead-gated ones in that handoff, and the lead verifies those before promotion.
  • SDK methods return `Promise<unknown>`. Responses are usually wrapped: read `res?.data ?? res`. Exception: `app_query` with a literal `appId` and `query` returns rows typed from the app's columns.
  • To fail a
Read more
@desplega-ai
Ships withagent-swarm

Your Company Agentic Operating System

1.1k17 skills5 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
1.1k
Star history of desplega-ai/agent-swarm on GitHub, a chart by star-history.com

Other skills on agent-swarm.

agent-swarm

agent-swarm

Install, self-host, deploy, operate, or use agent-swarm. Covers Docker Compose, Kubernetes, configuration, coding agents, the…

video-generation

video-generation

How to generate repo-committed video content (README hero videos, case-study clips, landing demos) with Remotion. Covers project…

task-digest-guide

task-digest-guide

Read the task-digest extension's output. Use when someone asks how many tasks completed or failed recently, or which agents did…

More skills from other plugins.

1password

1password

Set up and use 1Password CLI for sign-in, desktop integration, and reading or injecting secrets.

openclaw7d395k
@steipete@steipeteInstall Skill
jira-tickets

jira-tickets

Read and update Jira tickets through Orca's saved Jira connections. Use when a task comes from Jira or the user asks for Jira…

orca5d128k
@stablyai@stablyaiInstall Skill
agentmail

agentmail

Use your assigned AgentMail inbox to read email tasks, explicitly send or reply, and check delivery. Provided automatically by…

paperclip6d114k
@paperclipai@paperclipaiInstall Skill
adr-create

adr-create

Create a new Architecture Decision Record with sequential numbering and AgentDB registration

@ruvnet@ruvnetInstall Skill

Questions about swarm-scripts.

Which coding agents can use swarm-scripts?
swarm-scripts installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.