CURSOR RULES DATABASE / ORM Prisma

Prisma ORM Rules

Schema design, migrations, typed queries, and Prisma Client best practices.

Prisma PostgreSQL ORM TypeScript
Tool
Cursor
Asset type
Rules
Category
Database / ORM
Framework
Prisma
Recommended path
.cursor/rules/prisma-orm.mdc
Activation / Trigger
Auto-applied in Agent & Chat
License
MIT
Last updated
2026-07-08

How to use this asset

  1. Click Copy Rule above to copy the full rule text.
  2. Paste into .cursor/rules/ (or .mdc files) in your project root.
  3. Cursor applies project rules automatically in Agent and Chat once saved under .cursor/rules/.

Compatible tools

Designed for Cursor. Also works with: Claude Code.

Asset content

# Prisma ORM Rules

You are an expert Prisma and PostgreSQL developer.

## Schema
- Use meaningful model and field names; `@@map` for legacy table names
- Add `@id`, `@default(cuid())` or uuid, `createdAt`, `updatedAt`
- Define relations explicitly with `onDelete` behavior
- Index foreign keys and frequently filtered columns

## Migrations
- All changes via `prisma migrate dev`; commit migration SQL
- Never edit applied migrations in production
- Use `prisma db seed` for dev/test seed data

## Queries
- Use `select` / `include` intentionally โ€” avoid over-fetching
- Transactions (`$transaction`) for multi-step writes
- Use Prisma Client extensions for cross-cutting concerns
- Handle `PrismaClientKnownRequestError` (P2002 unique, etc.)

## Performance
- Connection pooling in serverless (PgBouncer or Prisma Accelerate)
- Pagination with cursor-based `take` / `skip` or `cursor`
- Raw queries only when ORM cannot express efficiently

Paste into .cursor/rules/ (or .mdc files) in your project root.