Skip to main content
rule

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.

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/database.mdc
Open on GitHub

What 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.prisma with a relation to User and an index on the date
  • Write an RLS policy for the orders table 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.mdc

Frontmatter: description, globs, alwaysApply

Step 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

Similar IDE rules

All IDE rules for Data and databases →

From the same set68

graphical-apps-development-cursorrules-prompt-file A Cursor rule that feeds the agent the Pyllments context: graph-based LLM apps in Python built on Panel and Langchain. ★ 41,011repo stars flutter-development-guidelines-cursorrules-prompt-file Locks down folder layout, naming and Dart style for Flutter apps built on MVVM with Riverpod. Useful when the agent scatters files across the project. ★ 41,011repo stars embedded-stm32-hal A Cursor rule that keeps the agent inside embedded C/C++ conventions: STM32 HAL, interrupts, DMA and tight memory budgets. ★ 41,011repo stars dragonruby-best-practices-cursorrules-prompt-file A Cursor rule that sets Ruby coding style for DragonRuby Game Toolkit: naming, file structure, error handling. ★ 41,011repo stars cypress-defect-tracking-cursorrules-prompt-file A Cursor rule that turns the agent into a QA engineer: writes Cypress tests tagged by team, category and case ID, and builds reports through qa-shadow-report. ★ 41,011repo stars cursorrules-cursor-ai-wordpress-draft-macos-prompt A Cursor rule that describes the PressThat project: a system tray app that connects to WordPress and creates draft posts. Useful if you work on that app in Cursor. ★ 41,011repo stars cursor-ai-react-typescript-shadcn-ui-cursorrules-p A Cursor rule that pushes the agent toward React and TypeScript code written the way shadcn/ui and Tailwind CSS projects expect. ★ 41,011repo stars code-style-consistency-cursorrules-prompt-file A Cursor rule that makes the agent study your codebase conventions first and write new code to match them. Useful in repos with an established style. ★ 41,011repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor