drizzle

Enforces Drizzle ORM schema conventions and query patterns for PostgreSQL databases.

Updated Jul 29, 2026
One-click install
npx skills add https://github.com/zomeru/zomlab --skill drizzle-zomeru
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: drizzle
Source: https://github.com/zomeru/zomlab/tree/main/.agents/skills/drizzle
Command: npx skills add https://github.com/zomeru/zomlab --skill drizzle-zomeru

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Teams writing Drizzle ORM schemas and queries often drift into inconsistent naming, fragile composite primary keys, loose JSONB typing, and the error-prone relational query API. This Skill codifies the project's schema and query style so every table, index, and query follows the same reviewed conventions. ## Core Features & Use Cases - Schema Conventions: Defines rules for pgTable definitions, surrogate primary keys, foreign keys, timestamps, indexes, naming families, and when to avoid pgEnum and composite PKs. - Query Style Enforcement: Mandates the db.select() builder API over db.query relational API, with patterns for joins, aggregations, one-to-many fetches, and raw SQL fallbacks like recursive CTEs. - Type Safety Guidance: Covers inferred insert/select types, concrete JSONB interfaces, and TypeScript value types via $type instead of database enums. - Use Case: When adding a new workspace-scoped table with a many-to-many junction, use this Skill to generate the schema with a uuid surrogate PK, uniqueIndex for pair uniqueness, cascade foreign keys, and a matching join query written with the select builder. ## Quick Start Use the drizzle skill to write a new pgTable schema and select query for a user-scoped logging table following project conventions.

Frequently Asked Questions about drizzle

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I define a Drizzle pgTable schema with proper conventions?▼

Define tables with plural snake_case names, a single-column surrogate primary key using text with idGenerator or uuid with defaultRandom, snake_case columns, cascade foreign keys, and spread timestamps from the helpers module. Put business uniqueness in a uniqueIndex rather than a composite primary key.

Should I use db.select or db.query relational API in Drizzle?▼

Always use the db.select() builder API and never the db.query relational API like findMany or findFirst with with clauses. The relational API generates complex lateral joins with json_build_array that are fragile and hard to debug.

Does Drizzle support composite primary keys for junction tables?▼

Drizzle supports composite primary keys, but this style guide forbids them on new tables including junction tables. Use a surrogate uuid primary key with a uniqueIndex on the pair, since composite PKs cannot include nullable columns and force rebuilds when uniqueness scope grows.

When should I use pgEnum versus text with $type in Drizzle?▼

Default to text or varchar columns with a TypeScript value type via $type instead of pgEnum. Database enums require migrations to add members and are awkward to rename or remove, so reserve pgEnum for effectively immutable value sets with explicit justification.

How do I write raw SQL safely in Drizzle queries?▼

Prefer Drizzle builders and use expression-level sql<T> only for features lacking helpers like JSON paths, casts, and CASE. Keep raw execute queries only for cases like recursive CTEs, with schema references in interpolations, explicit user scoping, and a narrow row interface.

Why avoid Record<string, unknown> for JSONB columns in Drizzle?▼

Loose JSONB types hide the data contract and make downstream access untyped. Define a concrete interface describing the expected shape, and do not add speculative metadata columns at all until a concrete writer ships alongside them.