Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Provides comprehensive Drizzle ORM patterns for schema definition, CRUD operations, relations, queries, transactions, and migrations. Proactively use for any Drizzle ORM development including defining database schemas, writing type-safe queries, implementing relations, managing transactions, and setting up migrations with Drizzle Kit. Supports PostgreSQL, MySQL, SQLite, MSSQL, and CockroachDB.
.claude/skills/giuseppe-trisciuoglio-drizzle-orm-patterns/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-06 | ✗→✓ | ▲ Improved | -4% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 17% | 0% |
| case-16 | ✓→✓ | = Same ✓ | 172% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 248% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 314% | 0% |
Expert guide for building type-safe database applications with Drizzle ORM. Covers schema definition, relations, queries, transactions, and migrations for all supported databases.
| Database | Table Function | Import | |----------|---------------|--------| | PostgreSQL | pgTable() | drizzle-orm/pg-core | | MySQL | mysqlTable() | drizzle-orm/mysql-core | | SQLite | sqliteTable() | drizzle-orm/sqlite-core | | MSSQL | mssqlTable() | drizzle-orm/mssql-core |
| Operation | Method | Example | |-----------|--------|---------| | Insert | db.insert() | db.insert(users).values({...}) | | Select | db.select() | db.select().from(users).where(eq(...)) | | Update | db.update() | db.update(users).set({...}).where(...) | | Delete | db.delete() | db.delete(users).where(...) | | Transaction | db.transaction() | db.transaction(async (tx) => {...}) |
relations() or defineRelations()typescriptimport { pgTable, serial, text } from 'drizzle-orm/pg-core'; import { drizzle } from 'drizzle-orm/node-postgres'; import { eq } from 'drizzle-orm'; export const users = pgTable('users', { id: serial('id').primaryKey(), name: text('name').notNull(), email: text('email').notNull().unique(), }); const db = drizzle(process.env.DATABASE_URL); const [user] = await db.select().from(users).where(eq(users.id, 1));
typescriptimport { eq } from 'drizzle-orm'; // Insert const [newUser] = await db.insert(users).values({ name: 'John', email: 'john@example.com', }).returning(); // Update await db.update(users) .set({ name: 'John Updated' }) .where(eq(users.id, 1)); // Delete await db.delete(users).where(eq(users.id, 1));
typescriptawait db.transaction(async (tx) => { const [from] = await tx.select().from(accounts) .where(eq(accounts.userId, fromId)); if (from.balance < amount) { tx.rollback(); } await tx.update(accounts) .set({ balance: sql`${accounts.balance} - ${amount}` }) .where(eq(accounts.userId, fromId)); });
See references/transactions.md for advanced transaction patterns.
$inferInsert / $inferSelectgenerate + migrate in production, push for developmentdeletedAt timestamp instead of hard deletes when possible.limit() and .where() to fetch only needed data() => table.column to avoid circular dependency issuestx.rollback() throws an exception - use try/catch if needed.returning() - check your dialect compatibility| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-16 | pass→pass | 3,998 | 3,059 | -23% | 1 | 1 | 0% | 671 | 1,825 | +172% | 0 | 0 | — |
case-01 | pass→pass | 3,154 | 3,480 | +10% | 1 | 1 | 0% | 574 | 1,998 | +248% | 0 | 0 | — |
case-02 | pass→pass | 2,789 | 1,920 | -31% | 1 | 1 | 0% | 411 | 1,701 | +314% | 0 | 0 | — |
case-03 | pass→pass | 2,148 | 2,244 | +4% | 1 | 1 | 0% | 290 | 1,743 | +501% | 0 | 0 | — |
case-04 | pass→pass | 2,709 | 2,204 | -19% | 1 | 1 | 0% | 435 | 1,713 | +294% | 0 | 0 | — |
case-05 | pass→pass | 12,855 | 9,006 | -30% | 1 | 1 | 0% | 2,152 | 3,057 | +42% | 0 | 0 | — |
case-06 | fail→pass | 15,671 | 6,642 | -58% | 1 | 1 | 0% | 2,527 | 2,427 | -4% | 0 | 0 | — |
case-07 | pass→pass | 13,029 | 9,231 | -29% | 1 | 1 | 0% | 2,080 | 2,948 | +42% | 0 | 0 | — |
case-08 | fail→pass | 13,171 | 6,962 | -47% | 1 | 1 | 0% | 2,244 | 2,615 | +17% | 0 | 0 | — |
case-09 | pass→pass | 2,640 | 2,416 | -8% | 1 | 1 | 0% | 401 | 1,783 | +345% | 0 | 0 | — |
case-10 | pass→pass | 3,294 | 2,696 | -18% | 1 | 1 | 0% | 490 | 1,831 | +274% | 0 | 0 | — |
case-11 | pass→pass | 3,025 | 4,722 | +56% | 1 | 1 | 0% | 468 | 2,154 | +360% | 0 | 0 | — |
case-12 | pass→pass | 11,301 | 7,083 | -37% | 1 | 1 | 0% | 1,857 | 2,683 | +44% | 0 | 0 | — |
case-13 | pass→pass | 3,777 | 2,691 | -29% | 1 | 1 | 0% | 539 | 1,769 | +228% | 0 | 0 | — |
case-14 | pass→pass | 1,970 | 2,759 | +40% | 1 | 1 | 0% | 342 | 1,931 | +465% | 0 | 0 | — |
case-15 | pass→pass | 2,678 | 2,498 | -7% | 1 | 1 | 0% | 410 | 1,833 | +347% | 0 | 0 | — |
case-17 | pass→pass | 5,534 | 1,778 | -68% | 1 | 1 | 0% | 813 | 1,646 | +102% | 0 | 0 | — |
case-18 | pass→pass | 7,715 | 3,664 | -53% | 1 | 1 | 0% | 1,329 | 1,983 | +49% | 0 | 0 | — |
case-19 | pass→pass | 4,954 | 2,740 | -45% | 1 | 1 | 0% | 791 | 1,803 | +128% | 0 | 0 | — |
case-20 | pass→pass | 7,321 | 4,852 | -34% | 1 | 1 | 0% | 1,270 | 2,211 | +74% | 0 | 0 | — |
case-21 | pass→pass | 4,240 | 3,300 | -22% | 1 | 1 | 0% | 786 | 1,943 | +147% | 0 | 0 | — |
case-22 | pass→pass | 6,833 | 8,361 | +22% | 1 | 1 | 0% | 1,209 | 2,912 | +141% | 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. 22 cases were attempted. The headline lift of +9 percentage points is the difference between those two pass rates over the 22 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.