A practical guide to Claude Code subagents: when they help, how to direct them, and the signals that tell you delegation is worth it.

  • Category
  • Product
    Claude Code
  • Date
    April 7, 2026
  • Reading time
    5
    min
  • Share
    Copy link
    https://claude.com/blog/subagents-in-claude-code

Claude Code handles complex, multi-step projects well, but long sessions accumulate weight. Every file read, every tangent explored, every half-finished thought stays in the context window, slowing responses and driving up token costs.Claude Code 能很好地处理复杂的多步骤项目,但长时间的会话会累积负担。每一次文件读取、每一次分支探索、每一个未完成的想法都会占用上下文窗口,导致响应变慢并增加 token 成本。

Consider building a new feature in a large TypeScript monorepo. The main work is the implementation, but side tasks keep appearing: trace how an existing service handles auth, find the shared util for date formatting, check whether the design system already has a component close to what you need. None of these need the full project context, and running them inside the main session adds noise. What if you could run them in parallel?设想在一个大型 TypeScript 单体仓库中构建新功能。主要工作是实现,但会不断出现旁支任务:追踪现有服务如何处理身份验证,找到用于日期格式化的共享工具,检查设计系统是否已有接近所需的组件。这些都不需要完整的项目上下文,而在主会话中运行它们会产生噪音。如果可以并行运行它们会怎样?

Enter subagents. A subagent is an isolated Claude instance with its own context window. It takes a task, does the work, and returns only the result. Think of subagents as the browser tabs of a Claude Code session: a place to chase a tangent without losing the main thread.引入子代理。子代理是一个拥有独立上下文窗口的隔离 Claude 实例。它接受任务,完成工作,只返回结果。可以把子代理想象成 Claude Code 会话的浏览器标签页:一个在不丢失主线的情况下追踪分支的地方。

In this article, we discuss when it makes sense to use subagents, how to invoke them, and when the overhead isn't worth it.在本文中,我们将讨论何时使用子代理、如何调用它们,以及何时开销不值得。

What is a subagent? 什么是子代理?

Subagents are self-contained agents that operate with their own context windows. When Claude spawns a subagent, that assistant works independently to read files, explore code, or make changes. When it completes its task, the subagent returns only the relevant results to the main conversation.子代理是自包含的代理,拥有自己的上下文窗口。当 Claude 启动子代理时,该助手会独立读取文件、探索代码或进行更改。任务完成后,子代理只将相关结果返回给主对话。

Each subagent starts fresh, unburdened by the history of the conversation or invoked skills. Multiple subagents can run in parallel, and each can have different permissions: a research subagent might have read-only access, while an implementation subagent gets full editing capabilities.每个子代理都是全新启动的,不受先前对话历史或已调用技能的影响。多个子代理可以并行运行,并且每个子代理可以拥有不同的权限:研究子代理可能只有只读权限,而实现子代理则拥有完整的编辑能力。

Claude Code includes several built-in subagent types, including:Claude Code 包含多种内置子代理类型,包括:

  • General-purpose agents for complex multi-step tasks用于复杂多步骤任务的通用代理
  • Plan agents that research codebases before presenting implementation strategies在呈现实现策略前研究代码库的计划代理
  • Explore agents optimized for fast, read-only code search 针对快速只读代码搜索进行优化的探索代理

Claude Code often spawns subagents on its own to handle assigned tasks. It's also possible to direct that behavior explicitly and to define reusable specialists that Claude delegates to automatically. Knowing when to reach for subagents is what makes the feature useful. Claude Code 经常自行生成子代理来处理分配的任务。也可以显式指示这种行为,并定义可重复使用的专员,让 Claude 自动委派。了解何时使用子代理是让此功能发挥作用的关键。

When should you use subagents? 何时应该使用子代理?

Certain categories of work benefit clearly from subagent delegation. Learning to recognize them makes the feature far more effective.某些工作类别显然受益于子代理委派。学会识别它们可以让此功能更高效。

Research-heavy tasks重研究任务

When understanding how something works is a prerequisite to changing it, a subagent can explore the codebase and return a summary rather than dumping dozens of files into the conversation.当了解某事的工作原理是更改它的前提时,子代理可以探索代码库并返回摘要,而不是把数十个文件倾倒到对话中。

The signal: Gathering context requires reading dozens of files.信号:收集上下文需要读取数十个文件。

The benefit: The main conversation stays clean, and synthesized findings arrive instead of raw content.好处:主对话保持整洁,合成的发现取代原始内容出现。

Multiple independent tasks多个独立任务

When fixing errors across several files, updating patterns in multiple components, or making changes that don't depend on each other, parallel subagents complete the task faster.当需要在多个文件中修复错误、在多个组件中更新模式或进行彼此不依赖的更改时,并行子代理可以更快完成任务。

The signal: Sub-tasks have no dependencies between them.信号:子任务之间没有依赖关系。

The benefit: Three subagents working simultaneously generally finish the task in less time.好处:三个子代理同时工作通常能在更短时间内完成任务。

Fresh perspective needed需要新视角

When an unbiased review of an implementation is the goal, a subagent provides a clean slate because it doesn't inherit the assumptions, context, or blind spots from the primary conversation.当目标是对实现进行公正审查时,子代理提供了干净的起点,因为它不继承主对话的假设、上下文或盲点。

The signal: Verification is needed without conversation history influencing the analysis.信号:需要验证但对话历史不应影响分析。

The benefit: Cleaner, more objective feedback.好处:更清晰、更客观的反馈。

Pro-tip: The /clear command also resets context and conversation history, providing a similarly unbiased slate, but at the cost of losing that history entirely. A subagent achieves the same fresh perspective while the main conversation stays intact.专业提示:/clear 命令同样会重置上下文和对话历史,提供类似的无偏视角,但代价是完全失去历史记录。子代理在保持主对话完整的同时实现相同的全新视角。

Verification before committing提交前的验证

Before finalizing changes, an independent subagent can verify the implementation isn't overfitting to tests or missing edge cases.在最终确定更改之前,独立的子代理可以验证实现是否过度拟合测试或遗漏边缘情况。

The signal: A second opinion is warranted before committing code.信号:在提交代码前需要第二意见。

The benefit: Catches issues that familiarity with the code might obscure.好处:捕获熟悉代码时可能忽视的问题。

Pipeline workflows流水线工作流

When a task has distinct phases (i.e., design, then implement, then test), each stage benefits from focused attention.当任务有明确阶段(例如设计、实现、测试)时,每个阶段都受益于专注的注意力。

The signal: Sequential stages with clear handoffs.信号:具有清晰交接的顺序阶段。

The benefit: Each subagent concentrates on its phase, without context from other stages creating noise.好处:每个子代理专注于其阶段,避免其他阶段的上下文产生噪音。

Pro-tip: When a task requires exploring ten or more files, or involves three or more independent pieces of work, that's a strong signal to direct Claude toward subagents.专业提示:当任务需要探索十个以上文件,或涉及三个以上独立工作块时,这是指向 Claude 使用子代理的强信号。

How to direct subagent usage如何引导子代理使用

Several methods exist for invoking subagents, ranging from simple conversation to automated workflows. The right starting point depends on the workflow, and sophistication can be layered on as patterns emerge.调用子代理的方法有多种,从简单的对话到自动化工作流。合适的起点取决于工作流,随着模式显现可以逐步加入更复杂的层次。

Conversational invocation对话式调用

The most flexible approach is simply asking Claude to use subagents in conversation. This works across all Claude Code interfaces: terminal, VS Code, JetBrains, the web, and desktop applications. 最灵活的方式就是在对话中直接让 Claude 使用子代理。这在所有 Claude Code 界面均可使用:终端、VS Code、JetBrains、网页和桌面应用。

Natural language patterns that reliably invoke subagents include:可靠触发子代理的自然语言模式包括:

  • "Use a subagent to explore how authentication works in this codebase"“使用子代理探索此代码库中身份验证的工作方式”
  • "Have a separate agent review this code for security issues"“让一个独立的代理审查此代码的安全问题”
  • "Research this in parallel. Check the API routes, database models, and frontend components simultaneously"“并行研究。检查 API 路由、数据库模型和前端组件”
  • "Spin up subagents to fix these TypeScript errors across the different packages"“启动子代理修复这些不同包中的 TypeScript 错误”

Being explicit matters. Specify the scope, request parallel execution when tasks are independent, and describe the desired output.明确表达很重要。指定范围、在任务独立时请求并行执行,并描述期望的输出。

Here's an effective prompt structure:以下是有效的提示结构:

Use subagents to explore this codebase in parallel:

1. Find all API endpoints and summarize their purposes
2. Identify the database schema and relationships
3. Map out the authentication flow

Return a summary of each, not the full file contents.

This prompt works because it clearly defines three independent tasks, explicitly requests parallel execution, and specifies the output format. Claude understands the intent and spawns appropriate subagents.此提示之所以有效,是因为它清晰定义了三个独立任务,明确请求并行执行,并指定输出格式。Claude 能理解意图并生成相应的子代理。

Tips for effective conversational invocation include:对话式调用的有效技巧包括:

  • Scope tasks clearly. "Explore how payments work" beats "explore everything."明确任务范围。"探索支付如何工作"胜过"探索所有内容"。
  • Request parallelization explicitly. Say "these can run in parallel" or "work on all three simultaneously."明确请求并行化。说"这些可以并行运行"或"同时处理这三项"。
  • Specify what should be returned. Summaries, specific findings, or recommendations. Naming the output format helps Claude deliver it.指定返回内容。摘要、具体发现或建议。命名输出格式有助于 Claude 按要求交付。
  • Ask for fresh context when unbiased analysis matters. "Use a subagent that does not see our previous discussion" ensures clean evaluation.在需要无偏分析时请求全新上下文。"使用未看到我们之前讨论的子代理"确保评估干净。

Pro-tip: When a subagent is taking a while, Ctrl+B sends it to the background. The conversation can continue while it runs, and results surface automatically when it finishes. The /tasks command shows anything running in the background.专业提示:当子代理运行时间较长时,按 Ctrl+B 将其发送到后台。对话可以继续进行,子代理完成后结果会自动弹出。/tasks 命令可查看后台运行的任务。

Custom subagents自定义子代理

When the same kind of subagent keeps getting requested (a security reviewer, a test writer, a docs proofreader), it can be defined once as a custom subagent. 当同一种子代理被频繁请求(如安全审查员、测试编写者、文档校对员),可以将其定义为一次性自定义子代理。

Claude then delegates to it automatically whenever a task matches its description, no prompting required.随后 Claude 会在任务匹配其描述时自动委派,无需额外提示。

Custom subagents live as markdown files in .claude/agents/ (project-level, shared with the team) or ~/.claude/agents/ (user-level, available across all projects). Each one gets its own system prompt, tool permissions, and optionally its own model.自定义子代理以 markdown 文件形式存放在 .claude/agents/(项目级,团队共享)或 ~/.claude/agents/(用户级,跨项目可用)中。每个子代理拥有自己的系统提示、工具权限,甚至可以指定模型。

The easiest way to create one is the /agents command, which walks through setup interactively and can generate a first draft from a description. The file can also be written by hand, for example:创建最简便的方式是使用 /agents 命令,它会交互式引导设置,并可根据描述生成初稿。文件也可以手动编写,例如:

---
name: security-reviewer
description: Reviews code changes for security vulnerabilities,
  injection risks, auth issues, and sensitive data exposure.
  Use proactively before commits touching auth, payments, or user data.
tools: Read, Grep, Glob
model: sonnet
---

You are a security-focused code reviewer. Analyze the provided
changes for:
- SQL injection, XSS, and command injection risks
- Authentication and authorization gaps
- Sensitive data in logs, errors, or responses
- Insecure dependencies or configurations

Return a prioritized list of findings with file:line references
and a recommended fix for each. Be critical. If you find nothing,
say so explicitly rather than inventing issues.

With this in place, Claude routes matching work to the subagent automatically. It can also be invoked by name: "Have the security-reviewer look at the staged changes."有了这些配置,Claude 会自动将匹配的工作路由到子代理。也可以通过名称调用:"让 security-reviewer 查看已暂存的更改。"

Custom subagents work best when:自定义子代理最适合的情形是:

  • A specialist should be available for Claude to delegate to automatically when a task matches当有专员可以在任务匹配时自动供 Claude 委派
  • The work benefits from a tightly scoped system prompt and restricted tools工作受益于严格限定的系统提示和受限工具
  • The configuration should be shared across a team or reused across projects配置需要在团队间共享或跨项目复用

Pro-tip: The description field is what Claude uses to decide when to delegate. Be specific about the trigger conditions, not just the capability. "Reviews code for security issues before commits" routes better than "security expert."专业提示:description 字段决定 Claude 何时委派。要具体说明触发条件,而不仅仅是能力。"在提交前审查代码的安全问题"的路由效果优于"安全专家"。

For the full configuration reference, including permission modes and how project and user subagents interact, see our Claude Code subagents docs.完整的配置参考,包括权限模式以及项目和用户子代理的交互方式,请参阅我们的 Claude Code 子代理文档。

CLAUDE.md instructionsCLAUDE.md 指令

Custom subagents define who the specialists are. CLAUDE.md files define the rules for when Claude should reach for them. If every code review should go through a read-only subagent, or every architecture question should trigger a research pass first, CLAUDE.md is where that policy lives. Claude reads it at the start of every conversation, so the behavior stays consistent across sessions and teammates without anyone needing to remember to ask.自定义子代理定义了专员是谁。CLAUDE.md 文件定义了 Claude 何时应调用它们的规则。如果每次代码审查都应通过只读子代理,或每个架构问题都应先进行研究,CLAUDE.md 就是存放这些策略的地方。Claude 在每次对话开始时读取它,从而在会话和团队成员之间保持一致行为,无需人为记住去请求。

CLAUDE.md is a good fit for subagent instructions when:CLAUDE.md 适合作为子代理指令的场景包括:

  • Code reviews should always use read-only subagents代码审查应始终使用只读子代理
  • The project has specific research patterns Claude should follow项目有特定的研究模式 Claude 应遵循
  • Consistent behavior is needed across team members and sessions需要在团队成员和会话之间保持一致行为

Here’s an example of a simple CLAUDE.md file that triggers a subagent given specific conditions:以下是一个简单的 CLAUDE.md 示例文件,当满足特定条件时触发子代理:

## Code review standards

When asked to review code, ALWAYS use a subagent with READ-ONLY access
(Glob, Grep, Read only). The review should ALWAYS check for:
- Security vulnerabilities
- Performance issues
- Adherence to project patterns in /docs/architecture.md

Return findings as a prioritized list with file:line references.

With the above CLAUDE.md file, every code review request automatically uses the defined pattern, eliminating the need to specify it each time.有了上述 CLAUDE.md 文件,每次代码审查请求都会自动使用定义好的模式,无需每次手动指定。

For more on CLAUDE.md files, see Customizing Claude Code for your codebase: setting up a CLAUDE.md file and our Claude Code CLAUDE.md file docs更多关于 CLAUDE.md 文件的信息,请参阅《为你的代码库定制 Claude Code:设置 CLAUDE.md 文件》以及我们的 Claude Code CLAUDE.md 文档。

Skills技能

For complex multi-step workflows that run repeatedly, skills provide a reusable interface. Define a skill once in .claude/skills/, then invoke it with /skill-name or let Claude load it automatically when a task matches its description.对于需要重复运行的复杂多步骤工作流,技能提供了可复用的接口。一次性在 .claude/skills/ 中定义技能,然后通过 /skill-name 调用,或让 Claude 在任务匹配其描述时自动加载。

Skills differ from CLAUDE.md files in scope. CLAUDE.md files are always loaded and shapes every interaction. A skill is loaded on demand, either because it was invoked explicitly or because Claude matched the current task to the skill's description field. That makes skills the right place for workflows that should be available but not applied to every prompt.技能与 CLAUDE.md 文件的作用范围不同。CLAUDE.md 文件始终加载并影响每一次交互。技能则按需加载,要么因为显式调用,要么因为 Claude 将当前任务匹配到技能的 description 字段。这使得技能成为那些需要可用但不应在每个提示中自动应用的工作流的理想位置。

Skills fit well when:技能适合的情形包括:

  • Certain actions get run regularly某些操作需要定期运行
  • Different team members need access to the same complex operation不同团队成员需要访问相同的复杂操作
  • Standardizing how certain tasks are performed across the team matters在团队内部统一执行特定任务的方式很重要

Here’s an example of a deep-review skill for comprehensive code review:以下是一个用于全面代码审查的 deep-review 技能示例:

# .claude/skills/deep-review/SKILL.md

---
name: deep-review
description: Comprehensive code review that checks security,
  performance, and style in parallel. Use when reviewing staged
  changes before a commit or PR.
---

Run three parallel subagent reviews on the staged changes:

1. Security review - check for vulnerabilities, injection risks,
   authentication issues, and sensitive data exposure
2. Performance review - check for N+1 queries, unnecessary iterations,
   memory leaks, and blocking operations
3. Style review - check for consistency with project patterns
   documented in /docs/style-guide.md

Synthesize findings into a single summary with priority-ranked issues.
Each issue should include the file, line number, and recommended fix.

In the code snippet above, /deep-review triggers a three-part subagent analysis on demand. Because the description mentions reviewing staged changes before commits, Claude can also reach for this skill automatically when that context comes up.在上面的代码片段中,/deep-review 会按需触发三部分子代理分析。因为 description 中提到在提交前审查已暂存的更改,Claude 也可以在相应上下文出现时自动调用此技能。

A skill is a directory, not a single file. Alongside SKILL.md, it can hold templates Claude fills in, example outputs showing the expected format, or scripts Claude executes as part of the workflow. The legacy .claude/commands/ format was a single flat file, so everything had to live in the prompt itself.技能是一个目录,而不是单个文件。除了 SKILL.md,它可以包含 Claude 填充的模板、示例输出(展示期望格式)或 Claude 在工作流中执行的脚本。旧的 .claude/commands/ 格式是单一平面文件,所有内容必须写在提示本身。

For more on using skills with Claude Code, see our Claude Code skills docs.更多关于在 Claude Code 中使用技能的信息,请参阅我们的 Claude Code 技能文档。

Hooks钩子

Hooks are user-defined shell commands, HTTP endpoints, or LLM prompts that execute automatically at specific points in Claude Code's lifecycle. Hooks can automate subagent workflows based on events. Hooks trigger on specific actions and run subagent tasks without manual invocation.钩子是用户自定义的 shell 命令、HTTP 端点或 LLM 提示,可在 Claude Code 生命周期的特定节点自动执行。钩子可以基于事件自动化子代理工作流。钩子在特定动作触发时运行子代理任务,无需手动调用。

Hooks are the right tool when:钩子适用的场景包括:

  • Every commit should be reviewed automatically before it's created每次提交都应在创建前自动审查
  • Security checks should run without anyone remembering to ask安全检查应在无人提醒的情况下运行
  • CI-like quality gates belong in the local development process类似 CI 的质量门应嵌入本地开发流程

Here is an example of a Stop hook that blocks Claude from ending its turn until a test is passed:以下是一个 Stop 钩子的示例,它会阻止 Claude 在测试通过前结束其回合:

{
  "hooks": {
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/check-tests.sh"
          }
        ]
      }
    ]
  }
}

And the script at .claude/hooks/check-tests.sh:以及位于 .claude/hooks/check-tests.sh 的脚本:

#!/bin/bash
INPUT=$(cat)
STOP_HOOK_ACTIVE=$(echo "$INPUT" | jq -r '.stop_hook_active // false')

# Don't loop forever — if we already blocked once this turn, let it through
if [ "$STOP_HOOK_ACTIVE" = "true" ]; then
  exit 0
fi

if ! npm test --silent > /dev/null 2>&1; then
  jq -n '{
    decision: "block",
    reason: "Tests are failing. Run `npm test` to see the failures and fix them before finishing."
  }'
  exit 0
fi

exit 0

When Claude finishes its turn, the Stop event fires. The script runs the test suite—if tests fail, it returns JSON with decision: "block" and a reason. Claude Code reads that, doesn't let Claude stop, and feeds the reason back into the conversation as instruction to keep working. The stop_hook_active guard at the top prevents infinite loops: if Claude is already continuing because of a previous stop-hook block, the script lets it exit.当 Claude 完成回合时,Stop 事件触发。脚本运行测试套件——如果测试失败,返回 JSON {"decision": "block", "reason": "..."}。Claude Code 读取该结果,阻止 Claude 停止,并将原因作为指令反馈回对话继续工作。脚本顶部的 stop_hook_active 保护防止无限循环:如果 Claude 已因之前的 stop‑hook 被阻止而继续,则脚本允许其退出。

Hooks represent the most automated approach to subagent orchestration. Conversational invocation or CLAUDE.md instructions are the better starting point; hooks come later, as workflows mature.钩子代表了子代理编排的最高自动化程度。对话式调用或 CLAUDE.md 指令是更好的起点;钩子则在工作流成熟后再引入。

For complete hooks configuration, see Claude Code power user customization: how to configure hooks or our Claude Code hooks docs.完整的钩子配置请参阅 Claude Code 高级用户自定义:如何配置钩子 或我们的 Claude Code 钩子文档。

Practical patterns for using subagents使用子代理的实用模式

The following patterns demonstrate subagent direction applied to common scenarios.以下模式展示了子代理在常见场景中的指引用法。

Research before implementing实现前的研究

When adding a feature to unfamiliar code, delegating research to a subagent first keeps the implementation discussion informed rather than exploratory, for example: 在不熟悉的代码库中添加功能时,先让子代理进行研究可以让实现讨论基于信息而非探索,例如:

Before I implement user notifications, use a subagent to research:
- How are emails currently sent in this codebase?
- What notification patterns already exist?
- Where should new notification logic live based on the current architecture?

Summarize findings, then we'll plan the implementation together.

A synthesized summary arrives instead of twenty files of raw context, and the implementation discussion starts from a solid foundation.合成的摘要代替二十个文件的原始上下文出现,实施讨论从坚实的基础开始。

Parallel modifications并行修改

When the same pattern needs updating across multiple files, parallel subagents finish faster and maintain focus, for example: 当同一模式需要在多个文件中更新时,并行子代理更快完成且保持专注,例如:

Use parallel subagents to update the error handling in these files:
- src/api/users.ts
- src/api/orders.ts
- src/api/products.ts

Each should follow the pattern established in src/api/auth.ts.
Work on all three simultaneously.

Three subagents working in parallel complete in roughly the time one would take. Each focuses on its file without context from the others creating confusion or inconsistency.三个子代理并行工作,大约只需单个子代理的时间。每个子代理专注于自己的文件,不会因其他上下文产生混乱或不一致。

Independent review独立审查

After implementing something complex, verification from a subagent that hasn't been influenced by the implementation journey catches what familiarity obscures, for example: 在实现复杂功能后,未受实现过程影响的子代理进行验证,可捕获熟悉代码时忽视的问题,例如:

Use a fresh subagent with read-only access to review my implementation of the payment flow. It should not see our previous discussion. I want an unbiased review.

Check for: security vulnerabilities, unhandled edge cases, and error handling gaps. Be critical.

The review subagent evaluates the code without knowing what tradeoffs were considered, what approaches were rejected, or what assumptions were made. This outside perspective surfaces issues the main conversation might miss.审查子代理在不知晓权衡、被拒方案或假设的情况下评估代码。这种外部视角会揭示主对话可能遗漏的问题。

Pipeline workflow流水线工作流

For multi-stage tasks, chaining subagents with explicit handoffs between phases keeps each stage focused, for example: 对于多阶段任务,使用显式交接的子代理链保持每个阶段的专注,例如:

Let's build this feature as a pipeline:

1. First subagent: Design the API contract and write it to docs/api-spec.md
2. Second subagent: Implement the backend endpoints based on that spec
3. Third subagent: Write integration tests for the implementation

Each stage should complete before the next begins. Use the output
files as the handoff mechanism between stages.

Using a pipeline workflow, each stage in the task receives focused context. The design subagent isn't distracted by implementation concerns, the implementation subagent works from a clean spec, and the testing subagent evaluates the result independently. 采用流水线工作流,每个阶段获得聚焦的上下文。设计子代理不受实现细节干扰,实现子代理从干净的规范开始,测试子代理独立评估结果。

When shouldn’t you use subagents? 何时不该使用子代理?

While subagents are a useful feature, subagents carry overhead. Each one spins up its own context, consumes tokens, and adds a layer of indirection between the developer and the work. They're worth that cost when context isolation, parallelism, or a fresh perspective actually helps. 虽然子代理是有用的功能,但它们也有开销。每个子代理都会启动自己的上下文,消耗 token,并在开发者与工作之间增加一层间接。只有在上下文隔离、并行或全新视角真正有帮助时才值得使用。

For smaller or tightly sequential tasks, sticking to the main conversation is usually simpler, for example: 对于较小或紧密顺序的任务,保持在主对话中通常更简单,例如:

  • Sequential, dependent work. When step two needs the full output of step one, and step three needs both, a single session handling the chain is usually cleaner than a relay of subagents passing state through files.顺序、相互依赖的工作。第二步需要第一步的完整输出,第三步需要前两步的结果,此时单一会话处理链路通常比子代理之间通过文件传递状态更清晰。
  • Same-file edits. Two subagents editing the same file in parallel is a recipe for conflict. In this scenario, keep tightly coupled changes in one context window.同文件编辑。两个子代理并行编辑同一文件会导致冲突。在这种情况下,应在同一上下文窗口内完成紧耦合的更改。
  • Small tasks. For a quick fix or a focused question, the overhead of delegation outweighs the benefit. Just prompt or ask in your main conversation.  小任务。对于快速修复或聚焦提问,委派的开销超过收益。直接在主对话中提示即可。
  • Too many specialist agents. It's tempting to define a custom subagent for everything, but flooding Claude with options makes automatic delegation less reliable. Most teams settle on a handful of well-scoped agents rather than a sprawling roster.过多的专员代理。为每件事都定义自定义子代理很诱人,但会让 Claude 的选项泛滥,降低自动委派的可靠性。大多数团队倾向于保留少数范围明确的代理,而不是庞大的名单。
  • Work that needs agents to coordinate with each other. Subagents report back to the main conversation but can't talk to one another. For tasks where subagents need to communicate, use agent teams. With agent teams, subagents coordinate across separate sessions rather than within one, which makes them heavier and more expensive. For more guidance on when to use subagents vs Agent Teams, check out our Claude Code agent teams docs.需要代理之间相互协作的工作。子代理只能向主对话报告,无法相互通信。若任务需要子代理之间交流,请使用代理团队。代理团队让子代理在独立会话间协作,代价更高且更昂贵。有关何时使用子代理 vs 代理团队的更多指导,请查看我们的 Claude Code 代理团队文档。

The signals described earlier (i.e., needing a second opinion, a lack of dependencies between sub-tasks, and extensive research) make it clear when delegation to a subagent is worth it.前文提到的信号(需要第二意见、子任务之间无依赖、需要大量研究)清晰表明何时委派给子代理是值得的。

Start conversational, automate later先对话,后自动化

Subagents deliver their full value when used deliberately. The automatic invocation Claude provides is helpful, but knowing when to delegate research, parallelize work, and request a fresh perspective produces better results than leaving it to chance.子代理在有意使用时才能发挥全部价值。Claude 提供的自动调用很有帮助,但了解何时委派研究、并行工作以及请求全新视角,能够比盲目依赖更好地获得结果。

When using subagents, start with conversational prompts. Notice which requests keep occurring and build automation as those patterns clarify. The goal is to make subagent delegation effortless, so your attention stays on the work that matters.使用子代理时,从对话提示开始。注意哪些请求频繁出现,并在模式明确后构建自动化。目标是让子代理委派变得轻松,从而让你的注意力专注于真正重要的工作。

No items found.
Prev
0/5
Next
eBook

No items found.
Or read the documentation或阅读 文档
Try Claude Code
Developer docs

Transform how your organization operates with Claude

See pricing
Contact sales

Get the developer newsletter

Product updates, how-tos, community spotlights, and more. Delivered monthly to your inbox.

Subscribe

Please provide your email address if you'd like to receive our monthly developer newsletter. You can unsubscribe at any time.

Thank you! You’re subscribed.
Sorry, there was a problem with your submission, please try again later.
Claude Code
Coding