swarm-scripts
Installation
SKILL.md
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, or ctx_* (context-mode) when your harness has it. |
| One large web fetch | ctx_fetch_and_index (context-mode). |
| 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.