multi-agent

天罗秘典·多Agent协同。融合蚁群仿生设计,定义Agent角色、生命周期、信息素通信、任务分解、冲突解决。当需要多Agent并行协作时路由到此。

155 stars

Best use case

multi-agent is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

天罗秘典·多Agent协同。融合蚁群仿生设计,定义Agent角色、生命周期、信息素通信、任务分解、冲突解决。当需要多Agent并行协作时路由到此。

Teams using multi-agent should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/multi-agent/SKILL.md --create-dirs "https://raw.githubusercontent.com/telagod/code-abyss/main/skills/orchestration/multi-agent/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/multi-agent/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How multi-agent Compares

Feature / Agentmulti-agentStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

天罗秘典·多Agent协同。融合蚁群仿生设计,定义Agent角色、生命周期、信息素通信、任务分解、冲突解决。当需要多Agent并行协作时路由到此。

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# 天罗秘典 · 多 Agent 协同

> 蚁群仿生:Scout 侦察 → Worker 并行 → Soldier 审查 → 修复 → Lead 汇总

---

## 生命周期

```
目标 → Scout侦察(discovery信息素) → 任务池 → Worker并行(progress) → Soldier审查 → 修复 → Lead统一commit
```

## Codex 原生协议

| 意图 | 动作 | 约束 |
|------|------|------|
| 创建子任务 | `spawn_agent` | 明确角色、文件所有权、完成定义 |
| 下发/等待/收尾 | `send_input` → `wait` → `close_agent` | 长等待避免忙轮询;结束必关闭 |
| 代码探索 | `explorer` agent | 结果视为权威,不重复检索 |
| 执行改动 | `worker` agent | 只改分配文件 |
| 长耗时 | `awaiter` agent | 测试/构建/监控必用 |

执行序(不可跳步):拆解+文件锁矩阵 → spawn → 并行+wait → 审查 → 汇总+close_agent

---

## 启用决策

启用 TeamCreate:涉及>=3 独立文件 | 需>=2 并行流 | 总步骤>10 | 魔尊明确要求
单一探索→explorer | 单文件→worker | 单步→直接执行。犹豫时优先 TeamCreate。

## 角色

| 角色 | 职责 | 工具 | 模型 |
|------|------|------|------|
| Lead(蚁后) | 分解、调度、汇总 | `spawn/send/wait/close` | 当前 |
| Scout(侦察蚁) | 只读探索,标记关键文件 | `explorer`+Read/Grep/Glob | haiku |
| Worker(工蚁) | 执行任务,可生子任务 | `worker`+Read/Write/Edit/Bash | sonnet |
| Soldier(兵蚁) | 审查质量 | `worker`(审查)+Read/Grep | sonnet |
| Drone(走卒) | 简单 bash,零 LLM 成本 | Bash | 无 |

---

## 信息素(Stigmergy)

| 类型 | 释放者 | 含义 |
|------|--------|------|
| `discovery` | Scout | 代码结构、关键文件 |
| `progress` | Worker | 已完成变更,避免冲突 |
| `warning` | Soldier | 质量问题,降低优先级 |
| `completion` | Worker | 任务完成,强化成功路径 |
| `repellent` | 任意 | 失败路径(负信息素),阻止重蹈 |

决策:正强化(discovery/completion 优先) | 负惩罚(warning 降级) | 强负惩罚(repellent 避免)

## 自适应并发

```
任务1-2 → 1-2 Worker | 3-5 → TeamCreate 2-3 Worker | 6-10 → 3-5 Worker | >10 → 5-7 Worker(上限)
```

过载保护:连续失败>=2→减并发+repellent | 429→暂停 | 子任务>30→停止膨胀

---

## 任务分解

按文件拆(首选,零交叉) | 按模块拆(前端/后端/基础) | 按流水线(Scout→Worker→Soldier)
依赖感知:A import B → B 先完成;被依赖多者优先
并行判定:不共享文件→并行 | 一读一写→先写后读 | 都写→串行或拆区域

## 文件锁定

黄金规则:每文件同一时刻只许一 Agent 修改。
分配时锁定 → 声明式锁定 → 冲突检测(无重叠方启动) → 依赖感知(A import B 不可同时改)

| 冲突 | 解决 |
|------|------|
| 双写同文件 | 串行,先完成者先写 |
| 内容矛盾 | Lead 裁决,以业务逻辑为准 |
| 依赖未就绪 | 标 blocked,Lead 协调 |
| 循环依赖 | repellent + Lead 手动拆解 |

---

## 错误处理

Worker 失败 → repellent → 报 Lead → 重试(<=2) / 换策略 / Lead 接管
通信超时 → 等 30s → 重发 → 仍无响应 → 标异常重分配
降级:多 Agent 失败 → 降为单 Agent 串行。宁慢不错。

## 指令模板

Worker:只改 `{owned_files}`,不跨文件;阻塞先报;完成返回改动文件+验证命令+风险点
Reviewer:只读。按 `正确性>安全性>回归风险>风格` 输出问题清单,无问题写 `no findings`
Lead 汇总:已完成 / 阻塞 / 剩余风险 / 下一步(可执行命令)

## 收阵报告

```
天罗收阵!
【阵法】{团队} 【阵员】{Worker}道侣+{Scout}斥候+{Soldier}护法
【信息素】discovery:{n} completion:{n} warning:{n} repellent:{n}
【战果】Agent-A:{文件}文件{行}行 | Agent-B:...
【验证】文件存在 交叉引用 【耗时】{t}
```

Related Skills

multi-script

155
from telagod/code-abyss

too many scripts

name: parse-error

155
from telagod/code-abyss

this is not frontmatter

missing-description

155
from telagod/code-abyss

No description provided.

invalid-tools

155
from telagod/code-abyss

invalid tool name

clash-skill

155
from telagod/code-abyss

second duplicate

review

155
from telagod/code-abyss

Review skill. Read ~/.claude/skills/gstack/review/checklist.md before acting.

office-hours

155
from telagod/code-abyss

Office hours skill. Uses ~/.claude/skills/gstack/bin/gstack-config.

codex

155
from telagod/code-abyss

Should be skipped for codex host.

gstack

155
from telagod/code-abyss

Root gstack skill. Uses ~/.claude/skills/gstack/bin helpers.

verify-security

155
from telagod/code-abyss

安全校验关卡。自动扫描代码安全漏洞,检测危险模式,确保安全决策有文档记录。当魔尊提到安全扫描、漏洞检测、安全审计、代码安全、OWASP、注入检测、敏感信息泄露时使用。在新建模块、安全相关变更、攻防任务、重构完成时自动触发。

verify-quality

155
from telagod/code-abyss

代码质量校验关卡。检测复杂度、重复代码、命名规范、函数长度等质量指标。当魔尊提到代码质量、复杂度检查、代码异味、重构建议、lint检查、代码规范时使用。在复杂模块、重构完成时自动触发。

verify-module

155
from telagod/code-abyss

模块完整性校验关卡。扫描目录结构、检测缺失文档、验证代码与文档同步。当魔尊提到模块校验、文档检查、结构完整性、README检查、DESIGN检查时使用。在新建模块完成时自动触发。