https://simonwillison.net/atom/everything 10月12日
Claude Code 子代理功能详解
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文详细介绍了 Claude Code 的子代理功能,通过实例展示了如何触发子代理执行任务,并展示了子代理在文档编写中的应用。

Claude Code includes the ability to run sub-agents, where a separate agent loop with a fresh token context is dispatched to achieve a goal and report back when it's done. I wrote a bit about how these work in June when I traced Claude Code's activity by intercepting its API calls.

I recently learned that you can deliberately trigger Claude Code to use sub-agents just by telling it to do so!

Here's an example. I ran this using Claude Code against a fresh checkout of simonw/datasette (commit ec38ad37689f3c14d307770977a17aed5efc5cb9), with no additional custom instructions:

Write markdown documentation for the context passed to each of the templates in this project. Use sub-agents.

Here's a snippet of the output:

⏺ I'll help you write markdown documentation for the context passed to each template in this project. Let me start by exploring the codebase to understand the template structure and then use sub-agents to document them comprehensively.

⏺ Search(pattern: "**/*.html")  ⎿  Found 47 files (ctrl+o to expand)⏺ Search(pattern: "render.*template|render_template")  ⎿  Found 16 files (ctrl+o to expand)

[...]

⏺ Now let me launch sub-agents to analyze different template contexts in parallel:

⏺ Task(Document index template context)  ⎿  Done (12 tool uses · 86.4k tokens · 1m 13s)⏺ Task(Document database template context)  ⎿  Done (15 tool uses · 55.4k tokens · 1m 41s)⏺ Task(Document table template context)  ⎿  Done (14 tool uses · 85.2k tokens · 1m 44s)⏺ Task(Document query/row template contexts)  ⎿  Done (17 tool uses · 78.7k tokens · 1m 55s)⏺ Task(Document special template contexts)  ⎿  Done (26 tool uses · 116.1k tokens · 1m 50s)

It churned away for a couple of minutes (those sub-agents execute in parallel, another benefit of this pattern) and made me this template_contexts.md markdown file. It's very comprehensive.

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

Claude Code 子代理 文档编写
相关文章