Claude Code中英文系列教程:子代理subagent
指定描述子代理用途的唯一标识符(例如, code-reviewer , api-designer )。在 .claude/agents/ 中创建团队共享的项目特定的子代理,注意这个目录不要乱改。假设你想使用专门的 AI 子代理来更有效地处理特定任务。上面命令显示了所有可用的子代理,并允许你创建新的子代理。让调试器子代理调查用户无法登录的原因。为你自己的工作流程创建自定义子代理。使用代码审查子代理来
Use specialized subagents
使用专门的子代理
Suppose you want to use specialized AI subagents to handle specific tasks more effectively.
假设你想使用专门的 AI 子代理来更有效地处理特定任务。
1,View available subagents 查看可用子代理
> /agents
This shows all available subagents and lets you create new ones.
上面命令显示了所有可用的子代理,并允许你创建新的子代理。
Use subagents automatically
自动使用子代理
2,Claude Code automatically delegates appropriate tasks to specialized subagents:
Claude Code 会自动将适当的任务委派给专门的子代理,例如:
> review my recent code changes for security issues
查看我最近的代码更改以查找安全问题
> run all tests and fix any failures
运行所有测试并修复任何故障
不需要明确指定具体使用哪个子代理。
3,Explicitly request specific subagents
当然也可以明确请求特定的子代理
> use the code-reviewer subagent to check the auth module
使用代码审查子代理来检查验证模块
> have the debugger subagent investigate why users can't log in
让调试器子代理调查用户无法登录的原因
4,Create custom subagents for your workflow
为你自己的工作流程创建自定义子代理
> /agents
Then select “Create New subagent” and follow the prompts to define:
然后选择“创建新子代理”,并按照提示进行定义:
A unique identifier that describes the subagent’s purpose (for example, code-reviewer, api-designer).
指定描述子代理用途的唯一标识符(例如, code-reviewer , api-designer )。
When Claude should use this agent
Claude 何时使用此代理
Which tools it can access
它能够访问哪些工具
A system prompt describing the agent’s role and behavior
以及描述代理角色和行为的系统提示词
使用技巧
Create project-specific subagents in .claude/agents/ for team sharing
在 .claude/agents/ 中创建团队共享的项目特定的子代理,注意这个目录不要乱改。
Use descriptive description fields to enable automatic delegation
使用描述性的 description 字段以实现自动委派
Limit tool access to what each subagent actually needs
限制每个子代理实际需要的工具
后面会详细展开讲下这个subagent
更多推荐




所有评论(0)