swarm

swarm is a skill for Claude Code, Codex from apple-ouyang/book-to-skill. It costs 90 tokens per session (1,495 once invoked), scanned A, original, MIT.

A workflow for creating a team of AI agents to work on a software task. It analyzes the work, chooses a collaboration pattern, assigns roles and permissions, and coordinates the agents after confirmation.

In plain words
What is it for?
Use it to organize agents for feature development, code audits, bug investigations, technical research, or large refactors and migrations.
Why use it?
It helps divide complex work into clear parallel or sequential responsibilities while reducing file conflicts and unclear ownership.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: names the AskUserQuestion tool.

Good fit Use it to organize agents for feature development, code audits, bug investigations, technical research, or large refactors and migrations.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/apple-ouyang/book-to-skill/swarm
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add apple-ouyang/book-to-skill --skill swarm
Clone the repo
git clone --depth 1 https://github.com/apple-ouyang/book-to-skill

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for swarm

README.md
[![agentmods](https://agentmods.dev/badge/skills/apple-ouyang/book-to-skill/swarm/github.svg)](https://agentmods.dev/skills/apple-ouyang/book-to-skill/swarm)
Your own site
<a href="https://agentmods.dev/skills/apple-ouyang/book-to-skill/swarm"><img src="https://agentmods.dev/badge/skills/apple-ouyang/book-to-skill/swarm/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for swarm

Your own site · 80×15
<a href="https://agentmods.dev/skills/apple-ouyang/book-to-skill/swarm"><img src="https://agentmods.dev/badge/skills/apple-ouyang/book-to-skill/swarm.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 90 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,495 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00090 $0.01495
Opus 5 $0.00045 $0.00747
Sonnet 5 $0.00018 $0.00299
Haiku 4.5 $0.00009 $0.00150

Measured 10d ago against content hash ea1dfe82b58d, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

swarm scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/swarm/SKILL.md · 194 lines

How it starts

The opening of the file, as written. The whole thing — 194 lines — stays where its author put it; the contents beside it link to each section on GitHub.

蜂群 Swarm

分析用户任务,自动规划 Agent 团队结构(角色、数量、提示词),确认后执行团队协作。

核心流程

分析任务 → 选择团队模式 → 设计角色与提示词 → 用户确认 → 创建团队 → 分配任务 → 监控执行

第一步:分析任务

收到用户任务描述后,从以下维度分析:

维度 评估内容
任务类型 功能开发 / 代码审计 / Bug 调试 / 技术选型 / 重构迁移
可并行度 哪些子任务可以同时进行
文件冲突 不同角色是否会修改同一文件
依赖关系 哪些任务必须按顺序执行
复杂度 决定团队规模(2-8 人)

第二步:选择团队模式

根据分析结果,从预定义模式中选择最匹配的模式。详见 references/team-patterns.md

五种基础模式

  1. 功能开发 — 新功能、跨层变更
  2. 代码审计 — PR Review、安全审计
  3. 调试竞争 — Bug 排查、假设验证
  4. 研究辩论 — 技术选型、方案评估
  5. 重构迁移 — 大规模重构、架构迁移

可混合使用或自定义。如果任务不完全匹配任何模式,基于模式原则自行设计。

第三步:设计角色与提示词

为每个 teammate 设计:

  1. 角色名称:简短描述(如 frontend-devsecurity-reviewer
  2. Agent 类型:根据职责选择(详见 references/agent-types.md
  3. 模型:根据任务复杂度选择(opus/sonnet/haiku)
  4. 权限模式:default / plan / bypassPermissions
  5. 提示词:包含角色、职责、文件范围、输出要求、协作规则
  6. 文件范围:明确可操作的目录,避免冲突

提示词结构

角色:{role}
职责:{responsibilities}

工作范围:
- 只修改:{allowed_dirs}
- 不要触碰:{excluded_dirs}

输出要求:
- {output_format}

协作规则:
- 发现跨模块影响时,通过消息通知 {related_teammate}
- 完成后标记任务为 completed

完成标准:
- {completion_criteria}

第四步:展示计划并确认

以结构化格式展示团队计划,等待用户确认:

## 团队计划

**任务**:{task_description}
**模式**:{pattern_name}
**团队规模**:{count} 人

### 角色分配

| # | 角色 | Agent 类型 | 模型 | 职责概要 |
|---|------|-----------|------|---------|
| 1 | {name} | {type} | {model} | {summary} |
| ...

### 任务列表与依赖

| ID | 任务 | 负责人 | 依赖 |
|----|------|--------|------|
| 1 | {task} | {owner} | - |
| 2 | {task} | {owner} | blockedBy: 1 |
| ...

### 文件分工(避免冲突)

| 角色 | 可操作目录 |
|------|-----------|
| {name} | {dirs} |
| ...

确认此计划?(Y/修改建议)

使用 AskUserQuestion 工具让用户确认或提出修改。

第五步:创建团队并执行

用户确认后,按以下顺序执行:

5.1 创建团队

TeamCreate → team_name: "{task-slug}"

5.2 创建任务列表

按计划创建所有任务(TaskCreate),设置依赖关系(TaskUpdate + addBlockedBy)。

5.3 启动 Teammates

对每个角色,使用 Task 工具启动 teammate:

Task → subagent_type: "{agent_type}"
       name: "{role_name}"
       team_name: "{team_name}"
       model: "{model}"
       mode: "{permission_mode}"
       prompt: "{designed_prompt}"

Read the full file on GitHub · 194 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 194 lines · 90 tokens per session scan A ea1dfe82b58d

Subscribe to this mod's changes

swarm is a skill published in the GitHub repository apple-ouyang/book-to-skill (130 stars, last pushed 6mo ago), licensed MIT. It adds 90 tokens to every session and 1,495 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

local-ai-agents

Build local-first AI agents that run entirely on a developer workstation with Microsoft Foundry Local and Qwen function-calling models. Covers Small Language Models (SLMs), the OpenAI-compatible local endpoint, sandboxed local tools, local RAG with Chroma, local MCP servers, hybrid cloud/local routing, and the…

microsoft/ai-agents-for-beginners · 200 tokens

next-cache-components-adoption

Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…

vercel/next.js · 95 tokens

insight-error-page

Write or audit an insight-kind error page for the Next.js dev overlay. Use when creating a new errors/ .mdx page, auditing an existing one, or checking that a page matches the framework fix cards. Covers page structure, title alignment, FixCard cards with Copy prompt button, code snippets, terminology verification…

vercel/next.js · 83 tokens

next-cache-components-optimizer

Drive a Next.js route to instant navigation by setting up an agentic loop, under Cache Components / PPR, on initial load (hard navigation) and client-side navigation (soft navigation). Encode the goal as a failing @next/playwright instant() e2e and work it to green, one verified route at a time; the shipped test then…

vercel/next.js · 170 tokens

next-partial-prefetching-adoption

Turn on Partial Prefetching in a Next.js app and work through the insights it surfaces. Use when the user wants to enable or adopt Partial Prefetching, flip the partialPrefetching flag, opt routes in with export const prefetch = 'partial', audit Link prefetch={true} behavior, preserve existing prefetched UI with…

vercel/next.js · 103 tokens