So this sub-agents feature is very useful, but I
mentioned that we have a problem here when it comes to looking up
documentation. These steps are all done step after step on the
main agent, and as you can imagine, reading documentation
articles, that's quite a lot of text that goes into the main
context window. So not only does it take time, but
it also pollutes the main context window.
That's why it could make sense to build a dedicated
documentation explorer sub-agent.
Now, it's also possible that by the point of time you're watching
agent is already built in. It's a great example nonetheless,
now, when I'm recording this, it's not.
So how do you build your own agent? Well, you can
add a local agent for your project by going to this
.Claude folder and adding a agents
sub-folder there. That name is not up to you.
It must be named agents. And then I already prepared
a docs explorer agent, which you'll find attached.
You can just paste it into this agents folder.
This name is up to you. It, of course, should kind of describe this
agent, and it must be a Markdown file.
And in that file, you then give this agent a name,
same as the filename, DocsExplorer, and you give it a description.
This description will also be important because it will give
Claude Code some hints on when to use this agent,
so when to outsource tasks to this agent.
So here I wanna make it clear that this agent is there to look up
libraries, frameworks, and so on.
You then can give your agent tools, and attached you'll find a link to the
official documentation that lists all the tools you can give to
your Claude Code sub-agents. Actually, there is one tool I wanna add, and
that's the mcp-search tool. This tool allows it to
dynamically load MCP tools. You also
define which model should be used for this task, and
here, right now when I'm recording this, I could use Opus or
Sonnet, and Sonnet is simply a bit cheaper.
And since exploring documentation is not a super hard task, I
don't need the smartest model, I want the model that's fast and
comparatively cheap. That's why I'm using Sonnet here.
Right now, when I'm recording this, the available options are Sonnet, Opus, or
Haiku, which would be the cheapest.
We could probably use that, but I'll use the one in the middle.
And then you just describe to Claude Code
how that sub-agent should work. So you don't need to be technical here.
Instead, I described it as a documentation
that it should work in parallel, execute all
lookups in parallel, that it should use the Context7 MCP as a
primary source, that it should fall back to web search if
Context7 doesn't work or doesn't provide the information it
needs. I then have the information about the
concrete Context7 tools it should use, which I looked up in the
Context7 documentation, and I give it some information on how to
search the web because many websites these days have
LLM-friendly pages, like a llms.txt file, or they
provide documentation as Markdown files, and I tell it to
look for these files, these URLs
first, and only if it doesn't find them should it
and search for the normal website.
So that is my documentation explorer agent.
It's stored locally here. You could also store it
globally. So in your root Claude folder, in my
case here on macOS under my username, you can also add such a
agents folder and add your agent here, and then it would be available
across all projects. It's up to you what you need.
With that done, in a new Claude Code session, if I
repeat this instruction, it should hopefully use this docs
explorer agent to look for the documentation.
But we can do better than hoping