WEBVTT

00:02.000 --> 00:07.560
So far, we have controlled the behavior of the eye through the different prompts that we have provided,

00:07.560 --> 00:12.680
and also through the specification that we have written inside our repository.

00:12.880 --> 00:18.840
There's also another way that is much more effective to ensure that the output that we're getting from

00:18.840 --> 00:21.320
the eye matches what we expect.

00:21.600 --> 00:24.360
And this particular feature is called rules.

00:24.520 --> 00:29.240
So through rules we can better control how the eye behaves.

00:29.520 --> 00:34.600
And cursor allows us to use project specific but also global rules.

00:34.800 --> 00:41.240
Now personally I like to use project specific rules even if there's a bit of duplication between various

00:41.240 --> 00:41.960
projects.

00:42.280 --> 00:47.960
I just like project rules because it is just related to a specific project, and I don't want to get

00:48.000 --> 00:50.960
a behavior that I don't want from somewhere else.

00:51.280 --> 00:53.840
So when does it make sense to have rules?

00:53.880 --> 01:00.000
Well, for example, earlier we have noticed that after we're making some changes, the agent doesn't

01:00.000 --> 01:02.480
automatically run the end to end tests.

01:02.600 --> 01:09.080
So for example, we can have some testing rules saying hey, after you make a change, also test on

01:09.080 --> 01:10.120
your own data.

01:10.320 --> 01:11.520
Tests are passing.

01:11.720 --> 01:15.680
Just ensure that you haven't broken any functionality by making this change.

01:15.680 --> 01:19.840
So this saves us the additional prompt of manually telling the AI.

01:20.080 --> 01:23.960
Hey, also, run this test to make sure that you haven't broken anything.

01:24.000 --> 01:24.520
All right.

01:25.200 --> 01:29.280
So if you want to set up project rules, that is relatively simple.

01:29.520 --> 01:33.520
All we need to do is to open the command palette.

01:33.520 --> 01:36.560
And this is slightly different depending on the operating system.

01:36.920 --> 01:39.840
And then add a new cursor rule.

01:40.480 --> 01:42.080
So let's jump into cursor.

01:42.400 --> 01:49.160
And what we're going to do here depending on the operating system I'm going to press Ctrl shift plus

01:49.200 --> 01:52.280
P or command shift plus P.

01:52.280 --> 01:54.120
And this should open the command palette.

01:55.000 --> 01:56.920
We need to be here inside cursor.

01:57.320 --> 01:58.480
Let's do exactly that.

01:59.040 --> 02:04.920
And what we need to do is right here cursor and rule.

02:05.400 --> 02:11.040
And we're going to find here something which is called new cursor rule is relatively nice.

02:11.040 --> 02:14.040
And then we need to specify a rule name.

02:14.240 --> 02:17.470
So let's go ahead and hold this testing, for example.

02:18.470 --> 02:20.670
And what exactly is happening here?

02:20.750 --> 02:25.710
Well, cursor has automatically created a directory dot cursor.

02:26.150 --> 02:29.310
And inside that directory there's another directory called rules.

02:29.630 --> 02:33.670
And inside there we're going to have this testing dot file.

02:33.830 --> 02:36.270
So this is a cursor specific file.

02:36.270 --> 02:41.790
It's pretty much marked down for cursor and does have a few interesting parts here.

02:41.790 --> 02:43.550
So it says here rule type.

02:43.590 --> 02:47.150
Also this rule is always attached to every chat.

02:47.430 --> 02:49.150
So this is exactly what we want.

02:49.230 --> 02:55.030
And we can also go ahead and put here our own content, which you're going to find also as a resource

02:55.030 --> 02:55.910
to this lecture.

02:56.150 --> 02:59.190
So we're going to say here okay this is regards to testing.

02:59.750 --> 03:01.110
This is going to be the header.

03:01.470 --> 03:03.390
And then we're going to have here two rules.

03:03.390 --> 03:10.830
For example first rule is going to be once you are done making changes to the code base run all tests

03:10.830 --> 03:11.830
to ensure they pass.

03:11.830 --> 03:13.950
So this is something sensitive.

03:14.590 --> 03:22.030
But apart from this we also want to proactively ask the user if after making some changes, we want

03:22.070 --> 03:25.470
to create additional tests to cover that particular functionality.

03:25.990 --> 03:28.430
So this is now covered in terms of testing.

03:28.430 --> 03:30.950
So we can take a look at exactly what we can do.

03:30.990 --> 03:33.190
We're going to do here a small change.

03:33.310 --> 03:37.310
So we can see here from the home page remove the word welcome.

03:38.990 --> 03:43.430
So now unfortunately we're going to see that these rules have not taken effect.

03:44.270 --> 03:46.670
We need to investigate why that is the case.

03:46.670 --> 03:50.510
We can go again and ask did you use the rules.

03:51.750 --> 03:53.390
And let's see what is coming back.

03:54.630 --> 04:01.630
So they are saying here I ran the test to ensure that they have passed, not seeing this explicitly.

04:01.630 --> 04:08.150
So it says here I didn't explicitly run the test immediately afterwards as it was a minor text removal.

04:08.510 --> 04:15.350
So it has kind of like figured out, okay, this is not going to break any tests, but it does confirm

04:15.350 --> 04:17.070
that it has followed the rules.

04:17.070 --> 04:20.670
So it's an indication that those rules have been included.

04:21.030 --> 04:25.390
Now there are many, many other rules that we can add here.

04:25.390 --> 04:28.230
So this is not just about testing.

04:28.630 --> 04:35.180
We can see here generally speaking, like example use cases, we may have some framework specific rules.

04:35.540 --> 04:41.940
In general it's about how the code is written, the code style we have, any architectural preferences,

04:41.940 --> 04:42.780
and so on.

04:43.140 --> 04:47.260
And there are a lot of projects which are sharing rules.

04:47.260 --> 04:52.060
For example, here as a resource of this lecture we're going to find cursor dot directory.

04:52.060 --> 04:55.740
It's a very nice website right here on top it has rules.

04:55.740 --> 04:59.220
If you click here on rules you're going to find here rules for TypeScript.

04:59.260 --> 05:02.140
You're going to find here rules for various programs.

05:02.140 --> 05:04.780
So we have here react or we have TypeScript.

05:04.780 --> 05:08.100
So there are a lot of rules that can be added here.

05:08.900 --> 05:11.060
Implementation guidelines and so on.

05:11.820 --> 05:15.300
Now I think these are a good inspiration but I wouldn't go.

05:15.580 --> 05:18.780
Click on copy and get them into the project.

05:19.420 --> 05:23.300
More rules is not better if you know what you're doing.

05:23.620 --> 05:24.500
That's great.

05:24.740 --> 05:26.100
You don't know what you're doing.

05:26.420 --> 05:31.140
My recommendation is to start with a few basic rules and adapt as needed.

05:31.820 --> 05:40.860
So just adding a lot of more context to the eye doesn't 100% guarantee that the output is going to be

05:40.860 --> 05:41.460
better.

05:41.940 --> 05:47.820
So if you have a specific issue that you're noticing and it annoys you, and you see that the AI is

05:47.820 --> 05:53.140
always doing the same error and you don't want it in there, go ahead and create some rules.

05:53.300 --> 05:58.180
Get some inspiration from the existing rules, but do not simply go ahead and copy paste.

05:58.180 --> 06:00.020
I'm also going to add some additional resources.

06:00.020 --> 06:04.460
So this is another GitHub repository with a lot of rules.

06:04.780 --> 06:09.260
Now before we conclude this lecture, there's one important aspect I want to mention.

06:09.540 --> 06:16.820
If you find resources mentioning the Fylkir rules this is deprecated.

06:16.820 --> 06:22.220
So this is an older version of this system of writing rules within cursor.

06:22.380 --> 06:26.180
So I definitely do not recommend using this particular file.

06:26.180 --> 06:31.500
Use the approach that I've shown where if for some reason the approach doesn't work, you can also manually

06:31.500 --> 06:32.460
create this file.

06:32.900 --> 06:34.820
It just saves a bit of time.

06:35.460 --> 06:38.580
Anyway, this is all in terms of rules.

06:38.580 --> 06:43.660
I'm going to reject the changes that have been made here and we're going to continue with the rest.
