
Drizzle Orm D1
Define type-safe Cloudflare D1 schemas, run Drizzle Kit migrations, and bulk-write without hitting D1 SQL pitfalls.
Overview
Drizzle ORM D1 is an agent skill for the Build phase that teaches type-safe schemas, Drizzle Kit migrations, and D1-safe batch patterns for Cloudflare Workers backends.
Install
npx skills add https://github.com/jezweb/claude-skills --skill drizzle-orm-d1What is this skill?
- Production-oriented Drizzle ORM patterns for Cloudflare D1 and Workers (status marked production ready in SKILL.md)
- Covers schema definition, Drizzle Kit migrations, relations, and D1 batch API usage
- Documents guards against 18 common failures including SQL BEGIN issues, cascade data loss, and 100-parameter limits
- Auto-trigger keyword lists for discovery (drizzle d1, drizzle kit, d1 orm, migration management)
- Troubleshooting hooks for D1_ERROR, BEGIN TRANSACTION, foreign keys, and too many SQL variables
- 18 documented error classes including SQL BEGIN failures, cascade data loss, and 100-parameter limits
Adoption & trust: 648 installs on skills.sh; 841 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You want Drizzle on Cloudflare D1 but keep hitting D1-specific SQL errors, migration mistakes, or bulk-insert limits that wipe or choke your data.
Who is it for?
Indie SaaS and API builders on Cloudflare Workers who standardize on Drizzle ORM and D1 for edge SQLite storage.
Skip if: Projects on Postgres/MySQL only, or teams that want a managed ORM with zero migration discipline and no Workers deployment.
When should I use this skill?
Defining D1 schemas, managing Drizzle migrations, bulk inserts, or troubleshooting D1_ERROR, BEGIN TRANSACTION, foreign keys, or too many SQL variables.
What do I get? / Deliverables
You leave with working Drizzle schemas, migration workflow, and query/batch patterns that align with D1 constraints instead of generic SQLite assumptions.
- Drizzle schema modules
- Migration files and Kit workflow
- D1 batch and query patterns
Recommended Skills
Journey fit
Database schema and migration work happens while building the product backend on Workers, before ship-time hardening. Drizzle on D1 is core backend persistence—not frontend or DevOps packaging—so the canonical shelf is Build → backend.
How it compares
Skill package for Drizzle+D1 edge SQLite—not a hosted database MCP server or Prisma-centric workflow.
Common Questions / FAQ
Who is drizzle-orm-d1 for?
Solo developers building on Cloudflare Workers who need typed schemas and migrations for D1 without learning every D1 quirk through production outages.
When should I use drizzle-orm-d1?
Use it during Build when defining D1 tables, running Drizzle Kit migrations, wiring relations, doing bulk inserts, or fixing D1_ERROR and transaction-related failures.
Is drizzle-orm-d1 safe to install?
Check the Security Audits panel on this Prism page; the skill guides schema and migration changes that can delete or alter production data if applied carelessly.
SKILL.md
READMESKILL.md - Drizzle Orm D1
{ "name": "drizzle-orm-d1", "description": "Build type-safe D1 databases with Drizzle ORM. Includes schema definition, migrations with Drizzle Kit, relations, and D1 batch API patterns. Prevents 18 errors including SQL BEGIN failures, cascade data loss, 100-parameter limits, and foreign key issues. Use when: defining D1 schemas, managing migrations, bulk inserts, or troubleshooting D1_ERROR, BEGIN TRANSACTION, foreign keys, too many SQL variables.", "version": "1.0.0", "author": { "name": "Jeremy Dawes", "email": "jeremy@jezweb.net" }, "license": "MIT", "repository": "https://github.com/jezweb/claude-skills", "keywords": [], "commands": "./commands/", "agents": "./agents/" } # Drizzle ORM for Cloudflare D1 **Status**: Production Ready ✅ **Last Updated**: 2026-01-03 **Production Tested**: Used across 2025-2026 Cloudflare ecosystem, full D1 compatibility --- ## Auto-Trigger Keywords Claude Code automatically discovers this skill when you mention: ### Primary Keywords - drizzle orm - drizzle d1 - drizzle cloudflare - type-safe sql - drizzle schema - drizzle migrations - drizzle kit - orm cloudflare - d1 orm - database orm ### Secondary Keywords - drizzle typescript - drizzle relations - drizzle transactions - drizzle query builder - schema definition - prepared statements drizzle - drizzle batch - drizzle workers - serverless orm - edge database orm - sqlite orm - migration management - schema migrations - database schema typescript - relational queries - drizzle joins - drizzle insert - drizzle select ### Error-Based Keywords - "drizzle migration failed" - "schema not found" drizzle - "d1 binding error" drizzle - "transaction not supported" d1 - "foreign key constraint" drizzle - "no such module wrangler" drizzle - "D1_ERROR" drizzle - "BEGIN TRANSACTION" d1 - "drizzle push failed" - "migration apply error" - "drizzle type inference" - "PRAGMA foreign_keys" --- ## What This Skill Does Provides production-tested patterns for Drizzle ORM with Cloudflare D1 databases. Covers type-safe schema definition, migrations management, query building, relations, transactions using D1 batch API, and complete Cloudflare Workers integration. ### Core Capabilities ✅ **Type-Safe Queries** - Full TypeScript inference for all queries ✅ **Schema Definition** - Complete D1 column types, constraints, and relations ✅ **Migrations Management** - Generate and apply migrations with Drizzle Kit + Wrangler ✅ **Relations & Joins** - One-to-many, many-to-many with type-safe queries ✅ **D1 Batch API** - Transactions using D1's batch API (not SQL BEGIN/COMMIT) ✅ **Prepared Statements** - Performance optimization for repeated queries ✅ **Workers Integration** - Complete Hono + Drizzle + D1 setup ✅ **Error Prevention** - Prevents 12 documented issues with production-tested solutions ✅ **10 Templates** - Ready-to-use patterns for every use case --- ## Known Issues This Skill Prevents | Issue | Why It Happens | Source | How Skill Fixes It | |-------|---------------|---------|-------------------| | D1 Transaction Errors | Drizzle tries to use SQL BEGIN TRANSACTION, D1 requires batch API | [drizzle-orm#4212](https://github.com/drizzle-team/drizzle-orm/issues/4212) | Use `db.batch()` instead | | Foreign Key Failures | PRAGMA foreign_keys = OFF in migrations causes issues | [drizzle-orm#4089](https://github.com/drizzle-team/drizzle-orm/issues/4089) | Proper migration order + cascading | | Module Import Errors | OpenNext bundler issues with Wrangler imports | [drizzle-orm#4257](https://github.com/drizzle-team/drizzle-orm/issues/4257) | Correct import paths documented | | D1 Binding Not Found | Missing or incorrect wrangler.jsonc configuration | Common D1 issue | Verify binding names match | | Migration Apply Failures | Syntax errors or conflicting migrations | Community reports | Test locally with `--local` first | | Schema Inference Errors | Complex circular references in relations | TypeScript limitation | Explicit type ann