/ts-dev-kit:drizzle-pgfrom ts-dev-kit
Defines Drizzle ORM reference for PostgreSQL covering schema definition, typesafe queries, relations, migrations with drizzle-kit, and configuration.
Ships in ts-dev-kit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Drizzle is a headless TypeScript ORM. Zero dependencies, SQL-like API, single-query output.
Packages: drizzle-orm (runtime), drizzle-kit (CLI/migrations).
import { drizzle } from "drizzle-orm/node-postgres";
import * as schema from "./schema";
import { relations } from "./relations";
const db = drizzle(process.env.DATABASE_URL, { schema, relations });
Or with existing Pool:
import { Pool } from "pg";
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
const db = drizzle({ client: pool, schema, relations });
import {
pgTable,
pgEnum,
serial,
text,
integer,
timestamp,
uuid,
jsonb,
index,
uniqueIndex,
} from "drizzle-orm/pg-core";
import { sql } from "drizzle-orm";
export const statusEnum = pgEnum("status", ["active", "inactive", "banned"]);
export const users = pgTable(
"users",
{
id: uuid("id")
.default(sql`gen_random_uuid()`)
.primaryKey(),
name: text("name").notNull(),
email: text("email").notNull().unique(),
status: statusEnum().default("active").notNull(),
metadata: jsonb("metadata").$type<{ roles: string[] }>(),
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
},
(t) => [index("users_email_idx").on(t.email)],
);
export const posts = pgTable("posts", {
id: serial("id").primaryKey(),
title: text("title").notNull(),
authorId: uuid("author_id")
.notNull()
.references(() => users.id, { onDelete: "cascade" }),
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
});
import { defineRelations } from "drizzle-orm";
import * as schema from "./schema";
export const relations = defineRelations(schema, (r) => ({
users: {
posts: r.many.posts({ from: r.users.id, to: r.posts.authorId }),
},
posts: {
author: r.one.users({ from: r.posts.authorId, to: r.users.id }),
},
}));
import { eq, and, ilike, sql } from "drizzle-orm";
// SELECT
const allUsers = await db.select().from(users);
const user = await db.select().from(users).where(eq(users.id, id));
// INSERT
const [created] = await db
.insert(users)
.values({ name: "Dan", email: "[email protected]" })
.returning();
// UPDATE
await db.update(users).set({ name: "Updated" }).where(eq(users.id, id));
// DELETE
await db.delete(users).where(eq(users.id, id));
// UPSERT
await db
.insert(users)
.values({ id, name: "Dan", email: "[email protected]" })
.onConflictDoUpdate({ target: users.id, set: { name: "Dan" } });
// Nested eager loading (single SQL query)
const usersWithPosts = await db.query.users.findMany({
with: { posts: true },
where: { status: "active" },
orderBy: { createdAt: "desc" },
limit: 10,
});
const user = await db.query.users.findFirst({
where: { id: userId },
with: { posts: { columns: { id: true, title: true } } },
});
# drizzle.config.ts -> see references/migrations.md
npx drizzle-kit generate # schema diff -> SQL files
npx drizzle-kit migrate # apply SQL to database
npx drizzle-kit push # direct push (no SQL files)
npx drizzle-kit pull # introspect DB -> Drizzle schema
npx drizzle-kit studio # visual browser UI
const filters: SQL[] = [];
if (name) filters.push(ilike(users.name, `%${name}%`));
if (status) filters.push(eq(users.status, status));
await db
.select()
.from(users)
.where(and(...filters));
await db.transaction(async (tx) => {
const [user] = await tx.insert(users).values({ name: "Dan" }).returning();
await tx.insert(posts).values({ title: "Hello", authorId: user.id });
});
type User = typeof users.$inferSelect;
type NewUser = typeof users.$inferInsert;
<quick_reference>
| Import path | Key exports |
|---|---|
drizzle-orm/pg-core | pgTable, pgEnum, column types (serial, text, integer, uuid, timestamp, jsonb, varchar, boolean, numeric, bigint, geometry, vector, ...), index, uniqueIndex, unique, check, primaryKey, foreignKey |
drizzle-orm | Operators: eq, ne, gt, gte, lt, lte, and, or, not, isNull, isNotNull, inArray, between, like, ilike, exists, sql, asc, desc. Utilities: getColumns, defineRelations, cosineDistance, l2Distance |
drizzle-orm (types) | InferSelectModel, InferInsertModel |
drizzle-zod | createInsertSchema, createSelectSchema |
</quick_reference>
For detailed API coverage, see:
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub jgamaraalv/ts-dev-kit --plugin ts-dev-kit22 skills in this plugin
/bullmqBullMQ queue system reference for Redis-backed job queues, workers, flows, and schedulers. Use when: (1) creating queues and workers with BullMQ, (2) adding jobs (delayed, prioritized, repeatable, deduplicated), (3) setting up FlowProducer parent-child job hierarchies, (4) configuring retry strategies, rate limiting, or concurrency, (5) implementing job schedulers with cron/interval patterns, (6) preparing BullMQ for production (graceful shutdown, Redis config, monitoring), or (7) debugging stalled jobs or connection issues/codebase-adapterAdapts ts-dev-kit plugin files to the host project where it is installed. Use when: (1) installing ts-dev-kit in a new project for the first time, (2) project tech stack or structure has changed, (3) agents reference wrong paths, unavailable skills, or missing MCPs, (4) the user says 'adapt the plugin', 'configure ts-dev-kit for this project', 'sync plugin to this codebase', or 'update plugin context'. Surgically edits specific sections in plugin skills and agent definitions — domain area tables, skill/MCP references, quality gate commands, project paths, and package names — without touching any workflow logic, execution protocols, or dispatch patterns./composition-patternsReact composition patterns that scale. Use when refactoring components with boolean prop proliferation, building flexible component libraries, or designing reusable APIs. Triggers on tasks involving compound components, render props, context providers, or component architecture. Includes React 19 API changes.Other plugins' skills for the same job