Sign in Get 3 free credits

Try a job or a niche: tiktok captions, study notes, excel formulas. Press Esc to close.

Drizzle ORM with SQLite

Writes and fixes Drizzle ORM code for SQLite and D1, so schemas, migrations and queries keep your data safe.

What we improved

Rewrote SKILL.md so it carries the method instead of only listing rule titles: a driver table, a client setup with pragmas, an example schema, the migration workflow, query, relation, transaction, hot path and type patterns with code, and a

Improved by YourAISkill from the original by pproenca, under its MIT licence. The download includes the author's licence and a CHANGES.md listing every change. Both Claude reviews read the improved version.

Claude's review

8/10 Thorough Drizzle SQLite guide with driver-specific transaction rules, pragmas, the migration table-rebuild FK trap and 45 incorrect/correct rule files.

We asked Claude the question you would ask: would I be glad I installed this? Two separate reviews, the second blind to the first, must both rate a skill 7 or higher before we sell it.

In detail

Drizzle ORM targeting SQLite (better-sqlite3, libsql/Turso, bun:sqlite, Cloudflare D1, expo-sqlite, op-sqlite). Covers schema definition (column modes, primary keys, foreign keys, indexes), drizzle-kit migrations (generate vs push, renames, custom SQL), the query builder (selects, upserts, returning, EXPLAIN), the relational query builder (relations(), `with`, partial columns), transactions and `db.batch()`, prepared statements with `sql.placeholder()`, connection pragmas (WAL, foreign_keys, busy_timeout), and Drizzle type inference (`$inferSelect`, `$inferInsert`, `$type<>`, drizzle-zod). Use when writing, reviewing, or refactoring Drizzle code for SQLite. Trigger even if the user doesn't say "performance" — schema/migration choices made now are expensive to reverse later, and SQLite-specific traps (single-writer model, no native booleans/dates, ALTER TABLE limits, FK pragma off by default) catch teams who reach for Drizzle without reading the SQLite docs.

How you use it

  1. Add it to your pack, then download your pack (1 credit).
  2. In Claude, open Customize > Skills and upload the zip. Code execution needs to be on under Settings > Capabilities.
  3. Ask Claude for the job in your own words. It uses the skill when your request matches what it does. Step by step guide

Safety check

Nothing risky found: no hidden instructions, no download and run, no reading of saved passwords or keys.

An automated scan lowers risk but cannot promise zero risk. How we check skills

Preview

The first lines of SKILL.md
---
name: drizzle-sqlite
description: "Write, review and fix Drizzle ORM code for SQLite databases (better-sqlite3, bun:sqlite, libsql/Turso, Cloudflare D1, expo-sqlite, op-sqlite). Covers schema columns and modes (booleans, timestamps, JSON, bigint), keys, foreign keys and indexes; drizzle-kit generate, migrate and push, renames and hand-edited migrations including the table-rebuild foreign key trap; queries (projection, inArray, keyset pagination, upserts, returning, EXPLAIN); relational queries; transactions (synchronous on better-sqlite3 and bun:sqlite, unavailable on D1) and db.batch(); prepared statements; connection pragmas (WAL, foreign_keys, busy_timeout); and type inference with $inferSelect, $type and drizzle-zod. Use when defining or changing a Drizzle SQLite schema, writing migrations, writing or reviewing Drizzle queries, setting up the client, or debugging SQLITE_BUSY, missing cascades, no such column errors or lost data after a migration."
---

<!-- Modified by YourAISkill (youraiskill.com) on 2 December 2026 from the original by pproenca. See CHANGES.md. -->

# Drizzle ORM with SQLite

Drizzle's API looks the same across Postgres, MySQL and SQLite, but SQLite behaves differently underneath, and most production bugs come from treating it like Postgres:

- **No server.** A local "connection" is an open file: no pool, no auth, no network.
- **One writer at a time.** Reads can run in parallel under WAL; writes queue.
- **No native boolean or date types.** Storage is `INTEGER`, `REAL`, `TEXT`, `BLOB` or `NULL`; Drizzle column modes do the conversion.
- **Limited `ALTER TABLE`.** Rename table, rename column, add column, drop column. Anything else (type change, add `NOT NULL`, change a constraint) needs a table rebuild.
- **Foreign keys are off by default** and `PRAGMA foreign_keys` is per connection, not stored in the file. It is also ignored inside a transaction.

The 45 rule files in `references/` each give an incorrect and a correct example. This file carries the method and the rules that matter most; open a rule file when you need its detail.

## Step 1: Know the driver and the version

| Driver | Import | API | `db.transaction()` | `db.batch()` |
| --- | --- | --- | --- | --- |
| better-sqlite3 (Node) | `drizzle-orm/better-sqlite3` | sync | **synchronous callback only** | no |
| bun:sqlite | `drizzle-orm/bun-sqlite` | sync | **synchronous callback only** | no |
| libsql / Turso | `drizzle-orm/libsql` (`/web` on edge runtimes) | async | async callback | yes |
| Cloudflare D1 | `drizzle-orm/d1` | async | **not available** (D1 rejects `BEGIN`) | yes, atomic |
| expo-sqlite, op-sqlite | `drizzle-orm/expo-sqlite`, `drizzle-orm/op-sqlite` | see the driver's Drizzle guide | | |

Check `drizzle-orm` in `package.json`. The stable line is 0.x and uses `relations()` with `drizzle(client, { schema })`. drizzle-orm 1.0 (release candidate in late 2026) introduces Relational Queries v2 (`defineRelations`, `drizzle(client, { relations })`, object-style filters). Write for the installed version.

Also check `casing`. With no `casing` option a column's SQL name is its TypeScript key (`authorId`); with `casing: 'snake_case'` it is `author_id`. The option must be set in **both** `drizzle.config.ts` and the `drizzle()` call, or migrations and queries disagree and you get "no such column". Raw SQL in the reference files assumes `snake_case`; inside `sql` templates, interpolate columns (`${posts.authorId}`) instead of typing names.

## Step 2: Client setup

```typescript
// src/db/client.ts — better-sqlite3, one connection for the process
import Database from 'better-sqlite3';
import { drizzle } from 'drizzle-orm/better-sqlite3';
import * as schema from './schema';
...

From pproenca's repository, MIT licence.

Related skills

  • Checked

    Safe Postgres migrations

    Plans Postgres schema changes with the right locks and backfills, so migrations run without downtime.

    by timescale 1.9k
    9/101 credit
  • Checked

    Reversible database migrations

    Writes safe, reversible migrations for Postgres, Prisma, Django and others, so tables change without downtime.

    by affaan-m 314k
    8/101 credit
  • Checked

    MySQL and MariaDB tuning

    Guides MySQL and MariaDB schema, indexes, EXPLAIN plans and replication, so your database runs smoothly.

    by ericrisco 691
    7/101 credit
  • Checked

    Prisma schema and queries

    Writes Prisma schemas, queries and migrations to current Prisma 7 rules, so your code avoids old habits.

    by ericrisco 691
    7/101 credit
  • Checked

    BigQuery migration checks

    Validates that tables moved to BigQuery match their source on schema, aggregates and rows, so nothing is lost.

    by google 25k
    7/101 credit
  • Checked

    Query driven schema design

    Designs tables, keys and indexes from your real query patterns, so your data model stays fast as it grows.

    by OneWave-AI 454
    7/101 credit

Secure checkout

Credits

AUD

  1. 1Choose
  2. 2Pay on Square
  3. 3Credits added