prisma-expert

Diagnoses and fixes Prisma ORM schema, migration, query, and connection issues.

1|Updated Jul 20, 2026
One-click install
npx skills add https://github.com/gonzoblasco/ai-developer-stack --skill prisma-expert-gonzoblasco
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: prisma-expert
Source: https://github.com/gonzoblasco/ai-developer-stack/tree/main/backend-infra/prisma-expert
Command: npx skills add https://github.com/gonzoblasco/ai-developer-stack --skill prisma-expert-gonzoblasco

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Prisma projects often suffer from N+1 queries, failed migrations, connection pool exhaustion in serverless environments, and schema design mistakes that are hard to diagnose without deep ORM expertise. ## Core Features & Use Cases - Schema Design Review: Validates relation definitions, indexes, cascade behaviors, and naming conventions with npx prisma validate and @@map/@@index patterns. - Safe Migration Workflows: Guides development migrations with migrate dev and production deployments with migrate deploy, including conflict resolution via migrate resolve. - Query Optimization: Detects N+1 problems and over-fetching, then applies include, select, and $queryRaw fixes with query logging for diagnosis. - Connection & Transaction Management: Implements the global singleton pattern for serverless (Vercel/Lambda), pool limits in DATABASE_URL, and interactive transactions with isolation levels and optimistic concurrency. - Use Case: A Next.js app on Vercel hits "too many connections" errors in production; the skill diagnoses the hot-reload client recreation issue and applies the global singleton pattern plus connection_limit tuning. ## Quick Start Ask the assistant to review your prisma/schema.prisma file and diagnose any slow queries or migration errors in your project.

Frequently Asked Questions about prisma-expert

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix N+1 query problems in Prisma?▼

Fix N+1 queries in Prisma by using include to load relations in a single query instead of looping with separate findMany calls. For better performance, use select to fetch only required fields, and use $queryRaw for complex aggregations.

How to run Prisma migrations in production safely?▼

Run production migrations with npx prisma migrate deploy, never migrate dev. If a migration fails, use prisma migrate resolve with --applied or --rolled-back to mark the migration state, and always test migrations before deployment.

Why does Prisma cause too many connections errors on Vercel?▼

Serverless environments create a new PrismaClient on each invocation or hot reload, exhausting database connections. Fix it with a global singleton pattern that reuses the client, and set connection_limit in your DATABASE_URL.

Does Prisma support transactions with isolation levels?▼

Yes, Prisma supports interactive transactions via prisma.$transaction with an async callback, accepting maxWait, timeout, and isolationLevel options such as Serializable. It also supports optimistic concurrency control using version field matching.

When should I use raw SQL instead of Prisma queries?▼

Use prisma.$queryRaw only for complex aggregations or queries Prisma's API cannot express, such as grouped counts with joins. Prefer standard Prisma queries for typical CRUD since they are type-safe and easier to maintain.