Mastering Claude's New Custom Sub-Agents for Advanced AI Workflows
Anthropic has recently unveiled a groundbreaking new feature for Claude, known as custom sub-agents. While it has always been possible to run multiple sub-agents, the level of control over their execution was limited. This latest update introduces the ability to configure them for highly specific tasks, assign them unique names, restrict their access to certain tools, and even customize their appearance with a unique color. Let's explore several examples of how this works in practice.
Getting Started: Prerequisites
It's important to note that support for custom sub-agents is exclusively available in version 1.0.60. Ensure you have this version installed to access the new agents
command. Upon execution, you will see the default general-purpose agent, which is always available. Initially, no custom agents will be present.
Creating Your First Custom Agent
Let's proceed with creating one. We will set its scope to the personal level, making it accessible across all projects. Next, we'll use the generate with Claude
option. This feature assists in generating the necessary Markdown configuration file for the agent; our only task is to provide a clear description.
For this demonstration, the description will be:
senior software engineer expert at fine grained detail and logic when it comes to reviewing code for quality security and best practices
After confirming, Claude proceeds to generate the agent's configuration file. Once this process is complete, we can select the specific tools we want our agent to access, with the option to view individual tool details. Given that this agent's purpose is code review, its access will be restricted to read-only tools to ensure safety and prevent unintended modifications. A complete list of the accessible tools is displayed for confirmation.
Note: A particularly powerful aspect of this feature is the ability to create an agent with access to a curated set of specific MCP tools.
After continuing, we can assign a color for easy identification. The system then displays the Claude-generated agent name, the comprehensive list of its tool access, its description, and the system prompt. Upon final confirmation, the new custom agent appears in our list. From here, we can review the agent's full details, including its description, color, and system prompt.
The configuration is fully modifiable to suit specific needs. Furthermore, these custom agents can be shared with the community on platforms like GitHub, hinting at a future where a repository of 'awesome' Claude sub-agents might become available. For now, we will proceed with the current configuration.
Putting the Agent to Work
To utilize this newly created agent, we will write a prompt specifically instructing it to review the security of a particular file. We can observe that Claude correctly selects our custom sub-agent for the task. After a short processing period, the task is complete. The results indicate the process took slightly more than a minute, consumed over 20,000 tokens, and produced a comprehensive security review of the specified file.
It is documented that Claude can automatically select the most appropriate sub-agent based on the task, though this automatic selection has not been observed in this specific instance.
Advanced Use Case: Orchestrating Multiple Sub-Agents
Let's explore a more complex scenario involving multiple custom sub-agents. We have configured a list of over 10 custom sub-agents, plus the general-purpose one. Several of these are based on the example agents provided in the official documentation. The goal is to trigger as many of these specialized agents as possible within a single, complex prompt.
The prompt will be as follows:
Check the code quality, performance, error handling, and metrics of all the code in the components directory. Then refactor, write tests, and write documentation for all the code using sub aents.
Let's observe the outcome. Claude responds by generating a to-do list, intelligently mapping each task to a specific sub-agent. It begins with the 'code quality' sub-agent, which completes its task in about a minute. Following that, it invokes the 'performance optimizer.' The process continues by assigning agents sequentially. It's worth noting that parallel agent execution is a known capability, though the reason for its sequential execution in this particular case is unclear.
Approximately one hour and 500,000 tokens later, the entire workflow is complete. The output includes a detailed quality code analysis, performance analysis, error handling review, and metrics monitoring. The codebase has been significantly improved with the addition of comments, comprehensive tests, and generated API documentation.
Important Considerations
A critical point to remember is that each sub-agent operates within its own context window, starting with a clean slate upon each invocation. This design choice can impact performance, as agents may need to repeatedly gather context to perform their duties effectively. For more in-depth information, refer to the official documentation.
Final Thoughts
Custom sub-agents are an exceptionally powerful feature. Personally, my day-to-day tasks with Claude may not always require such hyper-specialized agents. However, it is commendable to see Anthropic continuously innovating and pushing the boundaries of what Claude can achieve.