Free

Old Cursorrules in Action

Hey, welcome back. There are two types of Cursor Rules: global rules and project-specific rules. Let’s start with the global ones. Global rules apply to all your projects and can be set directly in Cursor’s settings. For example, if you want to add a simple rule to modify outputs, go to Preferences, then Cursor Settings, and add the rule. Once saved, it’s applied to every prompt you write. Let’s try it. Use the command shortcut, type a prompt, and see how the rule applies to the result. Now, let’s remove that rule and move on to project-specific rules. Project-specific rules are tailored to each project. If you’re working on multiple projects, you can have different rules for each. Before we set up our cursorrules file, let’s try something fun. Use the command shortcut to generate some project code. Once the code is generated, it’ll be part of your project. Now, let’s define a rule for code readability and speed. Go to the project explorer, create a new file, and name it cursorrules to include your custom rule. Save the file. Next, highlight the code we just generated, use the command shortcut, and ask Cursor to optimize it. Cursor will now automatically apply the rule for optimization. If you want this rule applied across the entire project, open the AI pane and prompt it to optimize all code. Cursor will update everything according to your rule. Let’s expand our app with additional functionality, and you’ll notice that Cursor continues following the rule when generating new code. These cursorrules files are flexible, allowing you to create custom rules for different languages or frameworks and reuse them across projects. Every time you ask the AI for code, it will follow these rules. For example, in a TypeScript project with specific styling, you could create a rule that ensures all components use the preferred setup.

Kevin Kernegger

Full Course - Early Access

Discount for the first 100 students