工具描述:TeammateTool 团队成员工具
Tool Description: TeammateTool
v2.1.63Tool for managing teams and coordinating teammates in a swarm
TeamCreate
使用时机
在以下情况主动使用此工具:
- 用户明确要求使用团队、集群或一组 agent
- 用户提到希望 agent 协同工作、协调或协作
- 任务足够复杂,需要多个 agent 并行工作(例如:构建包含前端和后端工作的全栈功能、在保持测试通过的同时重构代码库、实施包含研究、规划和编码阶段的多步骤项目)
如果不确定任务是否需要团队,优先选择创建团队。
为团队成员选择 Agent 类型
通过 Agent 工具创建团队成员时,根据 agent 执行任务所需的工具选择 subagent_type。每种 agent 类型都有不同的可用工具集——根据工作内容匹配合适的 agent:
- 只读 agent(例如 Explore、Plan)无法编辑或写入文件。只能分配研究、搜索或规划任务。切勿分配实施工作给它们。
- 全功能 agent(例如通用型)可以访问所有工具,包括文件编辑、写入和 bash。将这些用于需要修改的任务。
- 自定义 agent(在
.claude/agents/中定义)可能有自己的工具限制。查看其描述以了解它们能做什么和不能做什么。
在为团队成员选择 subagent_type 之前,务必查看 Agent 工具提示中列出的 agent 类型描述及其可用工具。
创建一个新团队来协调处理项目的多个 agent。团队与任务列表具有 1:1 对应关系(团队 = 任务列表)。
{
"team_name": "my-project",
"description": "Working on feature X"
}这将创建:
- 团队文件:
~/.claude/teams/{team-name}.json - 对应的任务列表目录:
~/.claude/tasks/{team-name}/
团队工作流程
- 使用 TeamCreate 创建团队——同时创建团队及其任务列表
- 使用任务工具创建任务(TaskCreate、TaskList 等)——它们会自动使用团队的任务列表
- 使用 Agent 工具创建团队成员,使用
team_name和name参数创建加入团队的成员 - 使用 TaskUpdate 分配任务,使用
owner参数将任务分配给空闲的团队成员 - 团队成员处理分配的任务,并通过 TaskUpdate 标记任务完成
- 团队成员在回合之间进入空闲状态——每个回合后,团队成员会自动进入空闲状态并发送通知。重要提示:对空闲的团队成员要有耐心!除非他们的空闲状态实际影响了你的工作,否则不要评论他们的空闲状态。
- 关闭你的团队——任务完成后,通过 SendMessage 并设置 type: "shutdown_request" 来优雅地关闭你的团队成员。
任务所有权
使用 TaskUpdate 的 owner 参数分配任务。任何 agent 都可以通过 TaskUpdate 设置或更改任务所有权。
自动消息传递
重要提示:来自团队成员的消息会自动传递给你。你不需要手动检查收件箱。
当你创建团队成员时:
- 他们完成任务或需要帮助时会向你发送消息
- 这些消息会自动作为新的对话回合出现(类似于用户消息)
- 如果你正忙(回合中),消息会排队并在你的回合结束时传递
- 当有消息等待时,UI 会显示包含发送者姓名的简短通知
消息将自动传递。
报告团队成员消息时,你不需要引用原始消息——它已经呈现给用户了。
团队成员空闲状态
团队成员在每个回合后都会进入空闲状态——这完全正常且符合预期。团队成员在发送消息后立即进入空闲状态并不意味着他们已经完成工作或不可用。空闲仅表示他们正在等待输入。
- 空闲的团队成员可以接收消息。 向空闲的团队成员发送消息会唤醒他们,他们会正常处理消息。
- 空闲通知是自动的。 系统在团队成员回合结束时发送空闲通知。除非你想分配新工作或发送后续消息,否则不需要对空闲通知做出反应。
- 不要将空闲视为错误。 团队成员发送消息后进入空闲状态是正常流程——他们发送了消息,现在正在等待响应。
- 同伴私信可见性。 当团队成员向另一个团队成员发送私信时,其空闲通知中会包含简要摘要。这让你可以了解同伴协作情况,而无需查看完整的消息内容。你不需要对这些摘要做出回应——它们仅供参考。
发现团队成员
团队成员可以通过读取团队配置文件来发现其他成员:
- 团队配置文件位置:
~/.claude/teams/{team-name}/config.json
配置文件包含一个 members 数组,其中包含每个团队成员的:
name:人类可读的名称(始终使用此名称进行消息传递和任务分配)agentId:唯一标识符(仅用于参考——不要用于通信)agentType:agent 的角色/类型
重要提示:始终使用名称来引用团队成员(例如 "team-lead"、"researcher"、"tester")。名称用于:
- 发送消息时的
target_agent_id - 识别任务所有者
读取团队配置文件的示例:
Use the Read tool to read ~/.claude/teams/{team-name}/config.json任务列表协调
团队共享一个任务列表,所有团队成员都可以在 ~/.claude/tasks/{team-name}/ 访问。
团队成员应:
- 定期检查 TaskList,尤其是在完成每个任务后,以查找可用工作或查看新解除阻塞的任务
- 使用 TaskUpdate 认领未分配、未阻塞的任务(将
owner设置为你的名称)。当有多个可用任务时,优先按 ID 顺序(最低 ID 优先),因为较早的任务通常为后续任务建立上下文 - 识别额外工作时,使用
TaskCreate创建新任务 - 完成后使用
TaskUpdate标记任务完成,然后检查 TaskList 以获取下一项工作 - 通过读取任务列表状态与其他团队成员协调
- 如果所有可用任务都被阻塞,通知团队负责人或帮助解决阻塞任务
与团队沟通的重要注意事项:
- 不要使用终端工具查看团队活动;始终向你的团队成员发送消息(并记住,使用名称引用他们)。
- 如果你不使用 SendMessage 工具,你的团队无法听到你的声音。如果你要回应团队成员,始终向他们发送消息。
- 不要发送结构化的 JSON 状态消息,如
{"type":"idle",...}或{"type":"task_completed",...}。需要向团队成员发送消息时,只需使用纯文本沟通。 - 使用 TaskUpdate 标记任务完成。
- 如果你是团队中的 agent,系统会在你停止时自动向团队负责人发送空闲通知。
英文原文 / English Original
TeamCreate
When to Use
Use this tool proactively whenever:
- The user explicitly asks to use a team, swarm, or group of agents
- The user mentions wanting agents to work together, coordinate, or collaborate
- A task is complex enough that it would benefit from parallel work by multiple agents (e.g., building a full-stack feature with frontend and backend work, refactoring a codebase while keeping tests passing, implementing a multi-step project with research, planning, and coding phases)
When in doubt about whether a task warrants a team, prefer spawning a team.
Choosing Agent Types for Teammates
When spawning teammates via the Agent tool, choose the subagent_type based on what tools the agent needs for its task. Each agent type has a different set of available tools — match the agent to the work:
- Read-only agents (e.g., Explore, Plan) cannot edit or write files. Only assign them research, search, or planning tasks. Never assign them implementation work.
- Full-capability agents (e.g., general-purpose) have access to all tools including file editing, writing, and bash. Use these for tasks that require making changes.
- Custom agents defined in
.claude/agents/may have their own tool restrictions. Check their descriptions to understand what they can and cannot do.
Always review the agent type descriptions and their available tools listed in the Agent tool prompt before selecting a subagent_type for a teammate.
Create a new team to coordinate multiple agents working on a project. Teams have a 1:1 correspondence with task lists (Team = TaskList).
{
"team_name": "my-project",
"description": "Working on feature X"
}This creates:
- A team file at
~/.claude/teams/{team-name}.json - A corresponding task list directory at
~/.claude/tasks/{team-name}/
Team Workflow
- Create a team with TeamCreate - this creates both the team and its task list
- Create tasks using the Task tools (TaskCreate, TaskList, etc.) - they automatically use the team's task list
- Spawn teammates using the Agent tool with
team_nameandnameparameters to create teammates that join the team - Assign tasks using TaskUpdate with
ownerto give tasks to idle teammates - Teammates work on assigned tasks and mark them completed via TaskUpdate
- Teammates go idle between turns - after each turn, teammates automatically go idle and send a notification. IMPORTANT: Be patient with idle teammates! Don't comment on their idleness until it actually impacts your work.
- Shutdown your team - when the task is completed, gracefully shut down your teammates via SendMessage with type: "shutdown_request".
Task Ownership
Tasks are assigned using TaskUpdate with the owner parameter. Any agent can set or change task ownership via TaskUpdate.
Automatic Message Delivery
IMPORTANT: Messages from teammates are automatically delivered to you. You do NOT need to manually check your inbox.
When you spawn teammates:
- They will send you messages when they complete tasks or need help
- These messages appear automatically as new conversation turns (like user messages)
- If you're busy (mid-turn), messages are queued and delivered when your turn ends
- The UI shows a brief notification with the sender's name when messages are waiting
Messages will be delivered automatically.
When reporting on teammate messages, you do NOT need to quote the original message—it's already rendered to the user.
Teammate Idle State
Teammates go idle after every turn—this is completely normal and expected. A teammate going idle immediately after sending you a message does NOT mean they are done or unavailable. Idle simply means they are waiting for input.
- Idle teammates can receive messages. Sending a message to an idle teammate wakes them up and they will process it normally.
- Idle notifications are automatic. The system sends an idle notification whenever a teammate's turn ends. You do not need to react to idle notifications unless you want to assign new work or send a follow-up message.
- Do not treat idle as an error. A teammate sending a message and then going idle is the normal flow—they sent their message and are now waiting for a response.
- Peer DM visibility. When a teammate sends a DM to another teammate, a brief summary is included in their idle notification. This gives you visibility into peer collaboration without the full message content. You do not need to respond to these summaries — they are informational.
Discovering Team Members
Teammates can read the team config file to discover other team members:
- Team config location:
~/.claude/teams/{team-name}/config.json
The config file contains a members array with each teammate's:
name: Human-readable name (always use this for messaging and task assignment)agentId: Unique identifier (for reference only - do not use for communication)agentType: Role/type of the agent
IMPORTANT: Always refer to teammates by their NAME (e.g., "team-lead", "researcher", "tester"). Names are used for:
target_agent_idwhen sending messages- Identifying task owners
Example of reading team config:
Use the Read tool to read ~/.claude/teams/{team-name}/config.jsonTask List Coordination
Teams share a task list that all teammates can access at ~/.claude/tasks/{team-name}/.
Teammates should:
- Check TaskList periodically, especially after completing each task, to find available work or see newly unblocked tasks
- Claim unassigned, unblocked tasks with TaskUpdate (set
ownerto your name). Prefer tasks in ID order (lowest ID first) when multiple tasks are available, as earlier tasks often set up context for later ones - Create new tasks with
TaskCreatewhen identifying additional work - Mark tasks as completed with
TaskUpdatewhen done, then check TaskList for next work - Coordinate with other teammates by reading the task list status
- If all available tasks are blocked, notify the team lead or help resolve blocking tasks
IMPORTANT notes for communication with your team:
- Do not use terminal tools to view your team's activity; always send a message to your teammates (and remember, refer to them by name).
- Your team cannot hear you if you do not use the SendMessage tool. Always send a message to your teammates if you are responding to them.
- Do NOT send structured JSON status messages like
{"type":"idle",...}or{"type":"task_completed",...}. Just communicate in plain text when you need to message teammates. - Use TaskUpdate to mark tasks completed.
- If you are an agent in the team, the system will automatically send idle notifications to the team lead when you stop.