How to Write a .cursorrules File That Actually Works
Copy-paste .cursorrules dumps don't help. Learn how to write a .cursorrules file: a focused, under-500-line policy generated from your real stack facts.
What a .cursorrules File Does
A .cursorrules file is the config Cursor reads to steer its AI inside your project. It carries the conventions to follow, the patterns to avoid, and the stack-specific rules that keep generated code looking like the rest of the codebase. The editor's agent treats it as standing context on every request in that repo.
Knowing how to write a .cursorrules file well is mostly about restraint. The popular sources push in two directions. Trigger.dev's piece on great Cursor rules is solid best-practice prose. The awesome-cursorrules repo is a giant collection of example files. The Cursor forum best-practices thread is community lore.
The best-practice writing is fine. The example dumps are the trap. Grabbing a 600-line rules file written for someone else's stack gives the agent a pile of rules that don't match your code, no curation, and no verification step. The agent then half-follows them, which is worse than no rules at all.
Why Copy-Pasted Rules Backfire
A borrowed .cursorrules file feels productive. You paste 500 lines, the agent now has "rules," done. Then it starts enforcing a state-management pattern you don't use and ignoring the one you do, because the file was written for a React app and yours is Vue.
Two things break with copy-paste. The rules don't match reality, so the agent applies conventions your codebase doesn't follow. And the sheer length means the model skims. A focused 80-line file the agent reads in full beats a 600-line file it samples. Past a few hundred lines, every extra rule competes for attention with the ones that matter.
There's a third miss that even the good prose guides underplay: no verification step. A rules file should tell the agent how to check its own work before claiming done. Most don't, so the agent declares victory on code that never ran the test.
What a Working Rules File Contains
- Stack facts. The actual language, framework, and versions, so rules reference real tooling.
- The conventions that matter. Import order, naming, the state pattern you use, the error-handling shape reviewers expect.
- The anti-patterns. What the agent must not produce: the deprecated API, the banned library, the pattern your team killed.
- A verification block. The check the agent runs before claiming done: run
{{test_command}}, confirm the lint is clean, confirm the change is in scope. - The scope. What this rules file governs, especially in a repo with more than one app.
Keep it tight. A rule that doesn't change the agent's behavior is just noise that crowds out the rules that do.
A Rules-Authoring Prompt You Can Copy
Instead of borrowing a dump, generate a focused file from your facts.
You write a .cursorrules file for this project.
Stack facts: {{stack_facts}}
Conventions reviewers enforce: {{conventions}}
Patterns to ban: {{anti_patterns}}
Produce a .cursorrules file under 200 lines with these sections:
- Stack: the versions and tooling, stated plainly.
- Conventions: one rule per line, imperative.
- Avoid: the banned patterns, one per line.
- Verify before done: run {{test_command}}, lint clean, scope check.
Use only the facts provided. Don't pad with generic advice.
Cut any rule that wouldn't change the agent's output.
The "cut any rule that wouldn't change the output" line is the whole trick. It forces the file to stay a policy, not a wish list. Every rule has to earn its line by changing behavior.
Watch for contradictions, too. Borrowed dumps often carry rules that quietly fight each other: one section says "prefer named exports," another pasted block says "default-export every component." When the agent hits a conflict, it picks one more or less at random, and you get inconsistent code that technically follows the rules. A generated file derived from one source of facts doesn't have this problem, because the conventions came from the same place. If you must merge two reference files, read them for conflicts first. The agent won't flag the contradiction. It'll just pick a side per file and leave you wondering why the codebase drifted.
A .cursorrules file the agent reads in full and follows is worth more than a sprawling one it skims. Generate a focused file from your real stack facts, keep it under a few hundred lines, and end it with a verification block. A borrowed 600-line dump gives the agent rules that don't match your code and a length that guarantees it won't read them all.
How the Rules File Reads Across the Stack
A generated .cursorrules file holds up because it's derived, not borrowed. The verification block in particular changes how reliably the agent finishes a task.
| Rule type | Effect on Cursor's agent | Note |
|---|---|---|
| Stack facts (versions, tooling) | Agent stops using deprecated APIs | Pin versions; "latest" drifts |
| Convention rules (imperative) | Followed when one rule per line | Paragraphs get skimmed |
| Anti-pattern bans | Strong, when stated as "never use X" | Soft phrasing gets ignored |
| Verification block | Agent runs the test before claiming done | The most-skipped, highest-value section |
The verification block is the one to never omit. Without it, the agent's idea of "done" is "the code looks plausible." With it, "done" means the test command ran. That single section is the difference between a rules file that improves quality and one that just sets a vibe.
Variables You'll Set
| Variable | Required | What it is |
|---|---|---|
{{stack_facts}} | Yes | The real language, framework, and versions the project uses |
{{conventions}} | Yes | The rules reviewers actually enforce on this codebase |
{{anti_patterns}} | Optional | Specific patterns to ban, like a deprecated API or library |
Getting Started
- Write down your real stack: language, framework, versions, tooling.
- List the conventions reviewers enforce, one rule each.
- List the patterns the agent must never produce.
- Run the authoring prompt to generate a focused file under 200 lines.
- Add the verification block: test command, lint, scope check.
- Drop the file in at the repo root and watch a real task run against it.
- For a policy-grade rules body, start with the Code Review Policy System Prompt.
A .cursorrules file sets the standard; a review pass checks the agent met it. The Code Review Policy System Prompt shares the same DNA as a good rules file, a focused policy with a verification step, which is why the two compose well: the rules guide the writing, the policy grades the result.
The Code Review Policy System Prompt does this end-to-end: a focused, contract-driven policy that grades code against a fixed standard with a {{diff}} variable and a severity-rated output, the same focused-and-verified shape a working .cursorrules file needs. It's part of The Complete AI Prompts Bundle, a one-time lifetime license to the whole catalog plus future packs, which makes sense once you're authoring rules across more than one repo.
A .cursorrules file works when it's short, derived from your real stack, and ends with a step that checks the agent's work. Borrowed dumps do the opposite. For the larger config that agents outside Cursor read, see how to write an AGENTS.md file with AI. And when a single rules file isn't enough because the repo holds many packages, Cursor rules for large monorepos covers scoping rules per package.
See all coding agent prompt packs →Common questions
What is a .cursorrules file?
How do you write a good .cursorrules file?
Why don't the awesome-cursorrules examples work for my project?
Get the prompt packs this guide is built on
Ready-to-paste prompts with documented variables and worked examples for ChatGPT, Claude, and Gemini. One-time payment, own it forever.
More prompt guides

A Production Readiness Review Prompt That Grades a Service
A service ships, and two weeks later it pages someone at 3 a.m. because nobody asked whether it had alerting before launch. The production readiness review checklist exists to catch that. Most teams k…

Write an AI Code Review Prompt That Actually Finds Bugs
A developer pastes a 400-line diff into ChatGPT, types "review this," and gets back three friendly paragraphs ending in "overall this looks solid." The off-by-one in the pagination loop is still there…

An AI PR Review Prompt Template for Clean Diffs
The difference between a PR review that catches the regression and one that waves it through usually isn't the model. It's whether the prompt has a workflow or just a wish. "Review this pull request"…