Install any skill in seconds. Free to start, no credit card required.
Get Started Free →This skill provides comprehensive Drizzle ORM patterns for PostgreSQL with Vercel Edge Runtime support. Drizzle is Quetrex's chosen ORM because it's edge-first, type-safe, and supports all deployme...
.claude/skills/aiskillstore-drizzle-orm-patterns/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-08 | ✗→✓ | ▲ Improved | 69% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 167% | 0% |
| case-18 | ✗→✓ | ▲ Improved | 84% | 0% |
| case-21 | ✗→✓ | ▲ Improved | 81% | 0% |
| case-14 | ✓→✓ | = Same ✓ | 90% | 0% |
Use when: Working with database operations, schema design, migrations, or queries in Quetrex.
This skill provides comprehensive Drizzle ORM patterns for PostgreSQL with Vercel Edge Runtime support. Drizzle is Quetrex's chosen ORM because it's edge-first, type-safe, and supports all deployment targets.
This skill is organized into focused modules:
Complete query patterns: select, insert, update, delete, joins, pagination, filtering, aggregations, subqueries, CTEs.
When to use:
Transaction patterns: isolation levels, rollback, nested transactions, error handling, deadlock prevention.
When to use:
Relationship patterns: one-to-one, one-to-many, many-to-many, self-referencing, cascading deletes, nested queries.
When to use:
Migration patterns: schema evolution, data migrations, zero-downtime deployments, rollback strategies.
When to use:
Edge deployment patterns: Vercel Edge Functions, Neon serverless, connection pooling, HTTP-based connections.
When to use:
Performance patterns: indexing, query optimization, N+1 prevention, batch operations, caching.
When to use:
TypeScript inference patterns: InferModel, InferSelect, InferInsert, schema types, custom types.
When to use:
Common pitfalls and fixes: SQL injection risks, N+1 queries, missing indexes, transaction deadlocks, type errors.
When to use:
Python script to validate Drizzle queries for common security and performance issues.
When to use:
bash# Core packages npm install drizzle-orm @neondatabase/serverless # Development tools npm install -D drizzle-kit
typescript// src/lib/db.ts import { drizzle } from 'drizzle-orm/neon-http'; import { neon } from '@neondatabase/serverless'; const sql = neon(process.env.DATABASE_URL!); export const db = drizzle(sql);
typescript// src/lib/schema.ts import { pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core'; export const users = pgTable('users', { id: serial('id').primaryKey(), email: text('email').notNull().unique(), name: text('name').notNull(), createdAt: timestamp('created_at').defaultNow().notNull(), });
typescript// src/services/user-service.ts import { db } from '@/lib/db'; import { users } from '@/lib/schema'; import { eq } from 'drizzle-orm'; export async function getUserByEmail(email: string) { return await db.select().from(users).where(eq(users.email, email)).limit(1); }
typescriptimport { db } from '@/lib/db'; import { users } from '@/lib/schema'; import { eq, and, gte } from 'drizzle-orm'; const activeUsers = await db .select() .from(users) .where( and( eq(users.status, 'active'), gte(users.createdAt, new Date('2024-01-01')) ) );
typescriptconst [newUser] = await db .insert(users) .values({ email: 'test@example.com', name: 'Test User', }) .returning();
typescriptconst [updatedUser] = await db .update(users) .set({ name: 'Updated Name' }) .where(eq(users.id, 1)) .returning();
typescriptawait db.transaction(async (tx) => { const [user] = await tx.insert(users).values({ email, name }).returning(); await tx.insert(profiles).values({ userId: user.id, bio }); });
typescriptconst usersWithProfiles = await db .select({ userId: users.id, userName: users.name, bio: profiles.bio, }) .from(users) .leftJoin(profiles, eq(users.id, profiles.userId));
All database code must have:
Before committing database code:
select * in production codepython validate-queries.py on changed filesBefore committing database code:
select *)If you're migrating from Prisma, see the ADR-002-DRIZZLE-ORM-MIGRATION.md decision record.
Key differences:
For Drizzle-specific questions:
For Quetrex-specific questions:
/docs/architecture/Last Updated: 2025-11-23 by Glen Barnhardt with help from Claude Code
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-14 | pass→pass | 13,414 | 17,031 | +27% | 1 | 1 | 0% | 2,216 | 4,203 | +90% | 0 | 0 | — |
case-01 | pass→pass | 15,699 | 16,056 | +2% | 1 | 1 | 0% | 2,658 | 4,231 | +59% | 0 | 0 | — |
case-02 | pass→pass | 7,762 | 14,142 | +82% | 1 | 1 | 0% | 1,323 | 3,981 | +201% | 0 | 0 | — |
case-03 | pass→pass | 8,614 | 9,517 | +10% | 1 | 1 | 0% | 1,254 | 2,905 | +132% | 0 | 0 | — |
case-04 | pass→pass | 14,659 | 11,879 | -19% | 1 | 1 | 0% | 1,969 | 3,683 | +87% | 0 | 0 | — |
case-05 | pass→pass | 15,345 | 14,040 | -9% | 1 | 1 | 0% | 1,799 | 4,065 | +126% | 0 | 0 | — |
case-06 | pass→pass | 11,521 | 10,754 | -7% | 1 | 1 | 0% | 2,219 | 4,189 | +89% | 0 | 0 | — |
case-07 | pass→pass | 5,006 | 3,540 | -29% | 1 | 1 | 0% | 913 | 2,852 | +212% | 0 | 0 | — |
case-08 | fail→pass | 15,267 | 4,657 | -69% | 1 | 1 | 0% | 1,562 | 2,642 | +69% | 0 | 0 | — |
case-09 | fail→pass | 14,589 | 11,961 | -18% | 1 | 1 | 0% | 1,487 | 3,969 | +167% | 0 | 0 | — |
case-10 | pass→pass | 10,455 | 13,796 | +32% | 1 | 1 | 0% | 1,956 | 3,848 | +97% | 0 | 0 | — |
case-11 | pass→pass | 8,430 | 10,098 | +20% | 1 | 1 | 0% | 1,118 | 2,981 | +167% | 0 | 0 | — |
case-12 | pass→pass | 11,425 | 7,193 | -37% | 1 | 1 | 0% | 1,277 | 3,132 | +145% | 0 | 0 | — |
case-13 | pass→pass | 11,574 | 3,667 | -68% | 1 | 1 | 0% | 843 | 2,807 | +233% | 0 | 0 | — |
case-15 | pass→pass | 8,269 | 15,081 | +82% | 1 | 1 | 0% | 1,672 | 4,080 | +144% | 0 | 0 | — |
case-16 | pass→pass | 7,322 | 3,324 | -55% | 1 | 1 | 0% | 1,078 | 2,586 | +140% | 0 | 0 | — |
case-17 | pass→pass | 10,562 | 9,784 | -7% | 1 | 1 | 0% | 742 | 3,074 | +314% | 0 | 0 | — |
case-18 | fail→pass | 17,847 | 11,628 | -35% | 1 | 1 | 0% | 1,824 | 3,364 | +84% | 0 | 0 | — |
case-19 | pass→pass | 6,805 | 3,878 | -43% | 1 | 1 | 0% | 1,082 | 2,750 | +154% | 0 | 0 | — |
case-20 | pass→pass | 4,685 | 12,459 | +166% | 1 | 1 | 0% | 867 | 3,015 | +248% | 0 | 0 | — |
case-21 | fail→pass | 10,183 | 9,741 | -4% | 1 | 1 | 0% | 1,696 | 3,070 | +81% | 0 | 0 | — |
case-22 | pass→pass | 13,942 | 5,938 | -57% | 1 | 1 | 0% | 1,194 | 3,117 | +161% | 0 | 0 | — |
case-23 | pass→pass | 8,035 | 4,326 | -46% | 1 | 1 | 0% | 497 | 2,832 | +470% | 0 | 0 | — |
case-24 | pass→pass | 12,502 | 12,368 | -1% | 1 | 1 | 0% | 1,205 | 3,326 | +176% | 0 | 0 | — |
case-25 | pass→pass | 12,449 | 6,055 | -51% | 1 | 1 | 0% | 1,386 | 3,366 | +143% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 25 cases were attempted. The headline lift of +16 percentage points is the difference between those two pass rates over the 25 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.