Skip to main content

Project-Specific Cursor Rules for Team Consistency

Generate a shared .cursorrules file enforcing naming, architecture, imports, and forbidden patterns across your whole Cursor team.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt
My team of 8 developers uses Cursor and we need shared rules to ensure consistent AI-generated code. Our project is B2B SaaS platform built with Next.js, tRPC, Prisma, PostgreSQL. 1) Write rules enforcing our naming conventions: camelCase for functions, PascalCase for components, UPPER_SNAKE for constants. 2) Add architecture rules: all new code must follow feature-sliced design with shared/entities/features/widgets layers — include examples of correct and incorrect structure. 3) Enforce import ordering: react, next, third-party, @shared, @features, relative imports. 4) Require error handling to use a Result/Either type or a typed AppError class with centralized handling instead of generic try-catch. 5) Set database query rules: no raw queries in controllers, eager-load relations, use the repository layer to prevent N+1 queries and enforce repository patterns. 6) Add commit message and PR description formatting rules. 7) Include forbidden patterns with explanations: any type, console.log in production code, direct DOM manipulation in React. 8) Create role-specific rule sections for frontend, backend, and full-stack developers. Provide the complete .cursorrules file with inline comments explaining each rule.

What this prompt does

This prompt generates a shared .cursorrules file for a whole team so AI-generated code stays consistent across every developer. You set [team_size], [project_type], and [tech_stack], then the AI writes rules enforcing your [naming_conventions], your [architecture_pattern] with both correct and incorrect structure examples, [import_order], the [error_handling_pattern] instead of generic try-catch, [db_rules] to prevent N+1 queries and enforce a repository layer, commit-message and PR-description formatting, and [forbidden_patterns] with explanations. It even splits into role-specific sections for frontend, backend, and full-stack developers.

The structure works because drift in AI output is the first problem teams hit once everyone is using Cursor. By pinning [naming_conventions], [import_order], and [architecture_pattern] in one shared, version-controlled file, every developer's Cursor produces code matching the same standard you would otherwise enforce manually in review. The role-specific sections keep the rules relevant per developer so a frontend engineer is not wading through backend-only constraints. The inline comments explain each rule, which is what makes the file maintainable rather than a black box that gets ignored or stripped out the first time a rule seems inconvenient. Providing both correct and incorrect examples for [architecture_pattern] makes the boundary concrete enough that both Cursor and teammates learn it quickly.

When to use it

  • A team of several developers all use Cursor and their AI output is visibly drifting apart
  • You want AI-generated code to match the same standards you enforce in code review
  • New team members need to inherit conventions without reading a long, separate style guide
  • You keep correcting the same naming or import-order issues across pull requests
  • N+1 queries or raw SQL in controllers keep slipping in and you want [db_rules] enforced in the editor
  • Different roles need different guidance but from one shared, version-controlled source of truth

Example output

You get one .cursorrules file with inline comments: naming rules from [naming_conventions], an architecture section showing correct and incorrect structure for [architecture_pattern], an import-ordering rule, the [error_handling_pattern], database rules covering eager-loading and the repository layer, commit and PR formatting rules, a forbidden-patterns list with reasons, and role-specific sections for frontend, backend, and full-stack work.

Pro tips

  • Derive [forbidden_patterns] from real issues you catch in review, and include the reason so teammates respect the rule
  • Provide both correct and incorrect examples for [architecture_pattern]; the contrast is what makes the rule actually stick
  • Keep [db_rules] specific (eager-load relations, no raw SQL in controllers) so Cursor can genuinely act on them
  • Version-control the file and treat changes as a team decision, not a quiet personal edit
  • Use the role sections so frontend developers are not buried in backend-only rules they will never apply
  • Keep inline comments current; a rule without a documented reason tends to get ignored or removed later

Frequently Asked Questions

How is this different from a personal .cursorrules file?
This version is built for a team of `[team_size]` developers, with role-specific sections and inline explanations so everyone's Cursor output matches one shared standard. It is version-controlled and treated as a team decision, where a personal file only governs your own suggestions.
Can a .cursorrules file really prevent N+1 queries?
It can steer Cursor away from them by encoding `[db_rules]` like eager-loading relations and using the repository layer. It is guidance, not enforcement, so it reduces how often the AI suggests N+1 patterns but does not replace query review or profiling.
Why include both correct and incorrect examples for the architecture?
Showing the wrong structure next to the right one makes the `[architecture_pattern]` rule concrete. Cursor and teammates both learn the boundary faster from a contrast than from an abstract description, which is why the prompt asks for both.
How do we keep the shared rules from going stale?
Version-control the file and update it through your normal review process whenever conventions change. The inline comments help here: a rule whose reason is documented is easier to evaluate, keep, or retire than an unexplained line.
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