در حال بارگذاری ...

Update AI Guidelines0:08

So the next tip I have for you is to nip it in the bud. And here's what I mean. If at any point AI generates some code or doesn't adhere to a convention that your team has, stop, take 30 seconds and then update your guidelines file. I know it's kind of annoying, but just do it to ensure that this never happens again. I'll show you an example here. I'm in the Laravel Workshop project. Mm-hmm. Uh, you can search for that on Lar cast.

Bookmarking Feature Example0:31

I'm in the Laravel Workshop project. Mm-hmm. Uh, you can search for that on Lar cast. And at the end of the series we added a read me with some potential suggestions. If you wanna take it further. Let's do the first one on the list. Implement the bookmarking feature. When the user clicks a bookmark icon, the user ID and post ID field should be inserted into a new bookmarks table that we create.

and post ID field should be inserted into a new bookmarks table that we create. All right? Add the ability to bookmark a post effectively. So here's what I'm gonna do. I'm gonna select this entire thing, and we're gonna have AI work on this, but I wanna show you something. I wanna work on a new bookmarking feature. Review this plan, and I'll paste that in here. And then I just wanted to do plan mode. I want you to give me some examples for the eloquent model

And then I just wanted to do plan mode. I want you to give me some examples for the eloquent model that you'll create for this particular feature. Don't write any code yet. Okay? So let's, uh, let's let it run. And I want you to notice, by the way, that I am using the clot agent here. All right, let's have a look. Here's the full bookmark model I would create. So bookmark extends model.

Spot Convention Mismatch1:28

bookmark model I would create. So bookmark extends model. We have the relationships, sort of what you'd expect, but I want you to notice this section right here, the fillable fields. Now maybe for your team, this is what you want, but for my team, we don't do this. We call model un guard across, uh, the entire project. In which case, this is not following my conventions. So of course it takes two seconds to delete that,

Edit Agent Guidelines File1:47

In which case, this is not following my conventions. So of course it takes two seconds to delete that, but I don't want it to ever do that again. So here's what I'd do. I'd close this out, and if I'm using the Claude agent here, then I would open claude.md. Uh, if I was using, if I were using a different agent like uni, then I would open up the uni configuration file, and that would be within the do uni guidelines file.

uni, then I would open up the uni configuration file, and that would be within the do uni guidelines file. And I would update it there. Anyhow, in this case, we're using the Claude agent. So yeah, you'll notice there's no reference here to fillable fields or guarding. So I wanna add my own rules, and I'm gonna show you two ways to do that. First up, let's imagine I'm not using Laravel Boost at all in that case, maybe I might even have a blank clo

First up, let's imagine I'm not using Laravel Boost at all in that case, maybe I might even have a blank clo that nd file, and I could say eloquent. And I'm just gonna give it some brief, uh, instructions here. How about this? Never use fillable or guarded fields. We run model un guard application wide. All right? And in fact, if I go to App Service provider, you can see right here it says Model Ungar.

All right? And in fact, if I go to App Service provider, you can see right here it says Model Ungar. Okay, that's it. So now we've updated our guidelines to instruct AI or Claude in this case to never use those properties. Okay? So let's bring this back. Try one more time while reviewing claude.md guidelines. All right, here we go. Perfect. I see the important guidelines.

All right, here we go. Perfect. I see the important guidelines. Let me revise the bookmark model. So now I want you to notice it omits the fillable fields entirely, and this is what we want. So here's the deal. You're gonna rinse and repeat. You're gonna follow this exact step every single time you run into, uh, even the smallest of paper cuts. If something's not working, then you need to fix it. Okay? So if you're starting with a blank, uh,

Persist Guidelines with Boost3:35

If something's not working, then you need to fix it. Okay? So if you're starting with a blank, uh, claw.md configuration file or guideline file, this is fine. However, if you are using something like Laravel Boost, then this file will be generated dynamically. And that case, here's what you do, I want you to open up your sidebar and you're gonna create a new directory called ai, and within there, create a directory called guidelines, and then add a series of markdown files, each

and within there, create a directory called guidelines, and then add a series of markdown files, each of which will effectively be appended to the top of this, um, clause.md file. So I'll show you, let's go right here and fix the typo. And let's add a file. We'll call it Laravel md. And I'm just gonna paste this in here. Okay, so now I've added custom guidelines, but of course it's not magical. This doesn't get updated automatically.

but of course it's not magical. This doesn't get updated automatically. That will only happen when we run boost install. So let's do that now. PHB Artisan Boost Install. All right. And we can see right up here that's working. So now if we scroll to the top of this file after it refreshes, you can now see that it is appended to the top of the file. Alright? So yeah, just as a general rule of thumb, if you're using Laravel Boost,

Alright? So yeah, just as a general rule of thumb, if you're using Laravel Boost, well when you fix these paper cuts, always update your do AI directory instead of rewriting this file. 'cause of course it's gonna be overwritten as soon as you run Boost, install a second time.

دوست دارید گاهی خبرهای Laracasts را ایمیل کنیم؟