Agent skill · software engineering · ccheney
postgres-drizzle
Proactively apply when creating APIs, backends, or data models. Triggers on PostgreSQL, Postgres, Drizzle, drizzle-orm, drizzle-kit, database, schema, pgTable, tables, columns, indexes, queries, migrations, ORM, relations, relational queries, joins, transactions, SQL, connection pooling, PgBouncer, N+1, JSONB, RLS, full-text search, partitioning. Use when writing database schemas, queries, migrations, connection setup, or any database-related code. PostgreSQL and Drizzle ORM best practices.
Why this skill is useful
Provides specific commands and best practices for using PostgreSQL with Drizzle ORM that the AI wouldn't reliably generate on its own.
What it needs
Requires drizzle-kit, drizzle-orm, postgres installed locally. About 5k tokens when loaded. Last updated 2026-07-07. 58 stars on the source repository.
What this skill does
PostgreSQL + Drizzle ORM Type-safe database applications with PostgreSQL 17/18 and Drizzle ORM. Version Check (do this first) Drizzle's API changed significantly between the stable 0.x line and v1.0. Check package.json before writing code, because the two relations APIs are incompatible and must not be mixed: drizzle-orm version Relations API Query filters ----------------------- --------------- --------------- ^0.x (npm latest) relations() per table, drizzle(client, { schema }) where: eq(users.id, id) 1.0.0-beta. / 1.0.0-rc. defineRelations() once for all tables, drizzle(client, { relations }) where: { id: userId } (object style) The official docs site (orm.drizzle.team) documents v1.0 syntax on its main pages. This skill defaults to stable 0.x syntax; for v1.0 projects read references/RELATIONS.md § "Relational Queries v2". Signals a project is on v1.0: defineRelations imports, object-style where, r.many.posts() in relations, from/to keys instead of fields/references. Essential Commands Quick Decision Trees "How do I model this relationship?" "Why is my query slow?" "Which drizzle-kit command?" Connection Setup Passing schema is what enables db.query. relational queries — forgetting it is the most common cause of "Property 'users' does not exist on type ...". Optional: drizzle(url, { schema, casing: 'snakecase' }) maps camelCase TS keys to snakecase columns so you can write pgTable('users', { createdAt: timestamp() }) without repeating column names. Set the same casing in drizzle.config.ts. Schema Patterns Basic Table with Timestamps Prefer timestamp(..., { withTimezone: true }) (timestamptz) — naive timestamps cause silent timezone bugs. For integer PKs, prefer integer().primaryKey().generatedAlwaysAsIdentity() over serial() (the PostgreSQL-recommended form; serial is legacy). Foreign Key with Index The third pgTable argument returns an array (the older object form is deprecated). Relations (stable 0.x API) relations() is application-level metadata for db.query. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills ccheney/postgres-drizzle