skills/community/drizzle-orm/SKILL.md
Expert guide for Drizzle ORM best practices, including schema definitions, queries, mutations, transactions, migrations, and performance optimization. Use when working with Drizzle ORM, database schemas, queries, or migrations.
npx skillsauth add pedronauck/skills drizzle-ormInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill provides guidelines, patterns, and best practices for working with Drizzle ORM in this project.
For detailed development guidelines, patterns, and code examples, refer to references/patterns.md.
Organize schemas by domain in separate files. Use fluent constraint chaining and add indexes for frequently queried columns.
export const users = pgTable('users', {
id: uuid('id').primaryKey().defaultRandom(),
email: varchar('email', { length: 255 }).notNull().unique(),
createdAt: timestamp('created_at').defaultNow().notNull(),
});
Always export table types for use in your application:
export type User = typeof users.$inferSelect;
export type NewUser = typeof users.$inferInsert;
Use prepared statements for frequently executed queries for extreme performance benefits:
export const getUserById = db
.select()
.from(users)
.where(eq(users.id, sql.placeholder('id')))
.prepare();
// Usage
const user = await getUserById.execute({ id: userId });
Use transactions for multi-step operations to maintain data consistency:
return db.transaction(async (tx) => {
const [user] = await tx.insert(users).values(userData).returning();
const [profile] = await tx.insert(profiles).values({ userId: user.id, ...profileData }).returning();
return { user, profile };
});
CRITICAL: Always use package scripts for migrations. Never call drizzle-kit directly.
pnpm run db:generate (generates migration)pnpm run db:migrate (applies migrations)pnpm run db:generate (generates migration)pnpm run db:migrate (applies migrations)db/
index.ts (Drizzle client initialization)
schema/
users.ts (User table & relations)
posts.ts (Post table & relations)
queries/
users.ts (User query functions)
posts.ts (Post query functions)
migrations/ (Auto-generated migration files)
limit() and offset() for user-facing queriessql.placeholder()with() or batch queriesBefore finishing a task involving Drizzle ORM:
pnpm run typecheck) and tests (pnpm run test)For detailed rules and code examples, consult references/patterns.md.
development
Deep review of branch diffs, working trees, or GitHub PRs at any size. Use when the user asks for CodeRabbit-grade review, an incremental re-review after new pushes, publication of findings to a PR, a cross-LLM peer-review verdict round, or conformance review against spec artifacts. Don't use for applying fixes, reviewing specs or PRDs as documents, or quick single-file feedback.
tools
Orchestrate Claude and Codex worker TUIs from a controller agent through herdr panes and the herdr socket CLI. Use when delegating bounded tasks to herdr worker panes, running user-activated plan-first delegations (Claude Code plan mode, Codex Plan mode), waiting on native agent status (idle, working, blocked, done), or verifying worker reports. Workers launch as interactive TUIs via herdr agent start — never through headless runners (compozy exec, claude -p, codex exec). Not for cmux workspaces (see cmux-orchestration) and not for end-user herdr control.
tools
TanStack Query, Router, and Form patterns for React. Use when writing useQuery/queryOptions, mutations, caching, file-based routes, search params, loaders, or TanStack Form validation. Don't use for TanStack Start, TanStack DB/collections, Zustand client state, or non-TanStack routing.
development
Use when the user wants to design, redesign, shape, critique, audit, polish, clarify, distill, harden, optimize, adapt, animate, colorize, extract, or otherwise improve a frontend interface. Covers websites, landing pages, dashboards, product UI, app shells, components, forms, settings, onboarding, and empty states. Handles UX review, visual hierarchy, information architecture, cognitive load, accessibility, performance, responsive behavior, theming, anti-patterns, typography, fonts, spacing, layout, alignment, color, motion, micro-interactions, UX copy, error states, edge cases, i18n, and reusable design systems or tokens. Also use for bland designs that need to become bolder or more delightful, loud designs that should become quieter, live browser iteration on UI elements, or ambitious visual effects that should feel technically extraordinary. Not for backend-only or non-UI tasks.