drizzle-orm
БесплатноБез исполняемых скриптовНе проверенUse when modeling data or querying with Drizzle ORM in TypeScript — `pgTable` schema in `.ts`, type-safe select/insert/relational queries, `drizzle-kit`…
от lza6★ 19 звёзд на GitHubОб этом скилле
Drizzle ORM — schema as code, type-safe queries, drizzle-kit migrations
Drizzle is the SQL-transparent TypeScript ORM: you declare tables in plain .ts, the query
builder emits SQL you can read, and there is no codegen client to regenerate. It runs in
edge/serverless runtimes. You own the schema, the queries, and the drizzle-kit workflow here —
the database engine, the ORM-agnostic migration strategy, and Prisma live in sibling skills.
Decide first
Three decisions before you write a line. Each branches, so use the table.
| Decision | Pick | Why |
|---|---|---|
| Drizzle vs Prisma | Drizzle when you want SQL you can read, no codegen step, edge runtime | Prisma's generated client + schema.prisma DSL is the opposite trade — use ../prisma-orm/SKILL.md if that is the ask |
| Version | 0.45.x + [email protected] for production |
npm latest is [email protected]; the 0.45 line has been latest since 2025-12-04 (checked 2026-06-02) |
| Version | 1.0.0-rc.x (npm rc tag = 1.0.0-rc.3, 2026-05-18) for a NEW edge-first project |
v1 has moved past beta into release candidates with Relations v2 — close to stable, but still pin an exact rc and expect late API churn |
| Driver entrypoint | match it to your DB/host (see below) | Each driver has its own drizzle-orm/<driver> import and its own client |
Driver entrypoints (pick one; full matrix + edge caveats in references/relations-and-drivers.md):
drizzle-orm/node-postgres, /postgres-js, /neon-http, /libsql (Turso), /planetscale-serverless,
/mysql2, /better-sqlite3, /bun-sqlite.
Install & config
npm i drizzle-orm
npm i -D drizzle-kit
npm i postgres # the driver client — here postgres-js; swap per your DB
drizzle.config.ts — the four keys drizzle-kit reads. The dialect here MUST match your table
helper (pgTable ⇒ 'postgresql'), or migrations target the wrong SQL.
import { defineConfig } from 'drizzle-kit';
export default defineConfig({
dialect: 'postgresql', // 'postgresql' | 'mysql' | 'sqlite' | 'turso'
schema: './src/db/schema.ts', // where your tables live
out: './drizzle', // emitted migration SQL
dbCredentials: { url: process.env.DATABASE_URL! },
});
package.json scripts — name them once so you never re-type the CLI:
{
"scripts": {
"db:generate": "drizzle-kit generate",
"db:migrate": "drizzle-kit migrate",
"db:push": "drizzle-kit push",
"db:studio": "drizzle-kit studio"
}
}
Schema as code
A table is plain TypeScript. Declare columns with the helpers, then derive your row types from the
table — never hand-write a parallel interface, it will drift.
import { pgTable, integer, text, timestamp, pgEnum, index } from 'drizzle-orm/pg-core';
export const roleEnum = pgEnum('role', ['admin', 'member']);
export const users = pgTable('users', {
id: integer().primaryKey().generatedAlwaysAsIdentity(),
email: text().notNull().unique(),
role: roleEnum().notNull().default('member'),
createdAt: timestamp().notNull().defaultNow(),
}, (t) => [index('users_email_idx').on(t.email)]);
export const posts = pgTable('posts', {
id: integer().primaryKey().generatedAlwaysAsIdentity(),
authorId: integer().notNull().references(() => users.id), // FK
title: text().notNull(),
});
export type User = typeof users.$inferSelect; // row as read
export type NewUser = typeof users.$inferInsert; // row as inserted
- One schema file per domain, and export every table.
drizzle-kitand the relational query builder only see what you pass them — an unexported table is invisible to migrations. - Derive types with
$inferSelect/$inferInsert. They stay in sync with the column defs for free; a separate interface is one more thing to forget to update.
Connect
drizzle() takes your driver client. Pass { schema } (0.45 / v1-compat) or { relations }
(v2, the 1.0 rc line) — without one of them, db.query.* is undefined and relational reads
silently break.
import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';
import * as schema from './schema';
const client = postgres(process.env.DATABASE_URL!);
export const db = drizzle(client, { schema }); // schema enables db.query.*
Query
Filter, join, and shape in SQL — not in JavaScript after the fact.
import { eq, and, inArray, desc } from 'drizzle-orm';
// select a column subset, not the whole row
const admins = await db.select({ id: users.id, email: users.email })
.from(users)
.where(and(eq(users.role, 'admin'), inArray(users.id, [1, 2, 3])))
.orderBy(desc(users.createdAt));
// insert + get the row back
const [created] = await db.insert(users)
.values({ email: '[email protected]', role: 'member' })
.returning();
// update / delete take the same operators
await db.update(users).set({ role: 'admin' }).where(eq(users.id, created.id));
await db.delete(posts).where(eq(posts.authorId,
Установить drizzle-orm в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл drizzle-orm?
Use when modeling data or querying with Drizzle ORM in TypeScript — `pgTable` schema in `.ts`, type-safe select/insert/relational queries, `drizzle-kit` migrations. NOT Prisma Client or `schema.prisma` (that is `prisma-orm`), NOT ORM-agnostic migration strategy (that is `db-migrations`), NOT Postgres engine tuning or EXPLAIN (that is `postgresdb`).
Как установить скилл drizzle-orm?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл drizzle-orm запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic