WEBVTT

00:00:00.080 --> 00:00:03.860
So we added a subagent,
and because of the description we added

00:00:03.880 --> 00:00:07.860
there, there are high chances
that Cloud Code will use it whenever it

00:00:07.900 --> 00:00:10.600
look up documentation.
But we can do better than hoping.

00:00:11.380 --> 00:00:15.300
Remember that Cloud MD file?
I mentioned that it would be loaded into

00:00:15.400 --> 00:00:19.180
every new Cloud Code session,
and therefore, we can add

00:00:19.280 --> 00:00:21.060
very specific instructions here.

00:00:21.120 --> 00:00:24.580
So instead of hoping,
we can add this instruction to the Cloud

00:00:24.620 --> 00:00:28.400
file.
"Whenever working with any third-party

00:00:28.500 --> 00:00:32.320
similar,
you must look up the official

00:00:32.360 --> 00:00:34.240
working with up-to-date information.

00:00:34.360 --> 00:00:37.780
Use the Docs Explorer subagent for
efficient documentation

00:00:37.840 --> 00:00:41.730
lookup." By adding this here,
we don't need to add it into

00:00:41.740 --> 00:00:45.629
our prompts and we have almost 100%
certainty that this

00:00:45.629 --> 00:00:49.440
subagent will be used and
that Cloud Code will do documentation

00:00:50.380 --> 00:00:54.120
So now we can send a prompt like this,
and it should

00:00:54.200 --> 00:00:57.960
automatically spin up that subagent,
that Docs Explorer

00:00:58.040 --> 00:01:01.840
subagent to look up the documentation of
BetterAuth and so

00:01:01.980 --> 00:01:05.820
on.
So here it's spinning up the explorer

00:01:05.860 --> 00:01:09.780
code base, but also the Docs Explorer,
actually multiple instances of the Docs

00:01:09.820 --> 00:01:13.160
Explorer, to explore the BetterAuth

00:01:13.180 --> 00:01:16.330
documentation and the bun-sql-lite
documentation, which is

00:01:16.440 --> 00:01:19.380
100% correct for the kind of task I gave
it.

00:01:19.420 --> 00:01:22.960
Now it's asking for permission to do web
search and so on, and yeah, I granted

00:01:23.020 --> 00:01:26.880
that.
But with that we now have multiple agents

00:01:26.960 --> 00:01:30.880
in parallel for efficient work
and also for

00:01:30.960 --> 00:01:34.390
avoiding a pollution of the main context
window.

00:01:34.400 --> 00:01:38.250
And that is a great use case for a custom
subagent that

00:01:38.280 --> 00:01:42.140
makes a lot of sense
and how to efficiently use

00:01:42.180 --> 00:01:45.730
a subagent.
So compared to the last time you now see

00:01:45.780 --> 00:01:49.680
it did not perform any research tasks in
the main agent, but

00:01:49.720 --> 00:01:53.580
instead outsourced all of
that to subagents,

00:01:53.640 --> 00:01:57.280
main files in the main agent
or the important files that were

00:01:57.320 --> 00:02:01.140
delivered by the explorer agent in the
main agent and

00:02:01.180 --> 00:02:04.860
gives me a summary, which of course
is the same summary as before, but now

00:02:04.940 --> 00:02:08.880
implemented with help of a subagent
that will automatically be used now

00:02:08.940 --> 00:02:11.400
whenever we work with a third-party
library.

00:02:11.440 --> 00:02:15.130
At least that's the plan.
Now actually here for me in this

00:02:15.140 --> 00:02:18.820
project where I just wanted to use this as
a demo, this extra review

00:02:19.000 --> 00:02:22.160
did find something that must be improved.

00:02:22.240 --> 00:02:26.180
This next cookies plugin must be used in
this auth.ts

00:02:26.280 --> 00:02:30.120
file here because indeed BetterAuth,
the authentication library

00:02:30.380 --> 00:02:33.920
I want to use here in this demo project,
does have

00:02:34.580 --> 00:02:38.540
an official Next.js integration guide,
and Next.js is the framework

00:02:38.660 --> 00:02:42.320
I'm using. And in there it has two main

00:02:42.380 --> 00:02:46.300
things you must do. For one,
when setting up those API

00:02:46.380 --> 00:02:49.950
routes, you must use to_nextjs_handler
and that is something

00:02:50.180 --> 00:02:53.540
Cloud Code did set up for me here in
that file,

00:02:53.580 --> 00:02:57.390
but in order to then later properly work
with

00:02:57.600 --> 00:03:00.780
BetterAuth, we also must add this

00:03:00.900 --> 00:03:04.520
next-cookies plugin here to the auth setup
and the

00:03:04.600 --> 00:03:08.590
auth.ts file. And that indeed
is missing here and

00:03:08.640 --> 00:03:12.440
was identified by my review here.
So I can actually now tell Cloud

00:03:12.520 --> 00:03:15.600
Code to fix that next-cookies issue
and don't do anything else.

00:03:15.720 --> 00:03:19.080
Of course we could also do
that manually though.

00:03:19.140 --> 00:03:22.560
So if we want to save those tokens,
we can also just go

00:03:22.680 --> 00:03:26.600
to this BetterAuth setup according to
their docs

00:03:27.060 --> 00:03:30.920
and add plugins, import next-cookies
and call

00:03:30.960 --> 00:03:33.630
nextCookies as a function there like this.

00:03:33.680 --> 00:03:37.660
That's of course the cheaper way,
but we could have also told Cloud Code to

00:03:37.720 --> 00:03:38.360
that.
