database — Cursor rule: Prisma and Supabase practices
A Cursor rule with database practices for Prisma and Supabase: schemas, migrations, queries, RLS policies. Scoped to database files by glob.
.cursor/rules/database.mdcWhat database does
This is a Cursor rule that tells the agent how to handle database work. It is split into sections: Prisma setup, Prisma models, Prisma queries, Supabase setup, Supabase security, Supabase queries, database design, performance, security, and general best practices. Each section is a short list of items such as proper migrations, proper indexes, proper query optimization.
The rule does not always apply. It sets alwaysApply: false and scopes itself with globs: prisma/**/*, src/db/**/*, **/*.prisma, supabase/**/*. So when you touch those files, Cursor pulls the rule in; elsewhere it stays quiet. That matters, because advice about RLS policies and connection pooling is noise inside a button component.
The items stay generic: use proper field types, handle N+1 queries properly. There are no code samples or ready snippets in the file, so treat it as a checklist of topics rather than a set of answers. For exact Prisma or Supabase syntax you will still end up checking the docs.
What it helps with
- keep one set of Prisma practices across a team
- remember RLS policies when working with Supabase
- catch N+1 queries before review
- check indexes and constraints in a schema
- remind the agent about connection pooling and caching
Example prompts for the agent
- Add an Order model to
prisma/schema.prismawith a relation to User and an index on the date - Write an RLS policy for the
orderstable in Supabase so a user only sees their own rows - Check this Prisma query for N+1 and load the relations in a single query
How to install database
Manually: put the files in place
.cursor/rules/database.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.claude/rules/database.mdThe paths frontmatter field limits the files: move globs from the source into paths
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.github/instructions/database.instructions.mdThe applyTo field sets which files it applies to: move globs from the source into applyTo
Manually: put the files in place
.devin/rules/database.mdManually: put the files in place
.clinerules/database.mdStep by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules
Questions about database
How do I install database in Cursor?
Create .cursor/rules/database.mdc and paste the rule contents into it. No other install step is needed for Cursor.
What does the database rule do?
It gives the agent Prisma and Supabase practices: schema design, migrations, queries, indexes, RLS policies, connection pooling. It fires when you work with database files.
Which files does the rule apply to?
prisma/**/*, src/db/**/*, **/*.prisma and supabase/**/*. It stays out of other files because alwaysApply is off.
Source text
database.mdc · CC0-1.0
--- description: "Database best practices focusing on Prisma and Supabase integration" globs: prisma/**/*, src/db/**/*, **/*.prisma, supabase/**/* alwaysApply: false --- # Database Best Practices ## Prisma Setup - Use proper schema design - Implement proper migrations - Use proper relation definitions - Configure proper connection - Implement proper seeding - Use proper client setup ## Prisma Models - Use proper model naming - Implement proper relations - Use proper field types - Define proper indexes - Implement proper constraints - Use proper enums ## Prisma Queries - Use proper query optimization - Implement proper filtering - Use proper relations loading - Handle transactions properly - Implement proper pagination - Use proper aggregations ## Supabase Setup - Configure proper project setup - Implement proper authentication - Use proper database setup - Configure proper storage - Implement proper policies - Use proper client setup ## Supabase Security - Implement proper RLS policies - Use proper authentication - Configure proper permissions - Handle sensitive data properly - Implement proper backups - Use proper encryption ## Supabase Queries - Use proper query optimization - Implement proper filtering - Use proper joins - Handle real-time properly - Implement proper pagination - Use proper functions ## Database Design - Use proper normalization - Implement proper indexing - Use proper constraints - Define proper relations - Implement proper cascades - Use proper data types ## Performance - Use proper connection pooling - Implement proper caching - Use proper query optimization - Handle N+1 queries properly - Implement proper batching - Monitor performance metrics ## Security - Use proper authentication - Implement proper authorization - Handle sensitive data properly - Use proper encryption - Implement proper backups - Monitor security issues ## Best Practices - Follow database conventions - Use proper migrations - Implement proper versioning - Handle errors properly - Document schema properly - Monitor database health
© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules