How to Use Cursor Rules to Guide AI Edits
Add a project rules file so Cursor follows your conventions and stack on every AI edit without being told each time.
Cursor reads project rules and applies them to its AI edits, which is the difference between code that matches your codebase and code you have to rewrite. This guide adds a rules file and confirms the editor follows it.
What you need
- Cursor installed with a project open
- Knowledge of your stack and house style
- About 8 minutes
Step 1: Create the rules folder
Project rules live in a dedicated folder at the repo root. Create it so Cursor knows where to look.
Step 2: Write a rule
Each rule is a small file describing how to write code in this project. Keep the guidance specific and testable, the same way you would brief a new teammate.
# Project style
- TypeScript strict; never use `any`.
- Prefer named exports over default exports.
- Use the existing `apiClient` helper for all network calls.
- Co-locate tests next to the file they cover.Step 3: Reference the right files
Point a rule at the patterns it governs so Cursor applies it where it matters. Tie API rules to your network layer and UI rules to your components.
Step 4: Verify the rule is applied
Ask Cursor to add a small feature and check the result. If your rules are loaded, the generated code uses named exports and your helpers without a reminder.
Result: Cursor produces edits that fit your codebase from the start, cutting the cleanup you used to do on every AI suggestion.
Watch related tutorials
41:18
28:05
3:12
26:54
39:10
32:18