AgentTeams 是 Claude Code 提供的多智能体并行协作机制。它协调多个 Claude Code 实例共同工作:一个会话担任团队 Lead ,负责创建团队、生成任务列表、调度 Teammate 并汇总结果;各 Teammate 各自运行在独立的上下文窗口中,能够直接相互通信,也可以被用户直接操控,而非只能通过 Lead 间接交互。
启用 AgentTeams 后,直接用自然语言描述任务和团队结构, Claude 会自动创建团队并调度 Teammate :
I'm designing a CLI tool that helps developers track TODO comments across their codebase. Create an agent team to explore this from different angles: one teammate on UX, one on technical architecture, one playing devil's advocate.
共享任务列表协调团队工作。任务有三种状态: pending 、 in progress 、 completed ,并支持任务依赖(依赖未完成的任务不可认领)。 Lead 可以显式分配,也可以让 Teammate 自主认领:
# 显式分配 Tell the backend teammate to take the database migration task. # 让 Lead 等待 Teammate 完成再继续 Wait for your teammates to complete their tasks before proceeding.
Create an agent team to review PR #142. Spawn three reviewers: - One focused on security implications - One checking performance impact - One validating test coverage Have them each review and report findings.
Users report the app exits after one message instead of staying connected. Spawn 5 agent teammates to investigate different hypotheses. Have them talk to each other to try to disprove each other's theories, like a scientific debate. Update the findings doc with whatever consensus emerges.
Create an agent team to implement the user notification feature. Spawn three teammates: - Frontend teammate: implement the notification UI components in src/components/ - Backend teammate: implement the notification API endpoints in src/api/ - Database teammate: write the migration and data access layer in src/db/ Each teammate should only modify files in their assigned directory.
Spawn an architect teammate to refactor the authentication module. Require plan approval before they make any changes. Only approve plans that: - Include unit tests for all modified functions - Don't change the public API interface - Include a rollback strategy
Teammate 启动时会自动加载项目上下文( CLAUDE.md 、 MCP Server 、 Skills ),但 不会继承 Lead 的对话历史 。在调度提示词中需要包含任务所需的关键背景:
Spawn a security reviewer teammate with the prompt: "Review the authentication module at src/auth/ for security vulnerabilities. Focus on token handling, session management, and input validation. The app uses JWT tokens stored in httpOnly cookies. Report any issues with severity ratings."