WEBVTT

00:00:00.080 --> 00:00:03.770
So this sub-agents feature is very useful,
but I

00:00:03.800 --> 00:00:07.260
mentioned that we have a problem here
when it comes to looking up

00:00:07.320 --> 00:00:11.020
documentation. These steps
are all done step after step on the

00:00:11.100 --> 00:00:14.490
main agent, and as you can imagine,
reading documentation

00:00:14.620 --> 00:00:18.500
articles, that's quite a lot of text
that goes into the main

00:00:18.640 --> 00:00:22.470
context window.
So not only does it take time, but

00:00:22.480 --> 00:00:25.290
it also pollutes the main context window.

00:00:25.360 --> 00:00:28.400
That's why it could make sense to build a
dedicated

00:00:28.410 --> 00:00:31.680
documentation explorer sub-agent.

00:00:31.700 --> 00:00:35.400
Now, it's also possible
that by the point of time you're watching

00:00:35.540 --> 00:00:39.380
agent is already built in.
It's a great example nonetheless,

00:00:39.460 --> 00:00:42.020
now, when I'm recording this, it's not.

00:00:42.100 --> 00:00:45.910
So how do you build your own agent? Well,
you can

00:00:45.980 --> 00:00:48.890
add a local agent for your project by
going to this

00:00:49.320 --> 00:00:52.170
.Claude folder and adding a agents

00:00:52.460 --> 00:00:55.449
sub-folder there. That name
is not up to you.

00:00:55.480 --> 00:00:59.460
It must be named agents.
And then I already prepared

00:00:59.500 --> 00:01:02.360
a docs explorer agent,
which you'll find attached.

00:01:02.420 --> 00:01:06.340
You can just paste it into this agents
folder.

00:01:06.350 --> 00:01:10.070
This name is up to you. It, of course,
should kind of describe this

00:01:10.120 --> 00:01:12.820
agent, and it must be a Markdown file.

00:01:12.840 --> 00:01:16.700
And in that file,
you then give this agent a name,

00:01:16.740 --> 00:01:20.100
same as the filename, DocsExplorer,
and you give it a description.

00:01:20.170 --> 00:01:24.080
This description will also be important
because it will give

00:01:24.120 --> 00:01:28.000
Claude Code some hints on
when to use this agent,

00:01:28.020 --> 00:01:30.920
so when to outsource tasks to this agent.

00:01:30.930 --> 00:01:34.640
So here I wanna make it clear
that this agent is there to look up

00:01:34.680 --> 00:01:36.660
libraries, frameworks, and so on.

00:01:36.700 --> 00:01:40.460
You then can give your agent tools,
and attached you'll find a link to the

00:01:40.500 --> 00:01:44.360
official documentation
that lists all the tools you can give to

00:01:44.460 --> 00:01:48.430
your Claude Code sub-agents. Actually,
there is one tool I wanna add, and

00:01:48.460 --> 00:01:52.240
that's the mcp-search tool.
This tool allows it to

00:01:52.280 --> 00:01:56.090
dynamically load MCP tools. You also

00:01:56.120 --> 00:02:00.010
define which model should be used for this
task, and

00:02:00.120 --> 00:02:03.950
here, right now when I'm recording this,
I could use Opus or

00:02:04.020 --> 00:02:07.030
Sonnet, and Sonnet
is simply a bit cheaper.

00:02:07.060 --> 00:02:10.960
And since exploring documentation
is not a super hard task, I

00:02:11.020 --> 00:02:14.859
don't need the smartest model,
I want the model that's fast and

00:02:14.920 --> 00:02:18.100
comparatively cheap.
That's why I'm using Sonnet here.

00:02:18.140 --> 00:02:22.070
Right now, when I'm recording this,
the available options are Sonnet, Opus, or

00:02:22.160 --> 00:02:23.980
Haiku, which would be the cheapest.

00:02:24.000 --> 00:02:26.680
We could probably use that,
but I'll use the one in the middle.

00:02:26.690 --> 00:02:29.940
And then you just describe to Claude Code

00:02:30.460 --> 00:02:34.049
how that sub-agent should work.
So you don't need to be technical here.

00:02:34.100 --> 00:02:37.920
Instead,
I described it as a documentation

00:02:38.020 --> 00:02:41.820
that it should work in parallel,
execute all

00:02:41.880 --> 00:02:45.860
lookups in parallel,
that it should use the Context7 MCP as a

00:02:45.920 --> 00:02:49.540
primary source,
that it should fall back to web search if

00:02:49.580 --> 00:02:52.800
Context7 doesn't work
or doesn't provide the information it

00:02:52.840 --> 00:02:56.180
needs.
I then have the information about the

00:02:56.220 --> 00:03:00.140
concrete Context7 tools it should use,
which I looked up in the

00:03:00.180 --> 00:03:03.940
Context7 documentation,
and I give it some information on how to

00:03:03.980 --> 00:03:07.049
search the web because many websites these
days have

00:03:07.180 --> 00:03:10.960
LLM-friendly pages, like a llms.txt file,
or they

00:03:10.980 --> 00:03:14.620
provide documentation as Markdown files,
and I tell it to

00:03:15.120 --> 00:03:18.720
look for these files, these URLs

00:03:18.800 --> 00:03:22.660
first,
and only if it doesn't find them should it

00:03:22.700 --> 00:03:24.530
and search for the normal website.

00:03:24.840 --> 00:03:28.100
So that is my documentation explorer
agent.

00:03:28.180 --> 00:03:31.620
It's stored locally here.
You could also store it

00:03:31.680 --> 00:03:35.620
globally. So in your root Claude folder,
in my

00:03:35.660 --> 00:03:39.390
case here on macOS under my username,
you can also add such a

00:03:39.520 --> 00:03:43.120
agents folder and add your agent here,
and then it would be available

00:03:43.200 --> 00:03:46.250
across all projects.
It's up to you what you need.

00:03:46.340 --> 00:03:49.970
With that done,
in a new Claude Code session, if I

00:03:50.000 --> 00:03:53.780
repeat this instruction,
it should hopefully use this docs

00:03:53.800 --> 00:03:57.450
explorer agent to look for the
documentation.

00:03:57.480 --> 00:04:00.560
But we can do better than hoping
