
prisma-expert
You are an expert in Prisma ORM with deep knowledge of schema design, migrations, query optimization, relations modeling, and database operations across PostgreSQL, MySQL, and SQLite.
- Installs
- 4.2K
- Last 24h
- —
- Trending rank
- —
- Security
- Pass
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/sickn33/agentic-awesome-skills --skill prisma-expert- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads prisma-expert automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
Security audits
Independent scans of the skill's instructions and bundled files.
SKILL.md
The instructions your agent reads when the skill is triggered.
Prisma Expert
You are an expert in Prisma ORM with deep knowledge of schema design, migrations, query optimization, relations modeling, and database operations across PostgreSQL, MySQL, and SQLite.
When Invoked
Step 0: Recommend Specialist and Stop
If the issue is specifically about:
- Raw SQL optimization: Stop and recommend postgres-expert or mongodb-expert
- Database server configuration: Stop and recommend database-expert
- Connection pooling at infrastructure level: Stop and recommend devops-expert
Environment Detection
# Check Prisma version
npx prisma --version 2>/dev/null || echo "Prisma not installed"
# Check database provider
grep "provider" prisma/schema.prisma 2>/dev/null | head -1
# Check for existing migrations
ls -la prisma/migrations/ 2>/dev/null | head -5
# Check Prisma Client generation status
ls -la node_modules/.prisma/client/ 2>/dev/null | head -3
Apply Strategy
- Identify the Prisma-specific issue category
- Check for common anti-patterns in schema or queries
- Apply progressive fixes (minimal → better → complete)
- Validate with Prisma CLI and testing
These CLI/client patterns depend on the installed Prisma major and engine/driver adapter. Inspect its help before using migration diff flags or pool URL parameters. Do not let npx fetch an unreviewed CLI for detection. The schema fragment omits Profile and the transaction/version examples require application models and fields. A unique email already supplies an index in the shown providers; do not add redundant indexes without query-plan evidence. Log query timing/shape without sensitive values. Reset destroys data; resolve --applied only records history and does not execute missing SQL, while --rolled-back does not undo database changes. Reconcile actual database state, backup and test before resolving or deploying failed migrations. Array transactions cannot pass a generated ID from one operation into the next; use nested writes or the shown interactive transaction for dependent records.
Problem Playbooks
Schema Design
Common Issues:
- Incorrect relation definitions causing runtime errors
- Missing indexes for frequently queried fields
- Enum synchronization issues between schema and database
- Field type mismatches
Diagnosis:
# Validate schema
npx prisma validate
# Check for schema drift
npx prisma migrate diff --from-schema-datamodel prisma/schema.prisma --to-schema-datasource prisma/schema.prisma
# Format schema
npx prisma format
Prioritized Fixes:
- Minimal: Fix relation annotations, add missing
@relationdirectives - Better: Add proper indexes with
@@index, optimize field types - Complete: Restructure schema with proper normalization, add composite keys
Best Practices:
// Good: Explicit relations with clear naming
model User {
id String @id @default(cuid())
email String @unique
posts Post[] @relation("UserPosts")
profile Profile? @relation("UserProfile")
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([email])
@@map("users")
}
model Post {
id String @id @default(cuid())
title String
author User @relation("UserPosts", fields: [authorId], references: [id], onDelete: Cascade)
authorId String
@@index([authorId])
@@map("posts")
}
Resources:
- https://www.prisma.io/docs/concepts/components/prisma-schema
- https://www.prisma.io/docs/concepts/components/prisma-schema/relations
Migrations
Common Issues:
- Migration conflicts in team environments
- Failed migrations leaving database in inconsistent state
- Shadow database issues during development
- Production deployment migration failures
Diagnosis:
# Check migration status
npx prisma migrate status
# View pending migrations
ls -la prisma/migrations/
# Check migration history table
# (use database-specific command)
Prioritized Fixes:
- Minimal: Reset development database with
prisma migrate reset - Better: Manually fix migration SQL, use
prisma migrate resolve - Complete: Squash migrations, create baseline for fresh setup
Safe Migration Workflow:
# Development
npx prisma migrate dev --name descriptive_name
# Production (never use migrate dev!)
npx prisma migrate deploy
# If migration fails in production
npx prisma migrate resolve --applied "migration_name"
# or
npx prisma migrate resolve --rolled-back "migration_name"
Resources:
- https://www.prisma.io/docs/concepts/components/prisma-migrate
- https://www.prisma.io/docs/guides/deployment/deploy-database-changes
Query Optimization
Common Issues:
- N+1 query problems with relations
- Over-fetching data with excessive includes
- Missing select for large models
- Slow queries without proper indexing
Diagnosis:
# Enable query logging
# In schema.prisma or client initialization:
# log: ['query', 'info', 'warn', 'error']
// Enable query events
const prisma = new PrismaClient({
log: [
{ emit: 'event', level: 'query' },
],
});
prisma.$on('query', (e) => {
console.log('Query: ' + e.query);
console.log('Duration: ' + e.duration + 'ms');
});
Prioritized Fixes:
- Minimal: Add includes for related data to avoid N+1
- Better: Use select to fetch only needed fields
- Complete: Use raw queries for complex aggregations, implement caching
Optimized Query Patterns:
// BAD: N+1 problem
const users = await prisma.user.findMany();
for (const user of users) {
const posts = await prisma.post.findMany({ where: { authorId: user.id } });
}
// GOOD: Include relations
const users = await prisma.user.findMany({
include: { posts: true }
});
// BETTER: Select only needed fields
const users = await prisma.user.findMany({
select: {
id: true,
email: true,
posts: {
select: { id: true, title: true }
}
}
});
// BEST for complex queries: Use $queryRaw
const result = await prisma.$queryRaw`
SELECT u.id, u.email, COUNT(p.id) as post_count
FROM users u
LEFT JOIN posts p ON p."authorId" = u.id
GROUP BY u.id
`;
Resources:
- https://www.prisma.io/docs/guides/performance-and-optimization
- https://www.prisma.io/docs/concepts/components/prisma-client/raw-database-access
Connection Management
Common Issues:
- Connection pool exhaustion
- "Too many connections" errors
- Connection leaks in serverless environments
- Slow initial connections
Diagnosis:
# Check current connections (PostgreSQL)
psql -c "SELECT count(*) FROM pg_stat_activity WHERE datname = 'your_db';"
Prioritized Fixes:
- Minimal: Configure connection limit in DATABASE_URL
- Better: Implement proper connection lifecycle management
- Complete: Use connection pooler (PgBouncer) for high-traffic apps
Connection Configuration:
// For serverless (Vercel, AWS Lambda)
import { PrismaClient } from '@prisma/client';
const globalForPrisma = global as unknown as { prisma: PrismaClient };
export const prisma =
globalForPrisma.prisma ||
new PrismaClient({
log: process.env.NODE_ENV === 'development' ? ['query'] : [],
});
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma;
// Graceful shutdown
process.on('beforeExit', async () => {
await prisma.$disconnect();
});
# Connection URL with pool settings
DATABASE_URL="postgresql://user:pass@host:5432/db?connection_limit=5&pool_timeout=10"
Resources:
- https://www.prisma.io/docs/guides/performance-and-optimization/connection-management
- https://www.prisma.io/docs/guides/deployment/deployment-guides/deploying-to-vercel
Transaction Patterns
Common Issues:
- Inconsistent data from non-atomic operations
- Deadlocks in concurrent transactions
- Long-running transactions blocking reads
- Nested transaction confusion
Diagnosis:
// Check for transaction issues
try {
const result = await prisma.$transaction([...]);
} catch (e) {
if (e.code === 'P2034') {
console.log('Transaction conflict detected');
}
}
Transaction Patterns:
// Sequential operations (auto-transaction)
const [user, profile] = await prisma.$transaction([
prisma.user.create({ data: userData }),
prisma.profile.create({ data: profileData }),
]);
// Interactive transaction with manual control
const result = await prisma.$transaction(async (tx) => {
const user = await tx.user.create({ data: userData });
// Business logic validation
if (user.email.endsWith('@blocked.com')) {
throw new Error('Email domain blocked');
}
const profile = await tx.profile.create({
data: { ...profileData, userId: user.id }
});
return { user, profile };
}, {
maxWait: 5000, // Wait for transaction slot
timeout: 10000, // Transaction timeout
isolationLevel: 'Serializable', // Strictest isolation
});
// Optimistic concurrency control
const updateWithVersion = await prisma.post.update({
where: {
id: postId,
version: currentVersion // Only update if version matches
},
data: {
content: newContent,
version: { increment: 1 }
}
});
Resources:
Code Review Checklist
Schema Quality
- All models have appropriate
@idand primary keys - Relations use explicit
@relationwithfieldsandreferences - Cascade behaviors defined (
onDelete,onUpdate) - Indexes added for frequently queried fields
- Enums used for fixed value sets
-
@@mapused for table naming conventions
Query Patterns
- No N+1 queries (relations included when needed)
-
selectused to fetch only required fields - Pagination implemented for list queries
- Raw queries used for complex aggregations
- Proper error handling for database operations
Performance
- Connection pooling configured appropriately
- Indexes exist for WHERE clause fields
- Composite indexes for multi-column queries
- Query logging enabled in development
- Slow queries identified and optimized
Migration Safety
- Migrations tested before production deployment
- Backward-compatible schema changes (no data loss)
- Migration scripts reviewed for correctness
- Rollback strategy documented
Anti-Patterns to Avoid
- Implicit Many-to-Many Overhead: Always use explicit join tables for complex relationships
- Over-Including: Don't include relations you don't need
- Ignoring Connection Limits: Always configure pool size for your environment
- Raw Query Abuse: Use Prisma queries when possible, raw only for complex cases
- Migration in Production Dev Mode: Never use
migrate devin production
When to Use
This skill is applicable to execute the workflow or actions described in the overview.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
FAQ
What does the prisma-expert skill do?
You are an expert in Prisma ORM with deep knowledge of schema design, migrations, query optimization, relations modeling, and database operations across PostgreSQL, MySQL, and SQLite.
How do I install prisma-expert?
Run npx skills add https://github.com/sickn33/agentic-awesome-skills --skill prisma-expert in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/prisma-expert/ (personal) or .claude/skills/prisma-expert/ (project).
Which AI agents can use prisma-expert?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is prisma-expert safe to install?
Security partners have reviewed it: Gen Agent Trust Hub passed; Socket passed; Snyk passed. As with any skill, read the SKILL.md and bundled scripts before installing.
Who maintains prisma-expert?
It is published by sickn33 in sickn33/agentic-awesome-skills. It has 4,177 recorded installs.
More from sickn33/agentic-awesome-skills
docker-expert
sickn33/agentic-awesome-skills
You are an advanced Docker containerization expert with comprehensive, practical knowledge of container optimization, security hardening, multi-stage builds, orchestration patterns, and production deployment strategies based on current industry best practices.
nodejs-best-practices
sickn33/agentic-awesome-skills
Node.js development principles and decision-making. Framework selection, async patterns, security, and architecture. Teaches thinking, not copying.
typescript-expert
sickn33/agentic-awesome-skills
TypeScript and JavaScript expert with deep knowledge of type-level programming, performance optimization, monorepo management, migration strategies, and modern tooling.
clean-code
sickn33/agentic-awesome-skills
This skill embodies the principles of "Clean Code" by Robert C. Martin (Uncle Bob). Use it to transform "code that works" into "code that is clean."
api-security-best-practices
sickn33/agentic-awesome-skills
Implement secure API design patterns including authentication, authorization, input validation, rate limiting, and protection against common API vulnerabilities
nextjs-best-practices
sickn33/agentic-awesome-skills
Next.js App Router principles. Server Components, data fetching, routing patterns.
Popular data & databases skills
supabase-postgres-best-practices
supabase/agent-skills
Postgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill BEFORE writing or changing anything that lives in a Postgres database: creating or altering tables and columns (including choosing column types), schema design, migrations and declarative schema files, RLS policies and the tests that verify them, indexes, triggers, database functions, queues and scheduled jobs (pgcron, pgmq), vector/semantic search (pgvector), and restoring dumps (pgrestore) or importing data. Also load it when diagnosing slow queries, high CPU, timeouts, EXPLAIN plans, connection exhaustion, locking, bloat, or rows visible to the wrong user or tenant. This is not just a performance guide — schema, migration, security, and SQL authoring tasks need these rules too, even for a one-column change or a single query.
prisma-client-api
prisma/skills
Prisma Client API reference covering model queries, filters, operators, and client methods. Use when writing database queries, using CRUD operations, filtering data, or configuring Prisma Client. Triggers on "prisma query", "findMany", "create", "update", "delete", "$transaction".
prisma-database-setup
prisma/skills
Deprecated compatibility name for prisma-orm-setup. Use only when a user or existing integration explicitly invokes prisma-database-setup; otherwise select prisma-orm-setup.
prisma-cli
prisma/skills
Prisma ORM 7 CLI reference for existing Prisma 7 applications or explicitly selected Prisma 7 workflows. Covers prisma init, generate, migrate, db, dev, studio, and mcp. For setup, connection repair, or Prisma 8, use prisma-orm-setup; not the Prisma Platform CLI.
prisma-postgres
prisma/skills
Deprecated compatibility name for prisma-postgres-setup. Use only when a user or existing integration explicitly invokes prisma-postgres; otherwise select prisma-postgres-setup.
prisma-driver-adapter-implementation
prisma/skills
Required reference for Prisma ORM 7 SQL driver adapter work. Use when implementing or modifying adapters, adding database drivers, or touching SqlDriverAdapter, Transaction, savepoint, result mapping, or DriverAdapterError behavior. Covers current transaction lifecycle, optional savepoint hooks, original database-error preservation, and verification.