DEV Community

Jovan Chan
Jovan Chan

Posted on

5 .cursorrules patterns that make Cursor write code you don't have to rewrite

Cursor is only as good as the rules you give it. With no .cursorrules file, it defaults to generic habits — and you spend your day undoing them. Here are five patterns that consistently produce code I actually keep.

1. State the boundary, not the vibe

Bad: "Write clean, maintainable React."
Good:

- Default to Server Components. Add "use client" only for state/effects/browser APIs.
- Fetch data in Server Components or Route Handlers, never in useEffect.
- Style with Tailwind only. Use the @/* alias — no ../../../ imports.
Enter fullscreen mode Exit fullscreen mode

The model can't act on "clean." It can act on "no useEffect for data fetching." Be that specific.

2. Encode your "definition of done"

Cursor will happily hand you code that doesn't compile. Close that loophole:

## Before finishing
- Run `pnpm tsc --noEmit` and `pnpm lint`. Report failures; don't claim done if either fails.
Enter fullscreen mode Exit fullscreen mode

This one line turns "looks plausible" into "actually verified."

3. Write the anti-patterns down

A "never" list kills your most frequent annoyances:

## Never
- Never use `any` or `@ts-ignore` to silence errors — fix the type.
- Never add a dependency without checking what already exists.
- Never reformat code unrelated to the current change.
Enter fullscreen mode Exit fullscreen mode

That last rule alone saves you from 200-line diffs where you changed 3 lines.

4. Use the modern .mdc format with scoped globs

Cursor's Project Rules let you scope rules to file types so you're not burning context on irrelevant instructions:

---
description: "Next.js App Router + TypeScript rules"
globs: ["**/*.ts", "**/*.tsx"]
alwaysApply: true
---
Enter fullscreen mode Exit fullscreen mode

Keep one focused rule file per concern instead of one giant catch-all.

5. Give it a reviewer persona

The highest-leverage habit: after a change, have the agent review its own diff as a skeptic.

Review the git diff. Classify findings 🔴 Bug / 🟡 Risk / 🔵 Cleanup.
Cite file:line. Skip style nits. Don't rubber-stamp.
Enter fullscreen mode Exit fullscreen mode

Grab working versions (free)

I keep ready-to-use .cursorrules and CLAUDE.md files — free, MIT — here:

👉 https://github.com/devloadout/awesome-claude-code-configs

The full kit (6 stacks, 4 subagents, slash commands, hooks, MCP setups) lives here if you want the complete set.


What's your most useful Cursor rule? I'm collecting the good ones — drop it below.

Top comments (0)