← Video library

How to Vibe Code Smarter with Cursor Rules

Use Cursor rules to keep personal defaults separate from constraints that apply to a single repository or file type.

Watch on YouTube ↗

Follow the walkthrough

  1. 1. Separate shared defaults from project rules

    Use account-level rules for communication or coding preferences that hold across projects. Put repository-specific instructions inside the project.

    Watch at 00:00:00
  2. 2. Choose how each rule activates

    Select manual reference for an occasional instruction or auto-attachment for relevant files. The video also covers letting the agent choose from descriptions.

    Watch at 00:01:46
  3. 3. Make a UI rule concrete

    Amir uses shadcn components and Tailwind as an example of a front-end convention. Attach that instruction where the UI files are edited.

    Watch at 00:02:30
  4. 4. Write the trigger as clearly as the instruction

    For a rule the agent selects, explain when it applies. Revise a rule when a recurring mistake exposes a missing or ambiguous constraint.

    Watch at 00:03:41

A rule is easier to test when it names the files or task that should activate it.

Read the transcript

Before we go out and start working on the project of the job board from PRD, I want to talk to you about rules. Now, what are rules? Rules are essentially a set of guiding principles that your agent can follow. It provides very consistent outputs and behavior based on the context of your development workflow. So, that it ensures it understands your preferences, standards, and requirements. There's two types of rules and they're applied at different

scopes. So, you can have actual global rules that are applied across all your projects and workspaces. So, this could be your general coding preferences, universal standards, or personal workflow. And you can actually set it in the settings section. I'll show you what that looks like. Or you can have project rules. Where they're specific to individual projects or codebases. And it's very project specific. So, it's whether it's a tech stack or team

standards or just an a way to approach actually like developing the UI. So, you can have a set of a global rules applied across all projects and then project-specific rules. Now, you can actually add rules manually either in a folder called .cursor or directly to the cursor settings panel. And I'll show you how to do that through the settings panel cuz I think it's the easiest way to do. Now, I already have an existing rule. This is a global rule that I've

come up with where essentially just follows clarity over clarity, structures, do not repeat yourself. So, there's a dry method where it doesn't have to repeat back to you what it wants to say. And just from a technical standpoint, it keeps things very component has and structured and very easy and neat, simple to understand, and it documents the codebase. So, we're going to copy the rule here, go to settings, cursor.settings, click on

rules, and then we're going to add a global rule here. Now, press done. Now, say for example, you want to add project-specific rules. So, you can actually go to So, you can see over here, I actually created a folder for you. So, you can go here and say UI standards. mdc. And it'll create an mdc file. And then you can actually create the rule type. So, whether you want it to be manual, so as you're in the chat, you

can reference the rule. So, you can say build out this UI for the dashboard, and then you'll say at UI standards.mdc, and it's referencing the rule or you can or change it to agent requested. So say for example, when you should be like when this rule should be used for example, when your building out front end or you can say auto attach that always attaches it based on some sort of file pattern that you have depending so let's

say for example, if your file ends in JSX, it could always attach a rule or you can do always most of the time depending on the rule that I have I want to either just apply the global rule or if it's project specific rule, I'll have it always auto attached and basically I'll say use shadcn components always use Tailwind. Now I'm not going to add the rule but because we'll maybe add it as we go through the project but for now I just want to show

you what that looks like at a project specific a level. When you're building out your rules, try to be very specific about what the instructions the agent should follow and explain why the rule should actually exist. So you can see over here when we have the global rule, we talk about what it's supposed to be following the key principles, the style of implementation. So what you want to ensure is that it's focused, it includes examples. I also

recommend that if you're building out global rules, try to start very small and iterate from it. In the documentation of a cursor, they also include this as well. They say you want to have just small iterations of rules that you can add and then just iterate on top of base on the responses you get and just assess whether or not the rule would actually effective. And when you're starting out with your rules, try to cover the code style if that's if

it's focused on coding, documentation. So for example, in our rule, we have a comment on whether or not it should actually document the code. You can also try to ensure that when you're deciding on attachment, you think about what is the best case here whether or not you want to have a task based, context based, problem based or technology based, right? If you're doing agent decides as an attachment then I recommend you include clear descriptions

descriptions of why it should include this rule. From a very high level standpoint, I always just start with your global rule, set the baseline, then add your project rules as you're building your project. Don't go into straight into a project in the beginning and start adding project rules. Try to look at specific patterns or prompts that you're constantly repeating that you think will be better off if you just create a rule around it versus trying to

manually type each prompt each time. And I would say just to leave it off, just add the rules, test it, iterate it rule with based on what is fit for your workflow.

Download as text