Skip to main content

Claude/ChatGPT Prompt to Write a .cursorrules File That Saves Hours

Generate a tuned .cursorrules file that steers Cursor to your stack, test conventions, commit format, and the files it must never touch.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

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.

Frequently Asked Questions

Why bother with a .cursorrules file?
Without one, Cursor reformats everything and reinvents conventions you already settled. A tuned rules file encoding your stack, tests, and commit style turns it into something that writes code you'd have written yourself.
How do I stop Cursor editing sensitive files?
List them in `[protected_paths]`, such as migrations, generated code, and .env files. The prompt treats this step as critical, since the protected-paths list is what prevents Cursor from touching code it should never modify.
Can it match my commit message format?
Yes. Set `[commit_style]`, such as Conventional Commits, and the generated rules include the format plus examples Cursor can copy. Real examples matter because a format without them tends to be interpreted loosely.
Will it ask before guessing?
Yes. A short "when unsure, ask" clause is a deliverable, so Cursor surfaces ambiguity instead of guessing. This prevents the agent from confidently producing a wrong diff when requirements are unclear.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Cursor AI Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support