What problem does it solve?
This Skill solves the problem of fragile, inconsistent database code in TypeScript projects by standardizing how Drizzle schemas, migrations, connections, and queries are organized so refactors stay safe and predictable.
Core Features & Use Cases
- Schema-first structure: Centralizes all table definitions in src/db/schema.ts as the single source of truth, with inferred types via $inferSelect and $inferInsert.
- Migration discipline: Uses drizzle-kit (drizzle.config.ts + npx drizzle-kit generate/migrate) to create versioned migration SQL rather than editing migration files manually.
- Typed query layer & singleton connection: Enforces a single Drizzle instance in src/lib/db.ts and routes all SQL-building through functions in src/db/queries to keep APIs consistent and maintainable.
- Validation and safety guardrails: Validates inputs at the service boundary (e.g., with Zod) and defines common anti-patterns like multiple DB connections and raw SQL string concatenation.
Quick Start
Ask your AI coding agent to implement Drizzle ORM using a schema-first layout: put all tables and inferred types in src/db/schema.ts, create the singleton connection in src/lib/db.ts, move all queries into src/db/queries/*, and manage schema changes with drizzle-kit migrations.