Transcript of Creating a subagent
Claude
0:03In the previous video, we covered what0:05sub agents are and how they work. Claude0:08Code includes built-in sub agents, but0:10you can also create your own sub agents0:12that specialize in certain tasks. Custom0:14sub agents are markdown files with YAML0:17front matter. These markdown files0:18contain configuration that helps Claude0:20understand when to use a sub agent and0:22provides directions to the sub agent0:25itself.0:28Now, the easiest way to create a sub0:30agent is with the /agents command.0:34This panel is the main interface for0:36managing your sub agents. Once here,0:38select create new agent.0:40You'll then be asked if you want to0:41create a sub agent for the current0:43project or a sub agent that will be0:45shared between all of the projects on0:47your machine. Next, you can create a sub0:49agent manually, but we recommend using0:50Claude Code to automatically generate it0:52for you.0:53Our first sub agent will be a code0:55reviewer.0:56I'll ask Claude to make a sub agent that0:59reviews code quality and security1:01issues.1:04Claude will use your input to generate a1:06name, description, and system prompt for1:08the sub agent. We'll see those in a1:10moment, but before we do, we get the1:12opportunity to customize the tools that1:14this sub agent has access to. Now, given1:17that our sub agent is only responsible1:19for reviewing code, you might decide to1:21disallow tools for editing,1:23but I'll leave in execution to allow the1:25sub agent to more easily identify1:28pending changes.1:30Next, you'll be prompted to select the1:32model that powers the sub agent.1:34And finally, a color. This color is used1:37in the UI to help you better identify1:39the sub agent, and it also just adds a1:41little bit of personal flair. Now, at1:43the summary window, we see that the sub1:46agent config file will be saved into my1:48current project at this path. Now, let's1:51open up that file to get a better idea1:53of what's going on.1:56The name field is a unique identifier.1:58This is how you reference the sub agent2:00either by asking Claude directly or2:02using @agentcodereviewer2:05in your message.2:06The description controls when Claude2:07decides to use the sub agent. The2:10description must be on a single line.2:12Notice that there are escaped new line2:14characters in there. If you want Claude2:16to use the sub agent automatically more2:18often, add in the word proactively to2:21the description.2:22You can also add example conversations2:24to help Claude understand when it should2:26be using the sub agent.2:29The tools field lists which tools the2:31sub agent can access. The list of tools2:34will match the tools we granted access2:36to during the agent generation, but you2:38can further edit the list of tools in2:40this file if you want.2:42The model field specifies which Claude2:44model to use. Sonnet, Opus, Haiku, or2:47inherit. Use Haiku for fast tasks, Opus2:51for complex analysis, and Sonnet if you2:54need something between the two.2:56Inherit will use the same model as your2:57main conversation.2:59The body of the file contains the system3:01prompt that is given to the sub agent.3:03The system prompt will provide guidance3:05to the sub agent helping it understand3:07how to complete its tasks and how it3:09should return information back to the3:11main agent.3:15Now, for the fun part. After creating3:17your sub agent, test it by making some3:19code changes and asking Claude to review3:21them.3:29If the sub agent isn't being used when3:31you expect, check your description.3:33Adding more specific examples helps3:35Claude understand when to delegate.
601 words · 96 lines







