Prisma ORM patterns — schema design, migrations, type-safe queries, testing, error handling, and performance
96
95%
Does it follow best practices?
Impact
100%
1.28xAverage score across 3 eval scenarios
Passed
No known issues
{
"context": "Tests whether the agent writes Prisma data access code following the skill's patterns: select for list views, include for detail views, no N+1 queries, transactions for multi-model writes with `tx` variable, error code handling for P2025, bulk updateMany for batch operations, and singleton PrismaClient.",
"type": "weighted_checklist",
"checklist": [
{
"name": "select for list view",
"description": "`listOrders` uses `select` (not `include`) to return only a subset of fields",
"max_score": 9
},
{
"name": "include for detail view",
"description": "`getOrderDetail` uses `include` to load related items and products in a single query",
"max_score": 9
},
{
"name": "No N+1 in detail",
"description": "`getOrderDetail` does NOT loop over results calling additional queries per record (no fluent API pattern like `.items()` inside a loop)",
"max_score": 9
},
{
"name": "Transaction for order creation",
"description": "`placeOrder` uses `prisma.$transaction(async (tx) => { ... })` to wrap the order and items creation",
"max_score": 10
},
{
"name": "Uses tx inside transaction",
"description": "All database operations inside the `$transaction` callback use `tx`, NOT `prisma`",
"max_score": 10
},
{
"name": "P2025 error handling",
"description": "`getOrderDetail` catches `Prisma.PrismaClientKnownRequestError` and checks for error code `P2025` (or handles the null/undefined case from findUnique) to throw a typed not-found error",
"max_score": 10
},
{
"name": "Bulk updateMany for cancellation",
"description": "`cancelStaleOrders` uses `updateMany` to cancel all matching orders in a single query, NOT a loop calling `update` per order",
"max_score": 10
},
{
"name": "Singleton client pattern",
"description": "`lib/prisma.ts` uses `globalThis` to store the PrismaClient and only assigns it in non-production environments (prevents hot-reload connection leaks)",
"max_score": 9
},
{
"name": "Conditional logging",
"description": "PrismaClient is instantiated with `log` set to `['query', 'warn', 'error']` in development and `['error']` in production (based on `NODE_ENV`)",
"max_score": 9
},
{
"name": "No select+include mix",
"description": "No query uses both `select` and `include` at the same level of the query object",
"max_score": 8
},
{
"name": "Import from @prisma/client",
"description": "The file imports `Prisma` (or `PrismaClient`) from `'@prisma/client'`",
"max_score": 7
}
]
}