prisma-expert
sickn33/antigravity-awesome-skills
Sie sind Experte für Prisma ORM und verfügen über fundierte Kenntnisse in den Bereichen Schema-Design, Migrationen, Abfrageoptimierung, Beziehungsmodellierung und Datenbankoperationen in PostgreSQL, MySQL und SQLite.
...Alle erweiternÜber prisma-expert
Der Kurs „ prisma-expert “ bietet Entwicklern, die das Prisma-ORM nutzen, spezielle Anleitungen und Lösungen für Herausforderungen beim Schema-Design, bei Datenbankmigrationen, bei der Abfrageoptimierung und bei der relationalen Modellierung in PostgreSQL, MySQL und SQLite. Es hilft Nutzern dabei, häufige Probleme in Prisma-Projekten zu identifizieren und zu beheben, wie beispielsweise Beziehungsfehler, fehlende Indizes, Abweichungen bei Enums und Migrationskonflikte. Durch die Konzentration auf Prisma-spezifische Probleme optimiert dieses Skill Datenbankvorgänge und stellt sicher, dass Schema und Abfragen korrekt den Best Practices entsprechen, wodurch Laufzeitfehler reduziert und die Anwendungsleistung verbessert werden.
Zu den Hauptfunktionen des Skills gehören die Erkennung der Entwicklungsumgebung und der Prisma-Version, die Diagnose von Schema- und Migrationsproblemen sowie die Empfehlung schrittweiser Korrekturen, die von minimalen Anpassungen bis hin zu vollständigen Überarbeitungen reichen. Er bietet strukturierte Anleitungen für das Schema-Design und Migrationen, in denen häufige Probleme, Diagnosebefehle, priorisierte Korrekturen und Best Practices hervorgehoben werden. Das Skill integriert zudem Umgebungsprüfungen, wie beispielsweise die Überprüfung der Prisma-Client-Generierung und bestehender Migrationen, und führt Benutzer durch sichere Migrationsabläufe sowohl für Entwicklungs- als auch für Produktionsumgebungen. Darüber hinaus bietet es Ressourcen und Referenzen zum weiteren Lernen direkt aus der offiziellen Prisma-Dokumentation.
Prisma-expert ist für Backend-Entwickler, Datenbankingenieure und Full-Stack-Entwickler konzipiert, die mit Prisma ORM und relationalen Datenbanken arbeiten. Es ist besonders nützlich in Teamumgebungen, in denen Schemakonsistenz, Migrationsmanagement und Abfrageoptimierung von entscheidender Bedeutung sind. Zu den Anwendungsfällen gehören die Behebung von Schema-Validierungsfehlern, die Leistungsoptimierung von Abfragen, die sichere Verwaltung von Migrationen über Entwicklungs- und Produktionsumgebungen hinweg sowie die Implementierung robuster relationaler Modelle. Durch eine schrittweise Anleitung hilft das Skill den Nutzern, die Zuverlässigkeit der Datenbank zu verbessern, Bereitstellungsrisiken zu reduzieren und effiziente Prisma-basierte Anwendungen zu warten.
FAQ
Welche Datenbanken werden von „ prisma-expert “ unterstützt?
Die Skill bietet Anleitungen für PostgreSQL, MySQL und SQLite bei der Verwendung von Prisma ORM.
Kann „ prisma-expert “ die Optimierung von Raw-SQL oder die Konfiguration von Datenbankservern übernehmen?
Nein, für die Optimierung von Raw-SQL oder die Konfiguration von Datenbankservern empfiehlt es stattdessen, „postgres-expert“, „mongodb-expert“ oder „database-expert“ zu konsultieren.
Wie unterstützt „ prisma-expert “ bei Migrationen?
Es bietet Diagnosebefehle, priorisierte Korrekturen und sichere Migrationsabläufe sowohl für Entwicklungs- als auch für Produktionsumgebungen und hilft so, Konflikte zu lösen und konsistente Datenbankzustände sicherzustellen.
Behebt „ prisma-expert “ Schemaprobleme automatisch?
Es bietet Anleitungen und schrittweise Strategien für Korrekturen, doch die Nutzer müssen die Änderungen manuell mithilfe von Prisma-CLI-Befehlen anwenden.
Welche Voraussetzungen sind für die Nutzung von „ prisma-expert “ erforderlich?
Ein funktionierendes Prisma-Projekt mit einem konfigurierten Schema sowie Zugriff auf die Prisma-CLI und eine Node.js-Umgebung sind erforderlich.
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 versionnpx prisma --version 2>/dev/null || echo "Prisma not installed"# Check database providergrep "provider" prisma/schema.prisma 2>/dev/null | head -1# Check for existing migrationsls -la prisma/migrations/ 2>/dev/null | head -5# Check Prisma Client generation statusls -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
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 schemanpx prisma validate# Check for schema driftnpx prisma migrate diff --from-schema-datamodel prisma/schema.prisma --to-schema-datasource prisma/schema.prisma# Format schemanpx 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 namingmodel 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 statusnpx prisma migrate status# View pending migrationsls -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:
# Developmentnpx prisma migrate dev --name descriptive_name# Production (never use migrate dev!)npx prisma migrate deploy# If migration fails in productionnpx prisma migrate resolve --applied "migration_name"# ornpx 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 eventsconst 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 problemconst users = await prisma.user.findMany();for (const user of users) { const posts = await prisma.post.findMany({ where: { authorId: user.id } });}// GOOD: Include relationsconst users = await prisma.user.findMany({ include: { posts: true }});// BETTER: Select only needed fieldsconst users = await prisma.user.findMany({ select: { id: true, email: true, posts: { select: { id: true, title: true } } }});// BEST for complex queries: Use $queryRawconst result = await prisma.$queryRaw` SELECT u.id, u.email, COUNT(p.id) as post_count FROM users u LEFT JOIN posts p ON p.author_id = 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 shutdownprocess.on('beforeExit', async () => { await prisma.$disconnect();});
# Connection URL with pool settingsDATABASE_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 issuestry { 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 controlconst 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 controlconst updateWithVersion = await prisma.post.update({ where: { id: postId, version: currentVersion // Only update if version matches }, data: { content: newContent, version: { increment: 1 } }});
Resources:
- https://www.prisma.io/docs/concepts/components/prisma-client/transactions
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.
prisma-expert installieren
Laden Sie die Skill-Dateien herunter und entpacken Sie sie in Ihr Verzeichnis „.claude/skills/“.
ZIP herunterladenKlonen Sie das Repository und kopieren Sie die Skill-Dateien in Ihr Projekt.
git clone https://github.com/sickn33/antigravity-awesome-skills/blob/main/skills/prisma-expert/SKILL.md # Copy SKILL.md to your .claude/skills/ directory
Kopieren





Heim
