What this prompt does
This prompt has the model act as a senior engineer configuring an AI pair-programmer and write a complete .cursorrules file, returning the full file rather than a sketch. You set the [stack], the [test_convention], the [commit_style], and the [protected_paths], and it returns coding-style rules, test conventions, commit format, refactor safety rules, off-limits paths, and a "when unsure, ask" clause — ready to drop into the repo root.
The structure works because without a rules file, Cursor reformats everything and reinvents conventions you already settled. By encoding coding style for [stack], where tests live under [test_convention], the [commit_style] with examples, and a [protected_paths] list Cursor must never edit, the prompt turns Cursor into something that writes code you'd have written. The protected-paths list is what stops it editing migrations or generated code. The refactor safety rules — change-scope limits, no silent API changes, stable public signatures — keep the agent from quietly widening a small task into a sprawling one.
When to use it
- You run Cursor across one or more codebases and want consistent output.
- Cursor keeps reformatting files and reinventing your conventions.
- You need test-location and mocking rules encoded for the agent.
- You want a fixed commit message format with copyable examples.
- You must keep certain paths (migrations, generated code) off-limits.
- You want Cursor to surface ambiguity instead of guessing.
- You want project terminology used correctly in generated code and comments.
Example output
Expect the complete .cursorrules file contents, ready to drop into the repo root. Inside: coding-style rules for [stack] (formatting, naming, imports, error handling), test conventions following [test_convention], a commit format following [commit_style] with examples, refactor safety rules that keep public signatures stable, the [protected_paths] list plus project terminology, and a short "when unsure, ask" clause so Cursor surfaces ambiguity rather than guessing. The whole thing is concise but complete, written to drop into the repo root and immediately steer the agent toward your conventions on the very next edit it makes.
Pro tips
- Be explicit in the protected-paths step —
[protected_paths]is what stops Cursor editing migrations or generated code. - Set
[stack]precisely (e.g. Next.js 15 + Prisma) so the style rules match the framework conventions you actually follow. - Encode
[test_convention]fully — where tests live, what to mock, coverage expectations — so generated tests land in the right place. - Give
[commit_style]real examples Cursor can copy, since a format without examples gets interpreted loosely. - Keep the "when unsure, ask" clause; it's what makes Cursor flag ambiguity instead of guessing and producing a wrong diff.
- Add project-specific terminology so Cursor uses your domain language correctly in code and comments.