.cursorrules guide

Stop writing .cursorrules
from scratch.

What a production-ready .cursorrules covers for frontend, backend, SaaS, DevOps, mobile, data and AI/ML work — with a free example to copy. Brainfile itself is built for Claude Code, not Cursor.

Free by email: a practical Claude Code tip every Tuesday and Thursday, plus a Sunday recap.

Drop-in ready Free example below 30-day guarantee 8 roles outlined

Writing your own .cursorrules is hard

Every developer who opens Cursor for the first time faces the same wall: the default rules are too generic to be useful, and writing good ones from scratch takes longer than the work itself.

🔁

Cursor doesn't know your stack

Without a strong .cursorrules file, Cursor keeps making the same wrong assumptions — suggesting the wrong framework, missing your naming conventions, and generating boilerplate you immediately delete.

⏳

You re-explain your stack every session

You paste the same context into every new chat: "I use React, TypeScript, Tailwind, Postgres, deployed on Fly.io..." A good .cursorrules file encodes this once. Most devs never write one.

📉

Your rules drift and go stale

Even the devs who write a .cursorrules file from scratch end up with a patchwork of half-remembered rules that no longer reflect how they actually code. Cursor ignores stale rules — or worse, follows them.

What a battle-tested .cursorrules looks like

Start from a structure instead of a blank file: role, stack, conventions, guardrails. The example below is free to copy. Fill in your stack, database and deploy target, and your Cursor session knows who you are, what you're building, and how you code.

⚡

Role-aware from the start

Write it for your specific engineering role — not a generic "developer." A frontend file should cover component architecture. A SaaS file should cover multi-tenancy and Stripe webhooks.

🔧

Three-field customization

The example has three blanks: your stack, your database, and your deploy target. Fill those in, then add the conventions your team actually enforces.

🔄

Review it when Cursor changes

Cursor changes its rules format and capabilities every few months. Re-check your file when it does; stale rules quietly lower output quality. (Brainfile's weekly freshness feed covers Claude Code, not Cursor.)

.cursorrules — Frontend Engineer configuration (excerpt)
# Role: Senior Frontend Engineer # Stack: React 18 + TypeScript + Tailwind CSS + Vite # Deploy: Vercel · DB: Supabase ## Component Architecture - Always use function components with explicit TypeScript interfaces - Props interface named [ComponentName]Props, exported for reuse - Co-locate component, types, tests, and styles in /components/[Name]/ - Prefer composition over prop drilling beyond 2 levels — use Context ## TypeScript Conventions - Strict mode enabled — no implicit any, no non-null assertions without comment - Use discriminated unions for state machines, never boolean flags - API response types live in /types/api.ts, never inlined ## Styling Rules - Tailwind utility classes only — no custom CSS except for animations - Mobile-first breakpoints: sm: md: lg: xl: — always in that order - Dark mode via class strategy ("dark" on html), not media query ## Testing - Vitest + React Testing Library — test behavior, not implementation - Every component gets a smoke test. Business logic gets unit tests.

What a .cursorrules should cover, by role

Eight engineering roles and the conventions, patterns and guardrails each file should encode. Use them as a checklist when you write yours. No fluff, no generic advice — only rules that change how Cursor behaves.

🎨

Frontend Engineer

  • React / TypeScript component architecture and naming conventions
  • Accessibility rules: ARIA labels, keyboard nav, focus management
  • Performance patterns: lazy loading, memo boundaries, bundle splits
Build a free starter file →
⚙️

Backend Engineer

  • Node.js / Python service structure and error handling patterns
  • Database conventions: query optimization, migration hygiene, indexing
  • RESTful API design, versioning strategy, response shape standards
Build a free starter file →
🚀

SaaS Founder

  • Multi-tenant data isolation patterns and row-level security
  • Stripe subscription management, webhook handling, billing edge cases
  • Auth patterns: JWT / session, invite flows, org-level permissions
Build a free starter file →
🛠️

DevOps Engineer

  • CI/CD pipeline conventions, GitHub Actions patterns, rollback strategy
  • Infrastructure-as-code: Terraform / Pulumi module structure and naming
  • Security hardening: secrets management, least-privilege IAM, audit trails
Build a free starter file →
🔗

Full-Stack Developer

  • Monorepo structure: shared packages, workspace boundaries, type sharing
  • API contract patterns: tRPC / OpenAPI schema-first with shared types
  • Feature flag and environment config strategy across frontend and backend
Build a free starter file →
📱

Mobile Developer

  • React Native / Swift / Kotlin platform-specific conventions and navigation
  • Performance rules: FlatList vs ScrollView, Hermes engine, re-render guards
  • Offline-first patterns: local state sync, conflict resolution, optimistic UI
Build a free starter file →
📊

Data Engineer

  • Pipeline architecture: idempotency, backfill strategy, partition hygiene
  • SQL and pandas conventions: naming, window functions, type casting rules
  • Data quality gates: schema validation, null handling, freshness checks
Build a free starter file →
🧠

AI / ML Engineer

  • PyTorch / JAX training loop conventions and reproducibility standards
  • Experiment tracking: MLflow / W&B run naming, artifact versioning
  • Data validation rules: distribution drift, leakage guards, evaluation protocols
Build a free starter file →

Three steps from zero to a Cursor that knows your codebase

Pick the role checklist that fits, write the file with your stack, and Cursor reads it on every request.

1

Pick your role checklist

Use the role list above that matches how you actually work: frontend, backend, SaaS, DevOps, mobile, data, or AI/ML.

→
2

Add your stack in 3 lines

Fill in your framework, your database, and your deploy target, then write the conventions, patterns and guardrails your role cares about.

→
3

Drop into Cursor → done

Save the file as .cursorrules in your project root. Open Cursor. It reads the file automatically. No setup, no config, no API keys. It just works.

Where Brainfile fits

Brainfile is built for Claude Code, not Cursor. It ships no .cursorrules files. If you also use Claude Code, here is what it adds there.

Category ✦ Brainfile (Claude Code) Write your own
What it ships CLAUDE.md, .claude/rules/ and brain/ files, plus the Autopilot protocol The .cursorrules you write for Cursor
Staying current A weekly freshness feed for Claude Code changes Manual — you research and update yourself
Role setup 15 role packs on Pro, including Software Developer and DevOps Your one role
Cursor support None — Brainfile ships no Cursor format Native
Also using Claude Code?

Your Claude Code should know how you code.
Not the other way around.

Brainfile for Claude Code: the Autopilot protocol, 10 pattern files and a weekly freshness feed. Pro adds 15 role packs. Start free — 30 days, no card.

$99 /month

30-day money-back guarantee · Instant access · Cancel anytime

Need a team setup? Enterprise — contact us →

Not ready to buy? Stay in the loop.

New .cursorrules configurations, AI context tips, and Claude Code updates. Free: a Claude Code tip every Tuesday and Thursday, plus a Sunday recap.

No spam. Unsubscribe anytime.