Agent Swarm Workflow — Parallel Implementation
Core Insight: Every agent is fungible and a generalist. They all use the same base model and read the same AGENTS.md. Simply telling one it's a "frontend agent" doesn't make it better at frontend.
The swarm is distributed, robust, and self-organizing through Agent Mail and Beads.
Prerequisites
Before starting a swarm:
- 1. Comprehensive plan created (see
planning-workflow skill) - Polished beads ready (see
beads-workflow skill) - AGENTS.md configured with all tool blurbs
- Agent Mail server running (
am or ~/projects/mcp_agent_mail/scripts/run_server_with_token.sh) - NTM available for session management
The Swarm Architecture
CODEBLOCK0
Starting the Swarm
Using NTM (Named Tmux Manager)
CODEBLOCK1
Manual Setup
Create tmux sessions/panes for each agent in your project folder.
THE EXACT PROMPT — Initial Agent Marching Orders
Give each agent this EXACT prompt to start:
CODEBLOCK2
The Implementation Loop
THE EXACT PROMPT — Move to Next Bead
Once agents complete a bead, use this prompt to keep them moving:
CODEBLOCK3
THE EXACT PROMPT — Self-Review After Bead Completion
Have agents review their work before moving on:
CODEBLOCK4
Keep running this until they stop finding bugs.
Handling Context Compaction
THE EXACT PROMPT — Post-Compaction
When an agent does a compaction, immediately follow up with:
CODEBLOCK5
This re-establishes the critical context about tools and workflows.
Quality Review Prompts
THE EXACT PROMPT — Cross-Agent Review
Periodically have agents review each other's work:
CODEBLOCK6
THE EXACT PROMPT — Random Code Exploration
For deep quality checks:
CODEBLOCK7
Committing Work
THE EXACT PROMPT — Commit Changes
Have agents commit logically grouped changes:
CODEBLOCK8
Post-Bead Completion Prompts
THE EXACT PROMPT — Add Test Coverage
CODEBLOCK9
THE EXACT PROMPT — UI/UX Scrutiny
CODEBLOCK10
THE EXACT PROMPT — Deep UI/UX Enhancement
CODEBLOCK11
Agent Mail Integration
How Agents Coordinate
Each agent:
- 1. Registers with Agent Mail at session start
- Reserves files before editing (
file_reservation_paths) - Announces work via messages with bead ID in INLINECODE5
- Checks inbox between tasks
- Releases reservations when done
File Reservation Pattern
CODEBLOCK12
Communication Pattern
CODEBLOCK13
Using BV for Task Selection
Key Commands
CODEBLOCK14
CRITICAL: Never run bare bv — it launches interactive TUI that blocks the session.
Quality Loops
Run Until Clean
Keep running these prompts in rounds until they consistently come back with no changes:
- 1. Self-review — Agent reviews own code
- Cross-review — Agent reviews other agents' code
- Random exploration — Deep dive into random code paths
The Steady-State Signal
When all three types of reviews return clean (no bugs found, no changes made), the code is likely solid.
Complete Prompt Reference
Initial Marching Orders
CODEBLOCK15
Move to Next Bead
CODEBLOCK16
Self-Review
CODEBLOCK17
Cross-Review
CODEBLOCK18
Random Exploration
CODEBLOCK19
Post-Compaction
CODEBLOCK20
Commit Changes
CODEBLOCK21
Test Coverage
CODEBLOCK22
UI/UX Scrutiny
CODEBLOCK23
Deep UI/UX Enhancement
I still think there are strong opportunities to enhance the UI/UX look and feel and to make everything work better and be more intuitive, user-friendly, visually appealing, polished, slick, and world class in terms of following UI/UX best practices like those used by Stripe, don't you agree? And I want you to carefully consider desktop UI/UX and mobile UI/UX separately while doing this and hyper-optimize for both separately to play to the specifics of each modality. I'm looking for true world-class visual appeal, polish, slickness, etc. that makes people gasp at how stunning and perfect it is in every way. Use ultrathink.
The Flywheel in Action
CODEBLOCK25
Each cycle improves:
- - CASS remembers solutions
- CM distills patterns
- UBS catches more issues
- BV shows graph health
FAQ
Q: How do agents know what to work on?
A: They use bv --robot-triage or bv --robot-next to find the highest-impact ready bead.
Q: How do they avoid conflicts?
A: File reservations in Agent Mail. Exclusive reservations block others; the pre-commit guard enforces it.
Q: What if an agent crashes or forgets?
A: Every agent is fungible. Start a new session, read AGENTS.md, check bead status, continue.
Q: How many agents should I run?
A: Depends on project complexity. Start with 3-6. More agents = faster but more coordination overhead.
Q: What model mix works best?
A: Mix recommended. Try 3 Claude Code (Opus), 2 Codex (GPT 5.2), 1 Gemini. They have different strengths.
Q: Do agents need individual areas of expertise?
A: No, every agent is fungible and a generalist. Simply telling one it's a frontend agent doesn't make it better at frontend.
Q: Is there traceability between git commit and bead?
A: Yes, bv automatically does this analysis and links beads to relevant git commits by analyzing the stream of data and making logical deductions.
Agent Swarm Workflow — 并行实现
核心洞察: 每个智能体都是可替代的通才。它们使用相同的基础模型,读取相同的 AGENTS.md。仅仅告诉某个智能体它是前端智能体并不能让它在前端任务上表现更好。
该蜂群是分布式的、健壮的,并通过智能体邮件和任务珠进行自组织。
前置条件
在启动蜂群之前:
- 1. 创建全面的计划(参见 planning-workflow 技能)
- 准备好精炼的任务珠(参见 beads-workflow 技能)
- 配置 AGENTS.md,包含所有工具简介
- 运行智能体邮件服务器(am 或 ~/projects/mcpagentmail/scripts/runserverwith_token.sh)
- NTM 可用于会话管理
蜂群架构
┌─────────────────────────────────────────────────────────────┐
│ 任务珠 │
│ (具有依赖关系、优先级、状态的任务图) │
└─────────────────────────────────────────────────────────────┘
│
┌─────────┴─────────┐
▼ ▼
┌─────────────────────────────┐ ┌─────────────────────────┐
│ BV │ │ 智能体邮件 │
│ (下一步做什么) │ │ (协调层) │
└─────────────────────────────┘ └─────────────────────────┘
│ │
└──────────────┬─────────────┘
▼
┌─────────────────────────────────────────────────────────────┐
│ NTM + 智能体 │
│ ┌─────┐ ┌─────┐ ┌─────┐ ┌─────┐ ┌─────┐ ┌─────┐ │
│ │ CC │ │ CC │ │ Cod │ │ Gmi │ │ CC │ │ Cod │ │
│ └─────┘ └─────┘ └─────┘ └─────┘ └─────┘ └─────┘ │
└─────────────────────────────────────────────────────────────┘
启动蜂群
使用 NTM(命名 Tmux 管理器)
bash
生成包含多个智能体的蜂群
ntm spawn myproject --cc=3 --cod=2 --gmi=1
向所有 Claude Code 智能体发送初始提示
ntm send myproject --cc $(cat initial_prompt.txt)
或向所有智能体发送
ntm send myproject --all $(cat initial_prompt.txt)
手动设置
在项目文件夹中为每个智能体创建 tmux 会话/窗格。
精确提示 — 初始智能体行动指令
给每个智能体这个精确的提示来启动:
首先仔细阅读 AGENTS dot md 文件和 README dot md 文件,理解两者的全部内容!然后使用你的代码调查智能体模式,全面理解项目的代码、技术架构和目的。然后向 MCP Agent Mail 注册,并向其他智能体介绍自己。
务必检查你的智能体邮件,并在需要时及时回复任何消息;然后仔细执行你下一个分配的任务珠,系统而细致地处理任务,通过任务珠和智能体邮件消息跟踪你的进度。
不要陷入沟通炼狱而一事无成;主动开始需要完成的任务,但在这样做时通过消息告知你的同伴智能体,并适当地标记任务珠。
当你不确定下一步该做什么时,使用 AGENTS dot md 中提到的 bv 工具来优先选择下一个最适合处理的任务珠;选择一个你能有效处理的任务珠并开始工作。确保确认来自其他智能体的所有通信请求,并了解所有活跃智能体及其名称。使用 ultrathink。
执行循环
精确提示 — 移动到下一个任务珠
一旦智能体完成一个任务珠,使用这个提示让他们继续前进:
重新阅读 AGENTS dot md,使其在你的脑海中保持新鲜。使用 ultrathink。使用带有机器人标志的 bv(参见 AGENTS dot md 了解相关信息)来找到下一个最有影响力的任务珠并开始处理。记住适当地标记任务珠并与你的同伴智能体沟通。选择你当前能有效处理的下一个任务珠,立即开始编码;向你的同伴智能体通报你正在做什么,并在工作时适当地标记任务珠。同时回复你收到的任何智能体邮件消息。
精确提示 — 任务珠完成后的自我审查
让智能体在继续前进之前审查自己的工作:
很好,现在我希望你以全新的眼光仔细阅读你刚刚编写的所有新代码以及你刚刚修改的其他现有代码,超级仔细地查找任何明显的错误、缺陷、问题、困惑等。仔细修复你发现的任何问题。使用 ultrathink。
持续运行此提示,直到他们找不到错误为止。
处理上下文压缩
精确提示 — 压缩后
当智能体进行压缩时,立即跟进:
重新阅读 AGENTS dot md,使其在你的脑海中保持新鲜。使用 ultrathink。
这将重新建立关于工具和工作流的关键上下文。
质量审查提示
精确提示 — 跨智能体审查
定期让智能体审查彼此的工作:
好的,现在你能把注意力转向审查你的同伴智能体编写的代码,检查是否有任何问题、错误、缺陷、低效、安全问题、可靠性问题等,并使用第一性原理分析仔细诊断它们的根本原因,然后在必要时修复或修改它们吗?不要局限于最新的提交,扩大范围并深入挖掘!使用 ultrathink。
精确提示 — 随机代码探索
用于深度质量检查:
我希望你以某种方式随机探索这个项目中的代码文件,选择代码文件进行深入调查和理解,并通过它们导入或导入它们的相关代码文件来追踪它们的功能和执行流程。
一旦你在工作流的更大上下文中理解了代码的目的,我希望你以全新的眼光进行超级仔细、有条理和批判性的检查,以发现任何明显的错误、问题、缺陷、愚蠢的错误等,然后系统、细致和智能地纠正它们。
确保遵守 AGENTS dot md 中的所有规则,并确保你编写或修改的任何代码符合 AGENTS dot md 文件中引用的最佳实践指南。使用 ultrathink。
提交工作
精确提示 — 提交更改
让智能体提交逻辑分组的更改:
现在,基于你对项目的了解,以一系列逻辑连接的组提交所有更改的文件,每个组附带超级详细的提交消息,然后推送。慢慢来,确保做对。不要编辑任何代码。不要提交明显是临时性的文件。使用 ultrathink。
任务珠完成后的提示
精确提示 — 添加测试覆盖
我们是否有完整的单元测试覆盖,而不使用模拟/虚假的东西?是否有完整的端到端集成测试脚本,带有详细日志记录?如果没有,那么为所有这些创建一个全面且细粒度的任务珠集,包含任务、子任务和依赖结构,并附有详细注释。
精确提示 — UI/UX 审查
很好,现在我希望你超级仔细地审视应用程序工作流和实现的每个方面,寻找那些对你来说似乎不够优化甚至错误/有误的地方,那些从用户友好性和直观性角度可以明显改进的地方,那些我们可以改进和打磨 UI/UX 使其更流畅、更具视觉吸引力、更高端感觉、超高质量的地方,就像 Stripe 级别的应用。
精确提示 — 深度 UI/UX 增强
我仍然认为有很强的机会来增强 UI/UX 的外观和感觉,使一切工作得更好、更直观、更用户友好、更具视觉吸引力、更精致、更流畅,并在遵循 UI/UX 最佳实践方面达到世界级水平,就像 Stripe 使用的那样,你同意吗?我希望你在做这件事时分别仔细考虑桌面 UI/UX 和移动 UI/UX,并分别为两者进行超优化,以发挥每种模式的特点。我追求的是真正的世界级视觉吸引力、精致度、流畅度等,让人们惊叹于它在各方面是多么惊艳和完美。使用 ultrathink。
智能体邮件集成
智能体如何协调
每个智能体:
- 1. 在会话开始时向智能体邮件注册
- 在编辑前保留文件(filereservationpaths)
- 通过带有任务珠 ID 的 thread_id 消息宣布工作
- 在任务之间检查收件箱
- 完成后释放保留
文件保留模式
python
开始处理任务珠前
file
reservationpaths(
project_key=/path/to/project,
agent_name=GreenCastle,
paths=[src/auth/
/*.ts],
ttl_seconds=3600,
exclusive=True,
reason=bd-123
)
完成工作后
release
filereservations(project
key, agentname)
通信模式
python
宣布开始处理任务珠
send_message(
project
key, agentname,
to=[BlueLake, RedMountain], # 其他活跃智能体
subject=[