What problem does it solve? Writing Prisma database code often leads to N+1 query problems, unoptimized field selection, inconsistent error handling, and scattered data access logic. This Skill provides proven patterns for structuring Prisma Client usage so database operations stay performant, type-safe, and maintainable. ## Core Features & Use Cases - Query & Relation Patterns: Covers findUnique, findMany, complex AND/OR filtering, nested writes, and one-to-many relation loading with include and select. - Transaction & Error Handling: Demonstrates interactive $transaction usage with timeouts and mapping Prisma error codes (P2002, P2003, P2025) to domain exceptions. - Performance Optimization: Shows how to prevent N+1 queries via include or batched where-in queries, limit fields with select, and use aggregations, groupBy, and upsert. - Use Case: When building a NestJS or Node.js service, apply the repository template to centralize user data access, wrap multi-step writes in transactions, and avoid N+1 queries when loading user profiles. ## Quick Start Ask the agent to refactor a service that fetches users and their profiles so it uses a Prisma repository with include-based N+1 prevention and proper P2002 error handling.