WEBVTT

00:00:00.500 --> 00:00:04.160
So Agent mode is the default mode that's
typically

00:00:04.200 --> 00:00:07.330
selected when you open a new chat,
at least at the point of time where I'm

00:00:07.360 --> 00:00:11.340
recording this. And Agent mode
is basically an enhanced version of the

00:00:11.380 --> 00:00:15.340
mode because in this mode,
it'll not just analyze your code

00:00:15.380 --> 00:00:18.780
and answer questions, but instead,
it will also

00:00:18.880 --> 00:00:22.720
actively edit your code.
You can always revert those changes and

00:00:22.760 --> 00:00:26.720
you'll see in detail what was changed,
but it will make

00:00:26.780 --> 00:00:30.700
changes.
So if I open a new chat by clicking the

00:00:30.740 --> 00:00:34.580
plus here or using the shortcut,
and I say analyze

00:00:34.620 --> 00:00:38.050
this demo.py file and identify

00:00:38.300 --> 00:00:42.050
potential improvements, despite my

00:00:42.200 --> 00:00:45.980
prompt,
it will actually not just identify

00:00:46.080 --> 00:00:49.800
also try to implement them because that's
implied if you're in Agent

00:00:49.880 --> 00:00:52.980
mode,
that you wanna make changes to your code.

00:00:52.990 --> 00:00:56.040
And of course,
I could have therefore also worded this

00:00:56.140 --> 00:00:58.610
about my intent and say,
"Analyze this demo file,

00:00:58.640 --> 00:01:02.300
identify potential improvements, and

00:01:02.520 --> 00:01:05.459
implement those improvements."
But that's technically not needed.

00:01:05.580 --> 00:01:08.840
You just still might wanna do this to be
very sure that it will

00:01:08.960 --> 00:01:12.780
actually edit your code. You

00:01:12.840 --> 00:01:16.690
could also include more detailed
instructions like, "Keep the

00:01:16.880 --> 00:01:20.360
overall code clean and simple and avoid

00:01:20.620 --> 00:01:24.300
unnecessary abstractions." Because
depending on your

00:01:24.340 --> 00:01:28.140
project and the kind of change you're
requesting, the AI might wander

00:01:28.220 --> 00:01:32.100
off and come up with unnecessary complex
solutions, so

00:01:32.120 --> 00:01:35.720
adding extra instructions
or constraints like this can make sense.

00:01:35.740 --> 00:01:38.580
But I'll get back to my cursor prompting
guide a little bit later

00:01:38.640 --> 00:01:41.740
anyways. So for now, I'll just hit enter.

00:01:41.800 --> 00:01:45.100
Again,
it'll find this file because it knows

00:01:45.140 --> 00:01:48.910
It analyzes this file, it reads it,
it then thinks about it,

00:01:48.940 --> 00:01:52.900
and then it goes ahead, makes a plan,
and will then also

00:01:52.980 --> 00:01:56.840
edit the code. So here we go.
It's now editing demo.py as you

00:01:56.860 --> 00:02:00.680
can see here. And then once it's done,
if I shrink

00:02:00.800 --> 00:02:03.720
that, well, it's not fully done yet.
Now it's done.

00:02:03.760 --> 00:02:07.580
It gives me a summary here telling me what
it did, so which

00:02:07.640 --> 00:02:10.460
improvements were implemented through
which I can read.

00:02:10.650 --> 00:02:14.300
But as you see here in the code file,
there's a lot of red and

00:02:14.380 --> 00:02:18.120
green here because it will actually show
you what was

00:02:18.160 --> 00:02:21.900
removed, this code was removed,
for example, and what was

00:02:22.000 --> 00:02:25.200
added. So in this case, it removed the old

00:02:25.240 --> 00:02:29.030
function and replaced it with a new one
that has a

00:02:29.100 --> 00:02:32.780
comment here and
that most importantly has error

00:02:32.920 --> 00:02:36.260
handling, handling file-related errors.

00:02:36.269 --> 00:02:39.340
And it added something like this to all
these functions.

00:02:39.360 --> 00:02:43.240
It also added a main function then to give
me a nice menu

00:02:43.300 --> 00:02:46.620
which allows me to choose
which option I wanna go for, write,

00:02:46.660 --> 00:02:50.420
append,
and edit the code for executing this main

00:02:50.500 --> 00:02:54.440
execute this file.
And what you can do now in this mode

00:02:54.480 --> 00:02:58.260
go through these changes either by
scrolling or by clicking

00:02:58.280 --> 00:03:02.000
these arrows here.
That will get you to the right

00:03:02.040 --> 00:03:06.000
place. And then for each change,
you can undo it or

00:03:06.240 --> 00:03:07.940
keep it, depending on what you wanna do.

00:03:08.020 --> 00:03:11.780
Or you can keep them all or undo them

00:03:11.800 --> 00:03:15.780
all. You can also make edits here. So
if I want to add

00:03:15.820 --> 00:03:19.600
a third parameter here, like the mode,
which by default should be

00:03:19.820 --> 00:03:21.740
W for write, for example, I can do that.

00:03:21.760 --> 00:03:25.460
You can edit this and
if you would click keep now, your

00:03:25.560 --> 00:03:29.380
edit is also kept. So you can make edits

00:03:29.460 --> 00:03:33.360
to these suggested changes.
You don't just have to either accept or

00:03:33.380 --> 00:03:36.230
reject them, you can tweak them as well.

00:03:36.280 --> 00:03:38.690
That's very important
and that's something many people miss.

00:03:39.480 --> 00:03:43.080
Now here I'll get rid of the mode,
therefore this brings me back into this

00:03:43.140 --> 00:03:46.520
mode, but I'll still keep this.
Now this adjusted

00:03:46.680 --> 00:03:50.560
originally suggested version.
But I don't wanna do this for all these

00:03:50.640 --> 00:03:54.440
blocks.
I'm happy with the overall changes,

00:03:54.520 --> 00:03:58.200
here or also here. Keep

00:03:58.280 --> 00:04:02.120
all, undo all. The difference is
that certain

00:04:02.180 --> 00:04:05.780
changes might affect multiple files.

00:04:05.840 --> 00:04:09.670
Here, it's all just in one file,
but later we'll see examples

00:04:09.720 --> 00:04:13.380
with multiple files
and then here you would be undoing or

00:04:13.440 --> 00:04:16.630
accepting for that one file in
which you currently are.

00:04:16.660 --> 00:04:20.540
Whereas here on the right,
you always undo or accept changes for

00:04:20.660 --> 00:04:23.980
all the files that were added.
But here it's only one file, so it's the

00:04:24.040 --> 00:04:27.940
same. Therefore,
I'll accept all the changes for all files

00:04:27.980 --> 00:04:31.780
clicking this button over here.
