.cursorrules Generator
Build a .cursorrules file for Cursor AI — pick a framework preset, customise each section, download instantly
Framework Preset
Selecting a preset fills in sensible defaults. You can edit each section after.
Enable sections and fill them in to build your .cursorrules file.
Where to place it: Save as .cursorrules in the root of your project. Cursor automatically loads it when you open that folder.
You’re setting up a new project in Cursor and you want the AI to follow your team’s conventions without constant reminders. Or you’re onboarding a freelancer and want Cursor to enforce your code style automatically. This generator builds a .cursorrules file for your project — with framework-specific templates you can edit and download in seconds.
What Is .cursorrules?
.cursorrules is a plain-text configuration file that Cursor AI reads whenever you open a project folder. It acts as persistent context for the AI — telling it about your code style preferences, the libraries you use, your file structure conventions, and any project-specific rules you want it to follow.
Without a .cursorrules file, Cursor has no knowledge of your project beyond what it can infer from open files. With one, every suggestion, completion, and chat response is informed by your team’s actual standards.
The file lives in your project root and is typically committed to version control so the whole team benefits.
How Cursor Loads Your Rules
Cursor automatically detects .cursorrules in the root of the currently opened workspace folder. There’s nothing to configure — just place the file and reopen the folder (or reload Cursor) for the rules to take effect.
The rules are injected as system-level context before every AI interaction in that workspace. They apply to:
- Tab completions — Cursor’s autocomplete respects your style preferences
- Cmd+K inline edits — targeted edits follow your conventions
- Chat — the AI assistant knows your stack and structure without being told each time
Best Practices for Writing .cursorrules
Be specific, not vague. “Write clean code” tells the AI nothing. “Use 2-space indentation, named exports, and TypeScript for all new files” gives it actionable constraints.
Describe your actual stack. List the exact libraries you use (e.g., “React Query, not SWR” or “Zod for validation, not Yup”). When the AI knows what you have installed, it won’t suggest alternatives.
Document your file structure. Cursor can’t see your entire project at once. Telling it “custom hooks go in src/hooks/” and “shared UI in src/components/ui/” means generated code lands in the right place.
Capture error-handling patterns. Teams have strong opinions here — whether to use result types, throw custom errors, or handle errors at the boundary. Write these down explicitly.
Keep it focused. A 100-line .cursorrules file is more useful than a 1000-line one. The AI’s attention is finite — bury the important rules in noise and they’ll be ignored. Prioritise the rules that differ from common defaults.
Version it. Commit .cursorrules alongside your code. When your conventions evolve, update the file so the whole team’s Cursor instances stay in sync.
Common Patterns by Framework
React projects benefit most from specifying component architecture (hooks vs. class components are long-settled, but functional component file structure varies widely), preferred state management, and whether you use TypeScript.
Next.js projects should specify App Router vs. Pages Router, the boundary between Server and Client Components, and where data fetching happens. These are decisions with significant style implications.
Python projects need explicit guidance on whether to use sync or async, the ORM/query layer, and error-handling conventions (exceptions vs. return codes vs. result types).
Go projects benefit from reminders around error handling (never ignore errors, wrap with context), package structure philosophy, and whether to use an HTTP framework or the standard library.
Frequently Asked Questions
Does .cursorrules affect all AI features in Cursor? Yes — the rules are injected as system context for completions, inline edits (Cmd+K), and chat. They don’t affect Cursor’s non-AI features (search, the file explorer, etc.).
What happens if my .cursorrules file is very long? Cursor loads the file into the AI’s context window on every request. Very long files consume tokens that could be used for your actual code. Keep it focused — 50 to 150 lines covers most projects well.
Can I have different .cursorrules for different parts of a monorepo?
Cursor reads the .cursorrules from the workspace root. For monorepos, put shared rules at the root and supplement with inline comments or Cursor’s project-level settings for package-specific behaviour.
Is .cursorrules the same as Cursor’s “User Rules” in settings?
No. User Rules in Cursor’s settings apply globally across all projects. .cursorrules is project-specific and takes precedence over User Rules when both are present. Use User Rules for personal preferences (like your preferred response length), and .cursorrules for project conventions.