prisma-schema

Rules for designing Prisma database schemas and migrations. Prisma is a tool that describes database tables in code and creates database changes from those descriptions.

In plain words
What is it for?
Adding business models, relationships, indexes, unique fields, timestamps and safely renaming or changing database columns.
Why use it?
They help prevent orphaned records, slow database queries and accidental data loss during schema changes.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/krivoox/agent-stack-template/prisma-schema
Clone the repo
git clone --depth 1 https://github.com/krivoox/agent-stack-template

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 375 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00375
Opus 5 $0.00000 $0.00187
Sonnet 5 $0.00000 $0.00075
Haiku 4.5 $0.00000 $0.00038

Measured 2d ago against content hash 36d87e387170, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

prisma-schema scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/prisma-schema.mdc · 33 lines

What it actually says

Prisma schema

  1. Tenancy. Every business model carries workspaceId, a relation with onDelete: Cascade, and an index that starts with workspaceId. Without the cascade, deleting a workspace orphans rows; without the index, every scoped list is a sequential scan.
  2. Both sides of a relation are declared, with explicit @relation.
  3. Ids: @id @default(cuid()) for business models. Better Auth models keep the ids the adapter assigns — do not change them.
  4. Timestamps: createdAt @default(now()) and updatedAt @updatedAt on anything a user edits.
  5. Indexes on every field used in a where, orderBy or join. Compound indexes follow query order (@@index([workspaceId, status])).
  6. Uniqueness with @unique / @@unique. Case-insensitive uniqueness has no direct equivalent — enforce it in the domain and say so in a comment.
  7. @@map to snake_case table names; the Better Auth models must keep the names the adapter expects.

Migrations

  • npm run db:migrate in development; the generated SQL is reviewed, not trusted blindly.
  • A rename that Prisma renders as drop + add is data loss. Split it: add the column, backfill, then remove the old one in a later migration.
  • npm run db:push is for local scratch work only. It never runs against a shared database.
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 33 lines · 0 tokens per session scan A 36d87e387170

Subscribe to this mod's changes

prisma-schema is a cursor rule published in the GitHub repository krivoox/agent-stack-template (31 stars, last pushed 12d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 375 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.