AI Learn
Anthropic · Claude Code Tutorial

Delegate a bounded investigation to Claude Code subagents

Split a large coding investigation into specialist subagents with narrow context, tools and deliverables, then integrate the findings in the main session.

Reviewed September 19, 2026Independent tutorialFeatures may vary
Not official support. AI Learn is an independent education site and is not affiliated with Anthropic. Check the provider’s current documentation for plan-specific limits, pricing and feature availability.
Before you start

Subagents are useful when independent investigations can run with focused context. They are not a reason to parallelize tightly coupled edits that all touch the same files.

1. Choose separable work

Good subagent jobs include tracing an error path, mapping test coverage, checking one subsystem or reviewing a dependency. Avoid vague “fix the whole app” delegation.

2. Give one deliverable

Ask each subagent for a compact artifact: relevant files, evidence, risks and a recommendation. Do not ask it to both investigate and rewrite half the repository unless necessary.

3. Restrict tools and context

Give only the tools, folders or commands needed for that specialist role. Smaller context reduces distraction and makes the result easier to audit.

4. Let the main session synthesize

Bring findings back to the parent session. Resolve contradictions there, decide the actual change plan and keep one source of truth for the implementation.

5. Verify before acting

Open the files and commands cited by the subagent. Treat its output as an investigation report, not as automatically trusted ground truth.

Try this prompt

Delegate this investigation to one specialist subagent. Scope: [subsystem]. Do not edit files. Return only: likely root cause, evidence with file paths/lines, tests that cover it, and the smallest recommended next step.

Common mistakes

Creating subagents for every tiny task; letting several agents edit the same files independently; accepting a subagent conclusion without evidence; delegating security-sensitive access too broadly.

Finish check

The parent session receives focused, evidence-backed findings that reduce uncertainty without introducing uncontrolled edits.

开始之前

当多个调查可以独立进行、每个都只需要聚焦上下文时,Subagents 很有价值;如果多个任务高度耦合并同时修改同一批文件,盲目并行反而更乱。

1. 选择真正可拆分的工作

适合子智能体的任务包括追踪错误路径、盘点测试覆盖、检查一个子系统或审查某个依赖。不要把“修好整个应用”这种模糊目标直接甩给子智能体。

2. 每个子智能体只交付一个明确成果

要求它输出相关文件、证据、风险和建议等紧凑结果。除非必要,不要同时让它调查问题又大范围重写仓库。

3. 缩小工具和上下文

只给这个专业角色所需的工具、目录和命令。上下文越聚焦,干扰越少,结果也更容易审计。

4. 由主会话统一综合

把各子智能体的发现带回主会话,在这里解决冲突、决定最终修改方案,并保持一个统一的实现来源。

5. 行动前再次核验

打开子智能体引用的文件和命令。把它的输出当作调查报告,而不是自动可信的事实。

可以直接套用的提示词

把这项调查交给一个专业子智能体。范围:【子系统】。不要修改文件,只返回:最可能根因、带文件路径/行号的证据、覆盖它的测试、以及最小的下一步建议。

常见错误

每个小任务都创建子智能体;让多个智能体独立修改同一批文件;没有证据就接受子智能体结论;给调查型子智能体过宽的敏感访问权限。

完成检查

完成后,主会话得到聚焦且有证据的调查结果,显著减少不确定性,同时没有产生失控修改。

開始之前

當多個調查可以獨立進行、每個都只需要聚焦上下文時,Subagents 很有價值;如果多個任務高度耦合併同時修改同一批檔案,盲目並行反而更亂。

1. 選擇真正可拆分的工作

適合子智能體的任務包括追蹤錯誤路徑、盤點測試覆蓋、檢查一個子系統或審查某個依賴。不要把“修好整個應用”這種模糊目標直接甩給子智能體。

2. 每個子智能體只交付一個明確成果

要求它輸出相關檔案、證據、風險和建議等緊湊結果。除非必要,不要同時讓它調查問題又大範圍重寫倉庫。

3. 縮小工具和上下文

只給這個專業角色所需的工具、目錄和指令。上下文越聚焦,干擾越少,結果也更容易審計。

4. 由主會話統一綜合

把各子智能體的發現帶回主會話,在這裡解決衝突、決定最終修改方案,並保持一個統一的實現來源。

5. 行動前再次核對

打開子智能體引用的檔案和指令。把它的輸出當作調查報告,而不是自動可信的事實。

可以直接套用的提示詞

把這項調查交給一個專業子智能體。範圍:【子系統】。不要修改檔案,只返回:最可能根因、帶檔案路徑/行號的證據、覆蓋它的測試、以及最小的下一步建議。

常見錯誤

每個小任務都創建子智能體;讓多個智能體獨立修改同一批檔案;沒有證據就接受子智能體結論;給調查型子智能體過寬的敏感訪問權限。

完成檢查

完成後,主會話得到聚焦且有證據的調查結果,顯著減少不確定性,同時沒有產生失控修改。

Official references

Check current product details at the source

Related practical tutorials

Continue with another single-task workflow.

All tutorials →