← ClaudeAtlas

prisma-patternslisted

Use when writing or reviewing Prisma ORM code in TypeScript backends — schema design, query optimization, transactions, pagination, and serverless deployment. Covers critical traps like updateMany returning a count not records, the 5s interactive $transaction timeout, migrate dev resetting the DB, @updatedAt skipped on bulk writes, P-code error handling, and serverless connection exhaustion.
Mixard/fable-pack · ★ 1 · API & Backend · score 74
Install: claude install-skill Mixard/fable-pack
# Prisma Patterns Production patterns and non-obvious traps for Prisma ORM in TypeScript backends. > **Check your version before applying patterns.** The Prisma API surface has evolved across major releases: > > ```bash > npx prisma --version > ``` > > Notable API differences across versions: > - `relationJoins` can load relations via JOIN rather than separate queries, but may cause row explosion on large 1:N relations or deep `include` — benchmark both approaches > - `omit` field modifier and `prisma.$extends` Client Extensions API were added > - **Newer installs**: the package may be named `prisma` instead of `@prisma/client`; `PrismaClient` may require a driver adapter (e.g. `@prisma/adapter-pg`); `datasource.url` may live in `prisma.config.ts` instead of `schema.prisma` > - CLI commands (`migrate dev`, `migrate deploy`, `generate`) are unchanged across versions ## When to Activate - Designing or modifying Prisma schema models and relations - Writing queries, transactions, or pagination logic - Using `updateMany`, `deleteMany`, or any bulk operation - Running or planning database migrations - Deploying to serverless environments (Vercel, Lambda, Cloudflare Workers) - Implementing soft delete or multi-tenant row filtering ## Core Concepts ### ID Strategy | Strategy | Use When | Avoid When | |---|---|---| | `@default(cuid())` | Default choice — URL-safe, sortable, no collisions | Sequential IDs needed for external systems | | `@default(uuid())` | Interoperability with