代理团队
- 作者仓库星标 2,212
- 作者仓库 pro-workflow
- 领域
- 人工智能
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @rohitg00 · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 即装即用
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 运行环境要求
- 未检出明确要求
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
Lead: "We need rate limiting. Breaking into 4 tasks."
Task 1: middleware implementation → Teammate 1
Task 2: Redis config → Teammate 2 (no deps)
Task 3: tests → Teammate 1 (after Task 1)
Task 4: API docs → Teammate 2 (after Task 1)
Teammate 1 plans → Lead approves → implements Task 1
Teammate 2 plans → Lead approves → implements Task 2
Task 1 completes → unblocks Tasks 3 and 4
Teammate 1 picks up Task 3, Teammate 2 picks up Task 4
All complete → Lead runs integration tests → commits
# Agent Teams
Coordinate multiple Claude Code sessions working on the same codebase simultaneously.
## Enable
```bash
export CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
claude # starts as team lead
```
The first session becomes the team lead. Subsequent sessions in the same repo join as teammates.
## Architecture
```text
Team Lead (coordinates, delegates, reviews)
├── Teammate 1 (owns task A, messages lead + peers)
├── Teammate 2 (owns task B, messages lead + peers)
└── Teammate 3 (owns task C, messages lead + peers)
│
└── Shared: task list + mailbox + file locks
```
**Key difference from subagents:** Teammates are full Claude Code sessions. They have their own context window, can use all tools, and message each other directly — not just report back to a parent.
## Team Sizing
| Team Size | Best For |
|-----------|----------|
| 2 | One builds, one reviews |
| 3-5 | Parallel features across layers (API, UI, tests) |
| > 5 | Coordination overhead outweighs parallelism |
3-5 teammates is the productive range. Beyond that, the lead spends more time coordinating than the team saves.
**Task granularity:** Aim for 5-6 tasks per teammate. Fewer means underutilization; more means excessive context switching.
## Display Modes
**In-process navigation:**
- `Shift+Down` — cycle through teammates (wraps around)
- See each teammate's current task and output
**Split-pane (recommended for >2 teammates):**
- tmux: `tmux split-window -h` per teammate
- iTerm2: Cmd+D for vertical split
- Each pane runs its own `claude` session
## Task Management
Tasks flow through states:
```text
pending → in-progress → completed
│
└── blocked (waiting on dependency)
```
### Task Decomposition
Break work into units that:
- Touch non-overlapping files
- Can be verified independently
- Have clear done criteria
**Good decomposition:**
```text
Task 1: Add rate limiting middleware (src/middleware/rate-limit.ts)
Task 2: Add rate limit tests (tests/rate-limit.test.ts)
Task 3: Update API docs for rate limit headers (docs/api.md)
Task 4: Add Redis config for rate limit store (src/config/redis.ts)
```
**Bad decomposition:**
```text
Task 1: Implement rate limiting
Task 2: Fix rate limiting bugs
Task 3: Improve rate limiting
```
### Dependencies
Tasks can declare dependencies:
```text
Task 3 (API docs) → depends on Task 1 (middleware)
Task 2 (tests) → depends on Task 1 (middleware)
Task 4 (Redis config) → no dependencies
```
Teammates pick up unblocked tasks automatically.
## File-Lock Claiming
Teammates claim files before editing to prevent conflicts:
1. Teammate checks if file is locked
2. If free, claims it (file-lock-based)
3. Edits the file
4. Releases lock on task completion
If two teammates need the same file, one waits or the lead reassigns.
## Plan Approval
Teammates plan before implementing:
1. Teammate receives task
2. Writes a brief plan (files to change, approach)
3. Lead reviews plan
4. Lead approves or redirects
5. Teammate implements
This prevents wasted work from misunderstood requirements.
## Delegate Mode
`Shift+Tab` toggles delegate mode for the lead:
- Lead coordinates only — no direct code edits
- All implementation delegated to teammates
- Lead reviews, approves plans, manages task flow
## Hook Events
| Hook | Fires When |
|------|------------|
| TeammateIdle | A teammate finishes its task and has no pending work |
| TaskCreated | New task added to the shared list |
| TaskCompleted | A teammate marks a task done |
Use these to trigger notifications, auto-assign next tasks, or run integration tests when all tasks complete.
## When to Use Teams vs Alternatives
| Scenario | Use |
|----------|-----|
| Parallel work on non-overlapping files | Agent teams |
| Quick background exploration | Subagent |
| Isolated feature branch work | Worktree (`claude -w`) |
| Competing approaches to same problem | Worktrees (compare results) |
| Cross-layer changes (API + UI + tests) | Agent teams |
| One-off delegation | Subagent with `isolation: worktree` |
| Large-scale migration (20+ files) | `/batch` command |
## Anti-Patterns
- More than 5 teammates — coordination overhead dominates
- Tasks that share mutable state or the same files
- Skipping plan approval — leads to rework
- Lead doing implementation instead of coordinating (use delegate mode)
- Not setting dependencies — teammates race on coupled tasks
## Example Session
```text
Lead: "We need rate limiting. Breaking into 4 tasks."
Task 1: middleware implementation → Teammate 1
Task 2: Redis config → Teammate 2 (no deps)
Task 3: tests → Teammate 1 (after Task 1)
Task 4: API docs → Teammate 2 (after Task 1)
Teammate 1 plans → Lead approves → implements Task 1
Teammate 2 plans → Lead approves → implements Task 2
Task 1 completes → unblocks Tasks 3 and 4
Teammate 1 picks up Task 3, Teammate 2 picks up Task 4
All complete → Lead runs integration tests → commits
```
## Docs
https://code.claude.com/docs/agent-teams
章节与文件索引
按说明文件中的顺序排列。
启用
建筑
团队规模调整
显示模式
任务管理
文件/命令 -> Shift+Down · tmux split-window -h · Shift+Tab · claude -w · isolation: worktree · /batch
内容校验值 -> 1bac8841b0da
当前原文的自动摘译,尚未人工审校。
启用
第一届会议成为团队负责人。同一存储库中的后续会话将作为队友加入。
建筑
与子代理的主要区别:队友是完整的克劳德代码会话。他们有自己的上下文窗口,可以使用所有工具,并直接互相发送消息,而不仅仅是向家长报告。
团队规模调整
团队规模 · 最适合 2 · 一次构建,一名评论 3-5 · 跨层并行功能(API、UI、测试) 5 · 协调开销超过并行性 3-5 名队友是高效范围。除此之外,领导者花费在协调上的时间比团队节省的时间还要多。
显示模式
进程内导航:
Shift+Down— 循环队友(环绕) 查看每个队友的当前任务和输出 分割窗格(建议 > 2 名队友使用): tmux:每个队友tmux split-window -h任务管理
任务流经状态: