Transcript of Designing effective subagents
Claude
0:03Now that you know how to create sub0:04agents, let's look at patterns that lead0:06to effective sub agents.0:10First, let's get a better idea of how0:12some of the data in the sub agent config0:14file is used.0:17Whenever you send a message to the main0:18context window agent, the name and0:20description of each sub agent is0:22included in the system prompt. So, if0:24you want to better control when the main0:26agent launches a sub agent0:27automatically, you should modify the0:30name description.0:31Next, remember that when a sub agent is0:33launched, the main agent writes an input0:36prompt. When writing this input prompt,0:38it uses the description as guidance. So,0:41if you want to better control when the0:42main agent launches a sub agent0:44automatically,0:45you should modify the name and0:47description.0:49Let's consider our review sub agent0:51again. Right now, when the main agent0:53runs the sub agent, the sub agent is0:55given an input prompt telling it to use0:57get diff to find the current changes.1:01If we wanted the main agent to more1:03reliably tell the sub agent exactly1:04which files to review, we would update1:07the description.1:09You must tell the agent precisely which1:11files you want it to review.1:15Now, if we ask Claude to run the code1:17reviewer agent, we'll see a different1:19input.1:24You can also influence what the main1:25thread tells a sub agent through the1:27description.1:28So, adding return sources that can be1:31cited to a web search sub agent's1:32description causes the main thread to1:35include that instruction when delegating1:37the task.1:41The most important improvement that you1:43can make is defining an output format in1:45the system prompt.1:46This creates natural stopping points for1:48the sub agent. Without a defined output1:51format, sub agents struggle to decide1:54when enough research has been done and1:56they tend to run much much longer than1:59sub agents that are given an output2:00format.2:04When a sub agent discovers a workaround2:06to some issue like solving a dependency2:09issue or finding that a certain command2:13needs particular flags, these details2:15should appear in the summary.2:17Otherwise, the main thread has to2:19rediscover the same solutions. Obstacles2:21encountered, any setup issues,2:23workarounds discovered, or environment2:25quirks, commands that needed special2:27flags or configuration, dependencies or2:30imports that cause problems.2:35Explicitly asking for obstacle reporting2:37in the output format surfaces this2:39information.2:42A read-only sub agent using just glob,2:45grep, read cannot accidentally modify2:48files.2:49This constraint clarifies that the sub2:51agent's role and prevents unintended2:53side effects.2:55So, think about what sub agents actually2:57needs to do.2:59If it's just researching, it only needs3:01to read files, so keep it read-only.3:03That way it can't accidentally modify3:05anything while exploring.3:07A reviewer needs to run get diff to see3:09what changed, so give it bash access,3:11but it still doesn't need to edit files.3:14Only give edit and write to sub agents3:16that should actually change your code3:17like a styling agent applying CSS3:19updates. This also helps clarify what3:21each sub agent is for when you have3:24several of them.3:27So, effective sub agents use structured3:30output, report obstacles, have specific3:33descriptions, and limit tool access.
537 words · 94 lines







