Lesson Description

The "Using Cursor AI Agent" Lesson is part of the full, Cursor & Claude Code: Professional AI Setup course featured in this preview video. Here's what you'd learn in this lesson:

Steve uses agent mode to generate a calculator component. With broad instructions, Cursor can get stuck or execute task outside the scope of what's being asked. Changes can be reviewed individually or accepted all at once.

Preview
Close

Transcript from the "Using Cursor AI Agent" Lesson

[00:00:00]
>> Steve Kinney: Well, now if I leave this file in here and it's open and all of a sudden, it's fair game. And so if you start getting results that you don't want, look inward and ask yourself like, is this my fault? Sometimes it's not. Sometimes again, there are good Claude days, there are bad Claude days.

[00:00:15]
So we'll delete that file. And now let's try progressively move up to wilder modes. We're in agent mode here and we are going to say, and I'm going to say I can make a new file. I don't trust it all the time. So we're going to make. Okay, I'm not gonna waste your time with the small brain version.

[00:00:43]
We're going to move to at least the medium sized brain version. It is one thing to say build me a calculator, that could go one of many ways, right? What I want to say is in calculator tsx, right? Build a calculator component. Now if I do that, I will probably get something that resembles a calculator component, but I can get a little bit more specific.

[00:01:20]
Put that component in @application.tsx. Now it's going to read Calculator TSX, which at this point doesn't really have anything in it. It's going to look at application tx. So we're getting more specific about then what do I want it to do? We'll say I want you to use usereducer to handle the logic.

[00:01:48]
The actual math should be done in a separate utility so I can test it with 100% test coverage. The calculator should be accessible and use tailwind to style it, right? The more specific you get, the more predictable your outcome is going to be. Mark.
>> Mark: Shouldn't you create a new chat?

[00:02:20]
>> Steve Kinney: I should. So honestly, if you're in the chat window and let's say ask me how I know this because Mark hit on why I know this, which is I get distracted. Let's say you typed all this command N, it moves it to a new chat with the current contents in there.

[00:02:42]
You can even see the things that I've brought into context are also referenced here as well. Do I need big brains for this? I don't need big brains for this. Go ahead. And now we are effectively in agent mode. And for some of this it's kind of like makes, on one hand it's amazing because it will do this faster than I can do it.

[00:03:10]
On the other hand we will sit here and watch this thinking, right? And I'm gonna scroll up and we're going to look at some of its thinking for a second. Great, I can see the Tailwind CSSV4 and VITest are already set up now create a comprehensive calculator and I talked about that to do list feature, right?

[00:03:25]
So it starts to if first of all, we'll try to at least tell you that it understood what you asked for. Again, ignore this at your peril. But then don't be surprised that it did something you didn't like accessible design. Cool, we'll use Tailwind styling. I forgot to mention responsive design.

[00:03:44]
So thank you for that. And then it creates a to do list you can go ahead and see. And so in this case we are phase where we are kind of approving this step by step. So we've got calculator error like okay, maybe that's slight over engineering but it's a good pattern as it's starting to build this feature out for me right now.

[00:04:11]
Granted one even in this simple example that was trying to walk that fine line of live typing English is harder than live coding. It wasn't so boring to watch me write. Was still not build me Excel. It was still like hey, here's what I want. Here are the initial rules and you're gonna see I would get real bored typing those every time.

[00:04:35]
So we'll deal with that momentarily. But you can kind of see that the better you can explain what you want to do, the better it is going to be at doing it. Is having some issues finding a thing but a lot of times it will figure out I have some problems because again we're getting that feedback loop in this case.

[00:04:59]
Cool, cannot find what's your issue. Can't see in that giant font. But it seems to continue going as it's navigating that. Okay, now you can see it's doing all the steps as we think and we start to get something that we can at least review. What I want to show you is the UX for doing so right now the lazy and dangerous thing to do is just slam on the keep all button and move on with your life and like follow the vibes where they go and yeah, that's a thing you can do it and sometimes I do it right.

[00:05:42]
The other option is one you can first of all see the manifest of all the things that it did. Here's all the files that I made and changed almost like a git diff, like pre git. You can see that it actually pulled in some terminal commands into context as it was fighting with the type setup.

[00:06:03]
Cuz literally didn't use this repo for anything. Don't know anything about it. And you can see all the files, you can go ahead. And more importantly, in a given file, now, these are a lot of new files. So there's one change. It is the contents of a file.

[00:06:17]
But if it was like changing a bunch of functions in line somewhere, you could jump down and across through all of them. The other important one is going across the different files. You can also use option L for that as well and go through and see each one, right?

[00:06:37]
And we know that there are some issues that we're gonna have to deal with here, which is like, there are some red squiggly lines. So I know typescript is angry with us, so it clearly didn't, we gotta see when we commit it all. But I have reason to believe that it made at least some mistakes, right?

[00:06:53]
Like, did I want all this? Did I ask for this little banner? I did not. So you can just go ahead and be like, no. Like, you're still like. The nice part about cursor, as opposed to some of the other tools is that, like, at least where you are still in the driver's seat, if you get to the point where you have, like, tests and eslint rules and cursor rules and all of these other things, maybe you can get a little nicer about it.

[00:07:27]
Right now I can name you a whole bunch of things I don't like about this, and a lot of them are nitpicky. I like hyphens, which, whatever, that's the thing. And we'll talk about how to set up those rules, both in terms of cursor rules, but also in terms of eslint rules that enforce it, so on and so forth, Mark.

[00:07:46]
>> Mark: Adam in the chat said, my agent wrote tests, the test failed, and now it's just stuck looking at the test and loading. Do you know how to resolve?
>> Steve Kinney: Yeah, so a lot of times you should have some kind of stop button where it's time to yell at it to stop, right?

[00:08:04]
Which at one point you need to step in and arguably take a look at it and be like, what is the actual issue here? Because a lot of times it will keep spinning and cursor, each one of these actions is what's called a tool call. It will give up after 25 tool calls because both like their money and your money, effectively, right?

[00:08:27]
At which point that is when we do have to kind of like, step in and a lot of times give it some guidance. Like I said before, the better you can express the problem or the issue. It can help you. But it will a lot of times get stuck in these loops, right?

[00:08:43]
So arguably, and we'll see it, there should be a stop button here. I'm obviously stopped, so it's hard for me to see if I just have it do something. All right, then you got a stop button and you can kind of like step in. This is not only important for when it gets caught in a loop, but sometimes because it's telling you everything it's going to do.

[00:09:09]
Like, sometimes you can see it going down a dark path. Like, I'm going to skip all these tests. I normally do this one. It's Ctrl+C. I'm very used to hitting the escape key in Claude code, which we'll see later. My hand hovers over it. It's even hovering over it as I stand at this podium.

[00:09:27]
Even though it's not the right keystroke for this one. But I think we'll see how some of the rules can. We'll look at cursor rules and then we'll look at some draconian eslint rules and we'll see how do we build the framework, the Iron man suit around. This doesn't look right metaphor for managing some of this, but you can see that it will do some stuff that I don't hate, but I didn't necessarily ask for.

[00:09:47]
Okay, so we've seen what agent mode is. We've seen what that surgical mode is. We've seen what the tab mode is, we've seen what the chat mode is. I feel like we can not follow my advice for a moment. Just kind of see it in place. We can see that we have some of these rules.

[00:10:04]
And you can see, once again, this is again, an empty project. And I will show you a project I have in a second where I've like, progressively clamped down on things, which is, did it do what I asked? Technically, I said I want all the files to be kebab case instead of camel case.

[00:10:24]
It spiritually did what I asked it to do. You know what I didn't ask it to do? Remove the old ones, right? And so we'll see how to deal with that rules in a second. But again, it's like one of those things where it's that joke that I said earlier.

[00:10:41]
The person writes the test and then you try to do the most subversive implementation you can, except you're paying this person and it's not real. So we've got those pieces in place. Which point we should talk about how to start expressing our intent about the way we want things done around here to cursor, and that involves this thing called cursor rules.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now