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
Guides a founder through the full Y Combinator batch application end-to-end. A 10-phase workflow that captures the live YC form, profiles the founders, stress-tests the idea via an embedded grill loop, runs a mandatory 5-agent parallel external research pass on the startup, drafts every form field with anti-pattern and accepted-example checks, produces founder-video bullet notes (no script), runs a final adversarial gate, generates paste-ready submission answers, unlocks an interview-prep simulator after invite, and supports reapplicant delta tracking and post-decision post-mortems. Writes a documented markdown trail under a user-chosen workspace. Use when a founder wants to prepare a YC batch application, build their founder video, drill mock YC interview questions, or reapply with delta evidence. Don't use for pitch-deck design unrelated to YC, generic startup advice without applying, or post-funding work.
development
Authors engineering blog posts end-to-end: launch deep-dives, incident postmortems, architecture migrations, performance case studies, tutorials, AI/agent system writeups, security disclosures, and research-to-product translations. Picks the correct archetype, plans the abstraction ladder, enforces an evidence cadence (diagrams, benchmarks, profiles, traces, code, ablations), tunes voice against publisher house styles (Datadog, Vercel, GitHub, AWS, Meta, Cloudflare, Jane Street), and runs a pre-publish gate for narrative momentum and disclosure ethics. Use when drafting a new engineering post, restructuring a draft that feels flat, deciding which evidence form belongs where, validating that depth and product context are balanced, or preparing a postmortem, migration, or performance narrative for external publication. Do not use for API reference documentation, README authoring, marketing copy, release notes, generic SEO content, ghost-written executive thought leadership, or non-engineering long-form essays.
tools
Provides guardrails for user-facing UI work: usability heuristics, accessibility floors, design-system discipline, component states, microcopy, motion, dark mode, responsive behavior, and human-AI UX. Use when designing, generating, reviewing, or refactoring visible product surfaces such as components, pages, dashboards, forms, dialogs, loading/empty/error states, or AI interfaces. Do not use for backend-only work, infrastructure, CLI/TUI design, or pure documentation editing.
tools
Master TypeScript's advanced type system including generics, conditional types, mapped types, template literals, and utility types for building type-safe applications. Use when implementing complex type logic, creating reusable type utilities, or ensuring compile-time type safety in TypeScript projects. Don't use for plain JavaScript, runtime validation libraries (Zod, Yup), or basic TypeScript syntax questions.