
Drizzle Orm
Model PostgreSQL, MySQL, or SQLite in TypeScript with compile-time-safe schemas, queries, and Drizzle Kit migrations for solo SaaS and API projects.
Overview
Drizzle ORM is an agent skill for the Build phase that teaches type-safe TypeScript SQL modeling, drivers, and Drizzle Kit migrations with minimal runtime overhead.
Install
npx skills add https://github.com/bobmatnyc/claude-mpm-skills --skill drizzle-ormWhat is this skill?
- Type-safe pg/mysql/sqlite schemas with zero-runtime overhead and SQL-like syntax
- Install paths for drizzle-orm, drivers (pg, mysql2, better-sqlite3), and drizzle-kit for migrations
- Progressive-disclosure references: query-patterns, performance, advanced-schemas, vs-prisma
- Edge and serverless–friendly patterns versus heavier ORMs
- Quick-start flow: schema in db/schema.ts, client via drizzle + Pool, migrations with Drizzle Kit
- 4 topical reference guides (query-patterns, performance, advanced-schemas, vs-prisma)
Adoption & trust: 4.3k installs on skills.sh; 53 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need a database layer in TypeScript but default ORMs feel heavy, opaque, or weak on edge and serverless deploy targets.
Who is it for?
Solo builders starting or refactoring a TypeScript backend who want SQL control with strong types and Drizzle Kit migrations.
Skip if: Teams already standardized on Prisma with no migration appetite, or greenfield projects that only need a hosted BaaS with no custom SQL.
When should I use this skill?
When working with drizzle-orm or related functionality.
What do I get? / Deliverables
You get concrete schema, client, and migration patterns so queries and migrations stay type-checked and SQL-transparent in your codebase.
- Typed schema modules
- Drizzle client setup
- Migration workflow via Drizzle Kit
Recommended Skills
Journey fit
ORM setup, schema design, and query patterns belong on the build shelf where persistence layers are implemented. Drizzle is backend data-access work—schemas, drivers, and SQL-shaped queries—not frontend or ship-only testing.
How it compares
Procedural ORM skill for in-repo TypeScript—not a managed database product or MCP server.
Common Questions / FAQ
Who is drizzle-orm for?
Indie and solo developers building TypeScript APIs, SaaS backends, or tools who want typed SQL without a large ORM runtime.
When should I use drizzle-orm?
During Build when defining schemas, wiring drivers, writing queries, or setting up drizzle-kit migrations—especially for PostgreSQL, MySQL, or SQLite on Node or edge-style runtimes.
Is drizzle-orm safe to install?
Treat it like any third-party skill: review the Security Audits panel on this Prism page and inspect the skill source in your repo before letting an agent run install or migration commands.
SKILL.md
READMESKILL.md - Drizzle Orm
# Drizzle ORM Modern TypeScript-first ORM with zero dependencies, compile-time type safety, and SQL-like syntax. Optimized for edge runtimes and serverless environments. ## Quick Start ### Installation ```bash # Core ORM npm install drizzle-orm # Database driver (choose one) npm install pg # PostgreSQL npm install mysql2 # MySQL npm install better-sqlite3 # SQLite # Drizzle Kit (migrations) npm install -D drizzle-kit ``` ### Basic Setup ```typescript // db/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(), }); // db/client.ts import { drizzle } from 'drizzle-orm/node-postgres'; import { Pool } from 'pg'; import * as schema from './schema'; const pool = new Pool({ connectionString: process.env.DATABASE_URL }); export const db = drizzle(pool, { schema }); ``` ### First Query ```typescript import { db } from './db/client'; import { users } from './db/schema'; import { eq } from 'drizzle-orm'; // Insert const newUser = await db.insert(users).values({ email: 'user@example.com', name: 'John Doe', }).returning(); // Select const allUsers = await db.select().from(users); // Where const user = await db.select().from(users).where(eq(users.id, 1)); // Update await db.update(users).set({ name: 'Jane Doe' }).where(eq(users.id, 1)); // Delete await db.delete(users).where(eq(users.id, 1)); ``` ## Schema Definition ### Column Types Reference | PostgreSQL | MySQL | SQLite | TypeScript | |------------|-------|--------|------------| | `serial()` | `serial()` | `integer()` | `number` | | `text()` | `text()` | `text()` | `string` | | `integer()` | `int()` | `integer()` | `number` | | `boolean()` | `boolean()` | `integer()` | `boolean` | | `timestamp()` | `datetime()` | `integer()` | `Date` | | `json()` | `json()` | `text()` | `unknown` | | `uuid()` | `varchar(36)` | `text()` | `string` | ### Common Schema Patterns ```typescript import { pgTable, serial, text, varchar, integer, boolean, timestamp, json, unique } from 'drizzle-orm/pg-core'; export const users = pgTable('users', { id: serial('id').primaryKey(), email: varchar('email', { length: 255 }).notNull().unique(), passwordHash: varchar('password_hash', { length: 255 }).notNull(), role: text('role', { enum: ['admin', 'user', 'guest'] }).default('user'), metadata: json('metadata').$type<{ theme: string; locale: string }>(), isActive: boolean('is_active').default(true), createdAt: timestamp('created_at').defaultNow().notNull(), updatedAt: timestamp('updated_at').defaultNow().notNull(), }, (table) => ({ emailIdx: unique('email_unique_idx').on(table.email), })); // Infer TypeScript types type User = typeof users.$inferSelect; type NewUser = typeof users.$inferInsert; ``` ## Relations ### One-to-Many ```typescript import { pgTable, serial, text, integer } from 'drizzle-orm/pg-core'; import { relations } from 'drizzle-orm'; export const authors = pgTable('authors', { id: serial('id').primaryKey(), name: text('name').notNull(), }); export const posts = pgTable('posts', { id: serial('id').primaryKey(), title: text('title').notNull(), authorId: integer('author_id').notNull().references(() => authors.id), }); export const author