Back to Skills

prisma-patterns

Prisma ORM patterns for TypeScript backends — schema design, query optimization, transactions, pagination, and critical traps like updateMany returning count not records, $transaction timeouts, migrate dev resetting the DB, @updatedAt skipped on bulk writes, and serverless connection exhaustion.

234,208stars35,691forksUpdated 7/28/2026

Security Assessment

Safe(96/100)
Security Score96/100

About prisma-patterns

Prisma Patterns is a reference skill that captures production-grade patterns and non-obvious traps for using the Prisma ORM in TypeScript backends. It solves the problem of subtle, hard-to-debug behaviors that experienced teams keep rediscovering — for example, that updateMany returns an affected-row count rather than the records themselves, that migrate dev can reset the database, that the @updatedAt field is skipped on bulk writes, that $transaction calls can time out, and that serverless deployments can exhaust the connection pool. It opens by reminding the reader to check their Prisma version, since the API surface has shifted across major releases.

The skill is documented guidance rather than executable tooling. It covers schema design (ID strategy trade-offs between cuid, uuid, and autoincrement; when to add indexes; declaring soft-delete columns upfront), the difference between include and select for controlling over-fetching, mapping entities to response DTOs to avoid leaking sensitive fields, choosing between array-form and interactive transactions, the PrismaClient singleton pattern to prevent connection exhaustion during hot reload, avoiding N+1 queries, and cursor-based pagination for feeds and large datasets. Guidance is illustrated with annotated good and bad TypeScript snippets.

It targets backend and full-stack TypeScript engineers who build on Prisma, particularly those deploying to serverless platforms such as Vercel, Lambda, or Cloudflare Workers, or implementing soft delete and multi-tenant row filtering. It is most useful when designing schemas, writing queries or transactions, planning migrations, or reviewing code for the traps it enumerates.

FAQ

When should I reach for this skill?

When designing or modifying Prisma schema models and relations, writing queries or transactions or pagination logic, using bulk operations like updateMany or deleteMany, planning migrations, deploying to serverless environments, or implementing soft delete and multi-tenant filtering.

Does it work with any Prisma version?

It advises checking your version first with npx prisma --version, since the API has evolved. It notes differences such as relationJoins, the omit modifier and Client Extensions, newer installs requiring a driver adapter, and datasource config moving to prisma.config.ts, while CLI commands like migrate dev and generate stay the same.

What are the main traps it warns about?

updateMany returning a count rather than records, $transaction timeouts, migrate dev resetting the database, @updatedAt being skipped on bulk writes, and serverless connection pool exhaustion.

Does it help with securing API responses?

Yes. It recommends never returning raw Prisma entities from API responses and instead mapping to explicit DTOs so internal fields like password hashes and deletedAt are not leaked.

Is this runnable code or guidance?

It is a single SKILL.md of documented patterns and annotated TypeScript examples, meant to guide how you write Prisma code rather than an executable tool.

Install prisma-patterns

Download and extract the skill files to your .claude/skills/ directory.

Quick Setup:

  1. Copy the skill folder to .claude/skills/
  2. Claude will automatically detect and use the skill