Skip to main content

Cursor Rules File Generator for Any Stack

Generate a comprehensive .cursorrules file for your stack — enforce conventions, preferred libraries, and AI behavior guidelines.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt
I need a .cursorrules file for a TypeScript/Next.js 14 with App Router project. The project uses pnpm and follows Airbnb ESLint with Prettier conventions. 1) Define global rules that instruct Cursor to always use server components by default, use client directive only when needed and never suggest any CSS, default exports for components, barrel files. 2) Add file-type-specific rules for .tsx, .ts, .css, .test.ts that enforce imports, naming, and structure. 3) Include documentation rules requiring TSDoc comments on all public functions. 4) Configure test generation preferences to use Vitest with React Testing Library with behavior-driven with descriptive it() blocks and no snapshot tests patterns. 5) Add dependency rules: prefer zod for validation, date-fns for dates, TanStack Query for data over alternatives, and never suggest deprecated packages. 6) Set up error handling conventions that mandate typed Result objects, never throwing for expected failures across the codebase. 7) Include a preamble comment explaining what the file does so new team members understand it immediately. Provide the complete .cursorrules file ready to drop into my project root.

What this prompt does

This prompt asks the AI to generate a complete .cursorrules file tailored to one specific stack. You feed it a [language]/[framework] pairing, your [package_manager], and your [coding_style], and it produces a ready-to-drop rules file that shapes how Cursor suggests code across the whole project. The seven numbered steps walk through global rules, file-type-specific rules, documentation requirements, test-generation preferences, dependency rules, error-handling conventions, and a preamble comment so new teammates understand the file at a glance.

The structure works because it forces the AI to be explicit about both what to do and what to avoid, which is exactly where editor suggestions usually go wrong. The [preferred_patterns] and [anti_patterns] variables become positive and negative constraints, so Cursor stops re-suggesting things you have already rejected. [file_types] scopes rules per extension, [doc_format] standardizes docblocks on public functions, and [test_framework] plus [test_style] push generated tests toward your real preferences instead of generic defaults like snapshot tests. The [preferred_libs] and [error_pattern] variables encode the small decisions — which validation library, whether to throw or return typed results — that otherwise get re-litigated in every code review. Because all of this lives in one file at the project root, the conventions travel with the repository.

When to use it

  • Starting a new project and you want consistent AI suggestions from day one
  • Onboarding teammates who should inherit the same Cursor conventions you already use
  • Migrating an existing repo onto a stricter set of patterns and wanting them enforced in the editor itself
  • Codifying anti-patterns you keep having to correct manually in pull requests
  • Standardizing test generation so Cursor stops emitting the wrong framework or snapshot tests
  • Documenting why certain libraries are preferred so the rules outlive the person who wrote them

Example output

You get a single .cursorrules file as text: a preamble comment explaining the file's purpose, a global-rules block, file-type-specific sections keyed to your [file_types], documentation and testing rules, a dependency allow-and-deny list built from [preferred_libs], and an error-handling convention drawn from [error_pattern]. It is meant to be pasted into your project root largely unchanged, then trimmed wherever a rule does not apply to your situation.

Pro tips

  • Fill [anti_patterns] from real friction you have hit, not theory — the negative rules are what cut noisy suggestions most effectively
  • Keep [preferred_libs] short and opinionated; a long list dilutes the signal Cursor actually acts on
  • Make [error_pattern] concrete (for example, typed Result objects rather than throwing for expected failures) so the AI applies it consistently across files
  • Treat the generated file as a draft: read every rule, delete what does not fit, and tighten any vague wording before committing
  • Revisit the file when your [framework] version changes — rules tied to specifics like App Router conventions age quickly
  • Keep the preamble comment intact so teammates understand the file before they edit it

Frequently Asked Questions

What is a .cursorrules file and where does it go?
A .cursorrules file is a plain-text file in your project root that tells Cursor how to suggest and generate code. It encodes conventions, preferred libraries, and forbidden patterns so the AI's output matches your project. This prompt generates one complete file ready to drop in.
Will the generated rules work for any language and framework?
The prompt is stack-agnostic because you supply `[language]`, `[framework]`, and `[package_manager]` yourself. The quality of the output depends on how specific those values and your `[preferred_patterns]` are. Vague inputs produce generic rules, so be concrete about your real stack.
Should I accept the generated file without changes?
No. Treat it as a strong draft and read every rule before committing it. The AI can include rules that do not fit your project or contradict each other, so trim and tighten the output rather than dropping it in blind.
How do I keep the rules current as my stack evolves?
Re-run the prompt or hand-edit the file when your `[framework]` version or `[preferred_libs]` change. Rules tied to specific framework versions, like routing conventions, age fastest. Keeping the preamble comment helps teammates know what to update.
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

AI assistant · trained on my work

👋

Hey there!

Quick Actions

WhatsApp Direct line to me

Chat on WhatsApp

+880 1723 741224 · Replies within the hour on working days

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

mejba.13@gmail.com

✓ 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