In this categoryCursor ยท 26
CursorBeginner

How to Add a .cursorrules File to Steer Cursor

Drop a rules file at your repo root so Cursor follows your stack and conventions without you repeating them in chat.

7 minBeginner

Cursor reads a rules file at the root of your project and feeds it to the model on every request. A few crisp lines about your stack and house style stop you from re-explaining the same things in chat all day. This guide adds one and confirms Cursor honors it.

What you need

  • Cursor installed with a project open
  • A clear idea of your build and test commands
  • About 5 minutes

Step 1: Create the rules file

Place a .cursorrules file at the repo root. Keep it to short imperative bullets covering stack, style, and anything surprising about the layout.

.cursorrules
- Stack: React + TypeScript (strict), Vite, Vitest.
- Use function components and hooks only; no class components.
- Imports: named exports, sorted, no default exports.
- Run the test suite mentally before suggesting an edit.
- Money is integer cents, never a float.

Step 2: Reload so Cursor picks it up

Cursor loads the file when the workspace opens. After creating or editing it, reload the window so the new rules take effect.

Command Palette (Cmd/Ctrl+Shift+P)
> Developer: Reload Window

Step 3: Test that it sticks

Ask for something that would expose a convention. If the rules loaded, Cursor uses named exports and cents without being told.

Cursor - rules in effect
You
Add a helper that totals a list of line items.
Agent
Added export function totalCents(items). It sums integer cents and returns a number, with a named export per your rules.
The model applies the rules from the file.
Keep it short
Every line costs context on each request. Trim the file to rules you actually care about. Ten sharp bullets beat a page of prose.

Result: Cursor starts every request already knowing your stack and style, so its suggestions land closer to mergeable on the first try.

Watch related tutorials

Free weekly email

New guides in your inbox

Fresh step-by-step how-to guides as we publish them. One email a week, no more.

Tags
#cursor#rules#config#conventions#setup