Drizzle

From Esposter/Esposter · View interactive version

Drizzle is an AI agent skill from the GitHub repository Esposter/Esposter. Apply when writing or modifying DB schema files in packages/db-schema, the Durable Object schemas in packages/db-schema/src/objects, or tRPC routers. Esposter's Drizzle ORM conventions for D1 and the object SQLite — how a table, a relation and a query are written, how its names are derived, and how

How to use this skill

Skill file

Drizzle ORM Conventions

Settled — do not re-propose

Deep dives

D1 and Object SQLite

Column Names

A column builder is called bare, never with a name string (no-restricted-syntax): the sqliteTable wrapper names every column after its key (references/table-definition.md).

Table Definition

Row Versions and Tombstones

Schemas, Names and Registries

Selects

getColumns(table) for a flat result, { alias: table } for a namespaced one, and a bare .select() only for one table (references/queries.md).

Query API: Relational vs SQL-style

The relational API for every read; SQL-style for writes, multi-column OR joins, aggregates and upserts; a read's limit is MAX_READ_LIMIT or DEFAULT_PAGE_LIMIT (references/queries.md).

Relations (v2 API) — at a glance

Self-Joins (Same Table Twice)

Both sides of a self-join are alias()es named foo1, foo2 (references/queries.md).

Batch Inserts

One INSERT over an array, never a loop of them (references/queries.md).

`.returning()`

requireMutation on the first row, the full entity returned, and [0] rather than takeOne wherever a guard reads the absence (references/returning.md).

Empty-Sentinel Columns

A column's empty value and its insert side are the absent-values skill's (references/sentinel-columns.md); the schema carries the sentinel, so Drizzle's inferred types propagate it.

Time Duration Columns

A duration is stored in milliseconds, never seconds, minutes or hours unless it needs sub-millisecond precision, and its column carries the Ms suffix (the naming skill, "No abbreviations") — durationMs: integer().notNull().

Primary Keys

A text id for an entity other tables reference, a text natural key, a composite for a pure join table, and a random code as id where one already identifies the row (references/primary-keys.md).

Migrations

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.