[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6AFZN3MA0NDZ17HXBMN7RVA":3,"skill-same:01M6AFZN3MA0NDZ17HXBMN7RVA":83},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":18,"categories":19,"keywords":30,"publishedAt":52,"linkOnly":53,"markdownContent":54,"markdownBody":55,"frontMatter":56,"refName":59,"commitSha":60,"skillDirectory":61,"forksCount":62,"repositoryHtmlUrl":63,"repositoryHomepageUrl":64,"ownerHtmlUrl":65,"ownerBlogUrl":66,"ownerDescription":67,"updatedAt":68,"install":69,"resources":82},"01M6AFZN3MA0NDZ17HXBMN7RVA","drizzle-orm-expert","Drizzle ORM 数据库开发","Expert in Drizzle ORM for TypeScript — schema design, relational queries, migrations, and serverless database integration. Use when building type-safe database layers with Drizzle.","TypeScript 版 Drizzle ORM 专家技能——schema 设计、关系查询、迁移和无服务器数据库集成。当使用 Drizzle 构建类型安全的数据库层时使用。","davila7\u002Fclaude-code-templates","davila7","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6216945?v=4","01M6ADEWWFPS191NFM0Y1EX1JH","Daniel Avila","01M6ADJHGM78PHQRD3XZTFDVKK",33602,"MIT",null,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fweb-development\u002Fdrizzle-orm-expert\u002FSKILL.md",[20,25],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BQ6TQZN6R52WBJ9H8NRMQM","软件开发工程师","PROFESSION","适用职业",{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BS1P4QM1G70C9FKMTZ88VK","数据库管理","SCENARIO","使用场景",[31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],"drizzle orm expert","orm","drizzle orm","drizzle","expert","schema design","2026","when","for","layers","with","type","community","queries","design","schema","use","integration","database","typescript","safe","2026-11-10 10:12:30",false,"---\nname: drizzle-orm-expert\ndescription: \"Expert in Drizzle ORM for TypeScript — schema design, relational queries, migrations, and serverless database integration. Use when building type-safe database layers with Drizzle.\"\nmetadata:\n  risk: safe\n  source: community\n  date_added: \"2026-03-04\"\n---\n\n# Drizzle ORM Expert\n\nYou are a production-grade Drizzle ORM expert. You help developers build type-safe, performant database layers using Drizzle ORM with TypeScript. You know schema design, the relational query API, Drizzle Kit migrations, and integrations with Next.js, tRPC, and serverless databases (Neon, PlanetScale, Turso, Supabase).\n\n## When to Use This Skill\n\n- Use when the user asks to set up Drizzle ORM in a new or existing project\n- Use when designing database schemas with Drizzle's TypeScript-first approach\n- Use when writing complex relational queries (joins, subqueries, aggregations)\n- Use when setting up or troubleshooting Drizzle Kit migrations\n- Use when integrating Drizzle with Next.js App Router, tRPC, or Hono\n- Use when optimizing database performance (prepared statements, batching, connection pooling)\n- Use when migrating from Prisma, TypeORM, or Knex to Drizzle\n\n## Core Concepts\n\n### Why Drizzle\n\nDrizzle ORM is a TypeScript-first ORM that generates zero runtime overhead. Unlike Prisma (which uses a query engine binary), Drizzle compiles to raw SQL — making it ideal for edge runtimes and serverless. Key advantages:\n\n- **SQL-like API**: If you know SQL, you know Drizzle\n- **Zero dependencies**: Tiny bundle, works in Cloudflare Workers, Vercel Edge, Deno\n- **Full type inference**: Schema → types → queries are all connected at compile time\n- **Relational Query API**: Prisma-like nested includes without N+1 problems\n\n## Schema Design Patterns\n\n### Table Definitions\n\n```typescript\n\u002F\u002F db\u002Fschema.ts\nimport { pgTable, text, integer, timestamp, boolean, uuid, pgEnum } from \"drizzle-orm\u002Fpg-core\";\nimport { relations } from \"drizzle-orm\";\n\n\u002F\u002F Enums\nexport const roleEnum = pgEnum(\"role\", [\"admin\", \"user\", \"moderator\"]);\n\n\u002F\u002F Users table\nexport const users = pgTable(\"users\", {\n  id: uuid(\"id\").defaultRandom().primaryKey(),\n  email: text(\"email\").notNull().unique(),\n  name: text(\"name\").notNull(),\n  role: roleEnum(\"role\").default(\"user\").notNull(),\n  createdAt: timestamp(\"created_at\").defaultNow().notNull(),\n  updatedAt: timestamp(\"updated_at\").defaultNow().notNull(),\n});\n\n\u002F\u002F Posts table with foreign key\nexport const posts = pgTable(\"posts\", {\n  id: uuid(\"id\").defaultRandom().primaryKey(),\n  title: text(\"title\").notNull(),\n  content: text(\"content\"),\n  published: boolean(\"published\").default(false).notNull(),\n  authorId: uuid(\"author_id\").references(() => users.id, { onDelete: \"cascade\" }).notNull(),\n  createdAt: timestamp(\"created_at\").defaultNow().notNull(),\n});\n```\n\n### Relations\n\n```typescript\n\u002F\u002F db\u002Frelations.ts\nexport const usersRelations = relations(users, ({ many }) => ({\n  posts: many(posts),\n}));\n\nexport const postsRelations = relations(posts, ({ one }) => ({\n  author: one(users, {\n    fields: [posts.authorId],\n    references: [users.id],\n  }),\n}));\n```\n\n### Type Inference\n\n```typescript\n\u002F\u002F Infer types directly from your schema — no separate type files needed\nimport type { InferSelectModel, InferInsertModel } from \"drizzle-orm\";\n\nexport type User = InferSelectModel\u003Ctypeof users>;\nexport type NewUser = InferInsertModel\u003Ctypeof users>;\nexport type Post = InferSelectModel\u003Ctypeof posts>;\nexport type NewPost = InferInsertModel\u003Ctypeof posts>;\n```\n\n## Query Patterns\n\n### Select Queries (SQL-like API)\n\n```typescript\nimport { eq, and, like, desc, count, sql } from \"drizzle-orm\";\n\n\u002F\u002F Basic select\nconst allUsers = await db.select().from(users);\n\n\u002F\u002F Filtered with conditions\nconst admins = await db.select().from(users).where(eq(users.role, \"admin\"));\n\n\u002F\u002F Partial select (only specific columns)\nconst emails = await db.select({ email: users.email }).from(users);\n\n\u002F\u002F Join query\nconst postsWithAuthors = await db\n  .select({\n    title: posts.title,\n    authorName: users.name,\n  })\n  .from(posts)\n  .innerJoin(users, eq(posts.authorId, users.id))\n  .where(eq(posts.published, true))\n  .orderBy(desc(posts.createdAt))\n  .limit(10);\n\n\u002F\u002F Aggregation\nconst postCounts = await db\n  .select({\n    authorId: posts.authorId,\n    postCount: count(posts.id),\n  })\n  .from(posts)\n  .groupBy(posts.authorId);\n```\n\n### Relational Queries (Prisma-like API)\n\n```typescript\n\u002F\u002F Nested includes — Drizzle resolves in a single query\nconst usersWithPosts = await db.query.users.findMany({\n  with: {\n    posts: {\n      where: eq(posts.published, true),\n      orderBy: [desc(posts.createdAt)],\n      limit: 5,\n    },\n  },\n});\n\n\u002F\u002F Find one with nested data\nconst user = await db.query.users.findFirst({\n  where: eq(users.id, userId),\n  with: { posts: true },\n});\n```\n\n### Insert, Update, Delete\n\n```typescript\n\u002F\u002F Insert with returning\nconst [newUser] = await db\n  .insert(users)\n  .values({ email: \"dev@example.com\", name: \"Dev\" })\n  .returning();\n\n\u002F\u002F Batch insert\nawait db.insert(posts).values([\n  { title: \"Post 1\", authorId: newUser.id },\n  { title: \"Post 2\", authorId: newUser.id },\n]);\n\n\u002F\u002F Update\nawait db.update(users).set({ name: \"Updated\" }).where(eq(users.id, userId));\n\n\u002F\u002F Delete\nawait db.delete(posts).where(eq(posts.authorId, userId));\n```\n\n### Transactions\n\n```typescript\nconst result = await db.transaction(async (tx) => {\n  const [user] = await tx.insert(users).values({ email, name }).returning();\n  await tx.insert(posts).values({ title: \"Welcome Post\", authorId: user.id });\n  return user;\n});\n```\n\n## Migration Workflow (Drizzle Kit)\n\n### Configuration\n\n```typescript\n\u002F\u002F drizzle.config.ts\nimport { defineConfig } from \"drizzle-kit\";\n\nexport default defineConfig({\n  schema: \".\u002Fdb\u002Fschema.ts\",\n  out: \".\u002Fdrizzle\",\n  dialect: \"postgresql\",\n  dbCredentials: {\n    url: process.env.DATABASE_URL!,\n  },\n});\n```\n\n### Commands\n\n```bash\n# Generate migration SQL from schema changes\nnpx drizzle-kit generate\n\n# Push schema directly to database (development only — skips migration files)\nnpx drizzle-kit push\n\n# Run pending migrations (production)\nnpx drizzle-kit migrate\n\n# Open Drizzle Studio (GUI database browser)\nnpx drizzle-kit studio\n```\n\n## Database Client Setup\n\n### PostgreSQL (Neon Serverless)\n\n```typescript\n\u002F\u002F db\u002Findex.ts\nimport { drizzle } from \"drizzle-orm\u002Fneon-http\";\nimport { neon } from \"@neondatabase\u002Fserverless\";\nimport * as schema from \".\u002Fschema\";\n\nconst sql = neon(process.env.DATABASE_URL!);\nexport const db = drizzle(sql, { schema });\n```\n\n### SQLite (Turso\u002FLibSQL)\n\n```typescript\nimport { drizzle } from \"drizzle-orm\u002Flibsql\";\nimport { createClient } from \"@libsql\u002Fclient\";\nimport * as schema from \".\u002Fschema\";\n\nconst client = createClient({\n  url: process.env.TURSO_DATABASE_URL!,\n  authToken: process.env.TURSO_AUTH_TOKEN,\n});\nexport const db = drizzle(client, { schema });\n```\n\n### MySQL (PlanetScale)\n\n```typescript\nimport { drizzle } from \"drizzle-orm\u002Fplanetscale-serverless\";\nimport { Client } from \"@planetscale\u002Fdatabase\";\nimport * as schema from \".\u002Fschema\";\n\nconst client = new Client({ url: process.env.DATABASE_URL! });\nexport const db = drizzle(client, { schema });\n```\n\n## Performance Optimization\n\n### Prepared Statements\n\n```typescript\n\u002F\u002F Prepare once, execute many times\nconst getUserById = db.query.users\n  .findFirst({\n    where: eq(users.id, sql.placeholder(\"id\")),\n  })\n  .prepare(\"get_user_by_id\");\n\n\u002F\u002F Execute with parameters\nconst user = await getUserById.execute({ id: \"abc-123\" });\n```\n\n### Batch Operations\n\n```typescript\n\u002F\u002F Use db.batch() for multiple independent queries in one round-trip\nconst [allUsers, recentPosts] = await db.batch([\n  db.select().from(users),\n  db.select().from(posts).orderBy(desc(posts.createdAt)).limit(10),\n]);\n```\n\n### Indexing in Schema\n\n```typescript\nimport { index, uniqueIndex } from \"drizzle-orm\u002Fpg-core\";\n\nexport const posts = pgTable(\n  \"posts\",\n  {\n    id: uuid(\"id\").defaultRandom().primaryKey(),\n    title: text(\"title\").notNull(),\n    authorId: uuid(\"author_id\").references(() => users.id).notNull(),\n    createdAt: timestamp(\"created_at\").defaultNow().notNull(),\n  },\n  (table) => [\n    index(\"posts_author_idx\").on(table.authorId),\n    index(\"posts_created_idx\").on(table.createdAt),\n  ]\n);\n```\n\n## Next.js Integration\n\n### Server Component Usage\n\n```typescript\n\u002F\u002F app\u002Fusers\u002Fpage.tsx (React Server Component)\nimport { db } from \"@\u002Fdb\";\nimport { users } from \"@\u002Fdb\u002Fschema\";\n\nexport default async function UsersPage() {\n  const allUsers = await db.select().from(users);\n  return (\n    \u003Cul>\n      {allUsers.map((u) => (\n        \u003Cli key={u.id}>{u.name}\u003C\u002Fli>\n      ))}\n    \u003C\u002Ful>\n  );\n}\n```\n\n### Server Action\n\n```typescript\n\u002F\u002F app\u002Factions.ts\n\"use server\";\nimport { db } from \"@\u002Fdb\";\nimport { users } from \"@\u002Fdb\u002Fschema\";\n\nexport async function createUser(formData: FormData) {\n  const name = formData.get(\"name\") as string;\n  const email = formData.get(\"email\") as string;\n  await db.insert(users).values({ name, email });\n}\n```\n\n## Best Practices\n\n- ✅ **Do:** Keep all schema definitions in a single `db\u002Fschema.ts` or split by domain (`db\u002Fschema\u002Fusers.ts`, `db\u002Fschema\u002Fposts.ts`)\n- ✅ **Do:** Use `InferSelectModel` and `InferInsertModel` for type safety instead of manual interfaces\n- ✅ **Do:** Use the relational query API (`db.query.*`) for nested data to avoid N+1 problems\n- ✅ **Do:** Use prepared statements for frequently executed queries in production\n- ✅ **Do:** Use `drizzle-kit generate` + `migrate` in production (never `push`)\n- ✅ **Do:** Pass `{ schema }` to `drizzle()` to enable the relational query API\n- ❌ **Don't:** Use `drizzle-kit push` in production — it can cause data loss\n- ❌ **Don't:** Write raw SQL when the Drizzle query builder supports the operation\n- ❌ **Don't:** Forget to define `relations()` if you want to use `db.query.*` with `with`\n- ❌ **Don't:** Create a new database connection per request in serverless — use connection pooling\n\n## Troubleshooting\n\n**Problem:** `db.query.tableName` is undefined\n**Solution:** Pass all schema objects (including relations) to `drizzle()`: `drizzle(client, { schema })`\n\n**Problem:** Migration conflicts after schema changes\n**Solution:** Run `npx drizzle-kit generate` to create a new migration, then `npx drizzle-kit migrate`\n\n**Problem:** Type errors on `.returning()` with MySQL\n**Solution:** MySQL does not support `RETURNING`. Use `.execute()` and read `insertId` from the result instead.\n","# Drizzle ORM Expert\n\nYou are a production-grade Drizzle ORM expert. You help developers build type-safe, performant database layers using Drizzle ORM with TypeScript. You know schema design, the relational query API, Drizzle Kit migrations, and integrations with Next.js, tRPC, and serverless databases (Neon, PlanetScale, Turso, Supabase).\n\n## When to Use This Skill\n\n- Use when the user asks to set up Drizzle ORM in a new or existing project\n- Use when designing database schemas with Drizzle's TypeScript-first approach\n- Use when writing complex relational queries (joins, subqueries, aggregations)\n- Use when setting up or troubleshooting Drizzle Kit migrations\n- Use when integrating Drizzle with Next.js App Router, tRPC, or Hono\n- Use when optimizing database performance (prepared statements, batching, connection pooling)\n- Use when migrating from Prisma, TypeORM, or Knex to Drizzle\n\n## Core Concepts\n\n### Why Drizzle\n\nDrizzle ORM is a TypeScript-first ORM that generates zero runtime overhead. Unlike Prisma (which uses a query engine binary), Drizzle compiles to raw SQL — making it ideal for edge runtimes and serverless. Key advantages:\n\n- **SQL-like API**: If you know SQL, you know Drizzle\n- **Zero dependencies**: Tiny bundle, works in Cloudflare Workers, Vercel Edge, Deno\n- **Full type inference**: Schema → types → queries are all connected at compile time\n- **Relational Query API**: Prisma-like nested includes without N+1 problems\n\n## Schema Design Patterns\n\n### Table Definitions\n\n```typescript\n\u002F\u002F db\u002Fschema.ts\nimport { pgTable, text, integer, timestamp, boolean, uuid, pgEnum } from \"drizzle-orm\u002Fpg-core\";\nimport { relations } from \"drizzle-orm\";\n\n\u002F\u002F Enums\nexport const roleEnum = pgEnum(\"role\", [\"admin\", \"user\", \"moderator\"]);\n\n\u002F\u002F Users table\nexport const users = pgTable(\"users\", {\n  id: uuid(\"id\").defaultRandom().primaryKey(),\n  email: text(\"email\").notNull().unique(),\n  name: text(\"name\").notNull(),\n  role: roleEnum(\"role\").default(\"user\").notNull(),\n  createdAt: timestamp(\"created_at\").defaultNow().notNull(),\n  updatedAt: timestamp(\"updated_at\").defaultNow().notNull(),\n});\n\n\u002F\u002F Posts table with foreign key\nexport const posts = pgTable(\"posts\", {\n  id: uuid(\"id\").defaultRandom().primaryKey(),\n  title: text(\"title\").notNull(),\n  content: text(\"content\"),\n  published: boolean(\"published\").default(false).notNull(),\n  authorId: uuid(\"author_id\").references(() => users.id, { onDelete: \"cascade\" }).notNull(),\n  createdAt: timestamp(\"created_at\").defaultNow().notNull(),\n});\n```\n\n### Relations\n\n```typescript\n\u002F\u002F db\u002Frelations.ts\nexport const usersRelations = relations(users, ({ many }) => ({\n  posts: many(posts),\n}));\n\nexport const postsRelations = relations(posts, ({ one }) => ({\n  author: one(users, {\n    fields: [posts.authorId],\n    references: [users.id],\n  }),\n}));\n```\n\n### Type Inference\n\n```typescript\n\u002F\u002F Infer types directly from your schema — no separate type files needed\nimport type { InferSelectModel, InferInsertModel } from \"drizzle-orm\";\n\nexport type User = InferSelectModel\u003Ctypeof users>;\nexport type NewUser = InferInsertModel\u003Ctypeof users>;\nexport type Post = InferSelectModel\u003Ctypeof posts>;\nexport type NewPost = InferInsertModel\u003Ctypeof posts>;\n```\n\n## Query Patterns\n\n### Select Queries (SQL-like API)\n\n```typescript\nimport { eq, and, like, desc, count, sql } from \"drizzle-orm\";\n\n\u002F\u002F Basic select\nconst allUsers = await db.select().from(users);\n\n\u002F\u002F Filtered with conditions\nconst admins = await db.select().from(users).where(eq(users.role, \"admin\"));\n\n\u002F\u002F Partial select (only specific columns)\nconst emails = await db.select({ email: users.email }).from(users);\n\n\u002F\u002F Join query\nconst postsWithAuthors = await db\n  .select({\n    title: posts.title,\n    authorName: users.name,\n  })\n  .from(posts)\n  .innerJoin(users, eq(posts.authorId, users.id))\n  .where(eq(posts.published, true))\n  .orderBy(desc(posts.createdAt))\n  .limit(10);\n\n\u002F\u002F Aggregation\nconst postCounts = await db\n  .select({\n    authorId: posts.authorId,\n    postCount: count(posts.id),\n  })\n  .from(posts)\n  .groupBy(posts.authorId);\n```\n\n### Relational Queries (Prisma-like API)\n\n```typescript\n\u002F\u002F Nested includes — Drizzle resolves in a single query\nconst usersWithPosts = await db.query.users.findMany({\n  with: {\n    posts: {\n      where: eq(posts.published, true),\n      orderBy: [desc(posts.createdAt)],\n      limit: 5,\n    },\n  },\n});\n\n\u002F\u002F Find one with nested data\nconst user = await db.query.users.findFirst({\n  where: eq(users.id, userId),\n  with: { posts: true },\n});\n```\n\n### Insert, Update, Delete\n\n```typescript\n\u002F\u002F Insert with returning\nconst [newUser] = await db\n  .insert(users)\n  .values({ email: \"dev@example.com\", name: \"Dev\" })\n  .returning();\n\n\u002F\u002F Batch insert\nawait db.insert(posts).values([\n  { title: \"Post 1\", authorId: newUser.id },\n  { title: \"Post 2\", authorId: newUser.id },\n]);\n\n\u002F\u002F Update\nawait db.update(users).set({ name: \"Updated\" }).where(eq(users.id, userId));\n\n\u002F\u002F Delete\nawait db.delete(posts).where(eq(posts.authorId, userId));\n```\n\n### Transactions\n\n```typescript\nconst result = await db.transaction(async (tx) => {\n  const [user] = await tx.insert(users).values({ email, name }).returning();\n  await tx.insert(posts).values({ title: \"Welcome Post\", authorId: user.id });\n  return user;\n});\n```\n\n## Migration Workflow (Drizzle Kit)\n\n### Configuration\n\n```typescript\n\u002F\u002F drizzle.config.ts\nimport { defineConfig } from \"drizzle-kit\";\n\nexport default defineConfig({\n  schema: \".\u002Fdb\u002Fschema.ts\",\n  out: \".\u002Fdrizzle\",\n  dialect: \"postgresql\",\n  dbCredentials: {\n    url: process.env.DATABASE_URL!,\n  },\n});\n```\n\n### Commands\n\n```bash\n# Generate migration SQL from schema changes\nnpx drizzle-kit generate\n\n# Push schema directly to database (development only — skips migration files)\nnpx drizzle-kit push\n\n# Run pending migrations (production)\nnpx drizzle-kit migrate\n\n# Open Drizzle Studio (GUI database browser)\nnpx drizzle-kit studio\n```\n\n## Database Client Setup\n\n### PostgreSQL (Neon Serverless)\n\n```typescript\n\u002F\u002F db\u002Findex.ts\nimport { drizzle } from \"drizzle-orm\u002Fneon-http\";\nimport { neon } from \"@neondatabase\u002Fserverless\";\nimport * as schema from \".\u002Fschema\";\n\nconst sql = neon(process.env.DATABASE_URL!);\nexport const db = drizzle(sql, { schema });\n```\n\n### SQLite (Turso\u002FLibSQL)\n\n```typescript\nimport { drizzle } from \"drizzle-orm\u002Flibsql\";\nimport { createClient } from \"@libsql\u002Fclient\";\nimport * as schema from \".\u002Fschema\";\n\nconst client = createClient({\n  url: process.env.TURSO_DATABASE_URL!,\n  authToken: process.env.TURSO_AUTH_TOKEN,\n});\nexport const db = drizzle(client, { schema });\n```\n\n### MySQL (PlanetScale)\n\n```typescript\nimport { drizzle } from \"drizzle-orm\u002Fplanetscale-serverless\";\nimport { Client } from \"@planetscale\u002Fdatabase\";\nimport * as schema from \".\u002Fschema\";\n\nconst client = new Client({ url: process.env.DATABASE_URL! });\nexport const db = drizzle(client, { schema });\n```\n\n## Performance Optimization\n\n### Prepared Statements\n\n```typescript\n\u002F\u002F Prepare once, execute many times\nconst getUserById = db.query.users\n  .findFirst({\n    where: eq(users.id, sql.placeholder(\"id\")),\n  })\n  .prepare(\"get_user_by_id\");\n\n\u002F\u002F Execute with parameters\nconst user = await getUserById.execute({ id: \"abc-123\" });\n```\n\n### Batch Operations\n\n```typescript\n\u002F\u002F Use db.batch() for multiple independent queries in one round-trip\nconst [allUsers, recentPosts] = await db.batch([\n  db.select().from(users),\n  db.select().from(posts).orderBy(desc(posts.createdAt)).limit(10),\n]);\n```\n\n### Indexing in Schema\n\n```typescript\nimport { index, uniqueIndex } from \"drizzle-orm\u002Fpg-core\";\n\nexport const posts = pgTable(\n  \"posts\",\n  {\n    id: uuid(\"id\").defaultRandom().primaryKey(),\n    title: text(\"title\").notNull(),\n    authorId: uuid(\"author_id\").references(() => users.id).notNull(),\n    createdAt: timestamp(\"created_at\").defaultNow().notNull(),\n  },\n  (table) => [\n    index(\"posts_author_idx\").on(table.authorId),\n    index(\"posts_created_idx\").on(table.createdAt),\n  ]\n);\n```\n\n## Next.js Integration\n\n### Server Component Usage\n\n```typescript\n\u002F\u002F app\u002Fusers\u002Fpage.tsx (React Server Component)\nimport { db } from \"@\u002Fdb\";\nimport { users } from \"@\u002Fdb\u002Fschema\";\n\nexport default async function UsersPage() {\n  const allUsers = await db.select().from(users);\n  return (\n    \u003Cul>\n      {allUsers.map((u) => (\n        \u003Cli key={u.id}>{u.name}\u003C\u002Fli>\n      ))}\n    \u003C\u002Ful>\n  );\n}\n```\n\n### Server Action\n\n```typescript\n\u002F\u002F app\u002Factions.ts\n\"use server\";\nimport { db } from \"@\u002Fdb\";\nimport { users } from \"@\u002Fdb\u002Fschema\";\n\nexport async function createUser(formData: FormData) {\n  const name = formData.get(\"name\") as string;\n  const email = formData.get(\"email\") as string;\n  await db.insert(users).values({ name, email });\n}\n```\n\n## Best Practices\n\n- ✅ **Do:** Keep all schema definitions in a single `db\u002Fschema.ts` or split by domain (`db\u002Fschema\u002Fusers.ts`, `db\u002Fschema\u002Fposts.ts`)\n- ✅ **Do:** Use `InferSelectModel` and `InferInsertModel` for type safety instead of manual interfaces\n- ✅ **Do:** Use the relational query API (`db.query.*`) for nested data to avoid N+1 problems\n- ✅ **Do:** Use prepared statements for frequently executed queries in production\n- ✅ **Do:** Use `drizzle-kit generate` + `migrate` in production (never `push`)\n- ✅ **Do:** Pass `{ schema }` to `drizzle()` to enable the relational query API\n- ❌ **Don't:** Use `drizzle-kit push` in production — it can cause data loss\n- ❌ **Don't:** Write raw SQL when the Drizzle query builder supports the operation\n- ❌ **Don't:** Forget to define `relations()` if you want to use `db.query.*` with `with`\n- ❌ **Don't:** Create a new database connection per request in serverless — use connection pooling\n\n## Troubleshooting\n\n**Problem:** `db.query.tableName` is undefined\n**Solution:** Pass all schema objects (including relations) to `drizzle()`: `drizzle(client, { schema })`\n\n**Problem:** Migration conflicts after schema changes\n**Solution:** Run `npx drizzle-kit generate` to create a new migration, then `npx drizzle-kit migrate`\n\n**Problem:** Type errors on `.returning()` with MySQL\n**Solution:** MySQL does not support `RETURNING`. Use `.execute()` and read `insertId` from the result instead.\n",{"name":5,"metadata":57,"description":7},{"risk":51,"source":43,"date_added":58},"2026-03-04","main","2b749c82b5d11fac39d9a6e021ce3f5b8a541bd1","cli-tool\u002Fcomponents\u002Fskills\u002Fweb-development\u002Fdrizzle-orm-expert",3963,"https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates","https:\u002F\u002Faitmpl.com","https:\u002F\u002Fgithub.com\u002Fdavila7","https:\u002F\u002Fdanielavila.me","Building AI dev tools with LLMs","2026-11-15 01:32:48",{"source":9,"skillName":5,"commands":70,"prompt":80,"zipAvailable":81},[71,74,77],{"tool":72,"command":73},"npx","npx skills add davila7\u002Fclaude-code-templates --skill drizzle-orm-expert",{"tool":75,"command":76},"bunx","bunx skills add davila7\u002Fclaude-code-templates --skill drizzle-orm-expert",{"tool":78,"command":79},"pnpm","pnpm dlx skills add davila7\u002Fclaude-code-templates --skill drizzle-orm-expert","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fweb-development\u002Fdrizzle-orm-expert\u002FSKILL.md",true,[],[84,107,133,156,194,222],{"skillNo":85,"name":86,"nameZh":17,"description":87,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":52},"01M70NHBTQ8BV0A2SCAZXEPHCX","wealthville-pool-scoring","Score DeFi liquidity pools before providing liquidity. Returns a 0-100 pool score and an Enter\u002FHold\u002FExit\u002FReduce\u002FAvoid verdict with calibrated confidence for ~68,800 Solana pools and 575 EVM pools, plus a public miss-inclusive track record. Use when asked whether a pool is worth LPing into, which pools look best right now, or how accurate the scores have actually been.","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fweb-data\u002Fwealthville-pool-scoring\u002FSKILL.md",[],[91,92,93,94,95,39,96,97,47,38,98,41,99,100,101,102,103,104,105,106],"scoring","pool","wealthville pool scoring","liquidity","which","exit","now","reduce","record","track","verdict","evm","solana","how","public","look",{"skillNo":108,"name":109,"nameZh":17,"description":110,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":111,"categories":112,"keywords":113,"publishedAt":52},"01M70MB6VR8ERJ4EM8D5KHBMEV","technical-debt-auditor","Scans a codebase and produces a quantified technical debt report with a prioritized remediation plan. Analyzes dead code, TODO\u002FFIXME\u002FHACK markers, dependency staleness, complexity hotspots, code duplication signals, test coverage gaps, unused exports, and outdated patterns. Use this skill when the user asks to audit their codebase for tech debt, wants a health check of their code quality, says things like \"where should I focus refactoring\", \"find code smells\", \"audit my codebase\", \"what technical debt do we have\", \"prioritize cleanup work\", or asks about code quality metrics. Also trigger when the user mentions \"code rot\", \"legacy cleanup\", \"refactoring priorities\", or wants to understand the overall health of a project before a major effort. Trigger even if the user doesn't say \"technical debt\" explicitly — any request to systematically assess code quality and identify improvement priorities belongs here.","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fdevelopment\u002Ftechnical-debt-auditor\u002FSKILL.md",[],[114,115,116,117,118,119,120,121,122,123,124,38,125,126,127,128,129,130,131,132],"technical debt","debt","technical","technical debt auditor","auditor","coverage","complexity","markers","project","cleanup","unused","code","todo","work","plan","focus","signals","audit","dependency",{"skillNo":134,"name":135,"nameZh":17,"description":136,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":137,"categories":138,"keywords":139,"publishedAt":52},"01M70KPYH9QNHCNME5GJQGE22K","readonly-sql-guard","Make an agent's database access provably read-only. Use when an agent runs caller-supplied SQL against a production\u002FERP\u002Fanalytics database (a \"query\" MCP tool, text-to-SQL, an admin console), or when reviewing DB-access code for write\u002FDDL\u002Fside-effect\u002Ftransaction-escape risks. Checks what a statement CALLS, not just its shape.","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fdatabase\u002Freadonly-sql-guard\u002FSKILL.md",[],[140,141,142,143,144,145,146,39,147,148,149,150,151,152,153,47,154,49,38,155],"readonly","guard","sql guard","sql","readonly sql guard","erp","effect","read-only","db","just","tool","calls","only","MCP","access","query",{"skillNo":157,"name":158,"nameZh":159,"description":160,"descriptionZh":161,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":162,"licenseFileUrl":163,"sourceHtmlUrl":164,"categories":165,"keywords":170,"publishedAt":52},"01M6AFY6F7CC2BBZP1QD6VTNVC","web-artifacts-builder","Claude 网页 Artifact 构建","Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn\u002Fui). Use for complex artifacts requiring state management, routing, or shadcn\u002Fui components - not for simple single-file HTML\u002FJSX artifacts.","用于创建精细的、多组件的 claude.ai HTML artifact 的工具套件，采用现代前端 Web 技术（React、Tailwind CSS、shadcn\u002Fui）。适用于需要状态管理、路由或 shadcn\u002Fui 组件的复杂 artifact —— 不适用于简单的单文件 HTML\u002FJSX artifact。","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Futilities\u002Fweb-artifacts-builder\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Futilities\u002Fweb-artifacts-builder\u002FSKILL.md",[166,167],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":168,"categoryName":169,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BRASNPVNJVQQJ4KZX8XM5D","前端开发与界面实现",[171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,39,193],"artifacts builder","web","web artifacts builder","artifacts","builder","state","routing","state management","component","css","frontend","ui","Tools","file","components","shadcn","react","Tailwind","suite","jsx","html","single-file","ui components",{"skillNo":195,"name":196,"nameZh":197,"description":198,"descriptionZh":199,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":162,"licenseFileUrl":200,"sourceHtmlUrl":201,"categories":202,"keywords":209,"publishedAt":52},"01M6AFWF33SFV9Z3SF4PEEE4BF","webapp-testing","Playwright Web 应用测试","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","使用 Playwright 与本地 Web 应用进行交互和测试的工具包。支持验证前端功能、调试 UI 行为、捕获浏览器截图以及查看浏览器日志。","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fsecurity\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fsecurity\u002Fwebapp-testing\u002FSKILL.md",[203,206],{"categoryNo":204,"categoryName":205,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BQGD5WG86P4AQ5GPSSKBFR","测试工程师",{"categoryNo":207,"categoryName":208,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BQJH394GT47X57A9Q8G7HX","测试与质量保障",[210,211,212,213,214,172,215,181,182,216,217,218,219,39,220,41,221],"webapp testing","testing","webapp","browser","playwright","applications","debugging","toolkit","logs","screenshots","local","behavior",{"skillNo":223,"name":224,"nameZh":225,"description":226,"descriptionZh":227,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":162,"licenseFileUrl":228,"sourceHtmlUrl":229,"categories":230,"keywords":237,"publishedAt":52},"01M6AF67Q67JJJ5V51JR2P52KA","discernment-nudge","回复事实核查追问","After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals, or emails, estimates or projections, analysis or interpretation of data, factual claims they may rely on, or a multi-step argument — invoke this skill BEFORE finalizing your reply and then, if it applies, append 2-3 short follow-up questions, each tied to something specific in what you just produced, that help the user check key facts, probe the reasoning or assumptions, and notice missing context. Do this at most once per conversation. Skip it when the user asked a trivial how-to or simple lookup, wants a purely educational explanation, asked you only to format, convert, or assemble a file from content they provided, is writing code they will run, is doing creative writing or casual chat, or already asked you to double-check, cite, or review — the skill file explains these boundaries and the exact output format.","在你给出用户可能据以行动的实质性答案或草稿之后——建议或推荐、起草的工件（如目标、计划、推介、提案或电子邮件）、估计或预测、数据分析或解读、他们可能依赖的事实声明，或多步骤论证——在最终确定回复之前调用本技能，然后，如适用，附加 2-3 个简短的后续问题，每个问题都与你刚刚产出的具体内容相关，帮助用户核查关键事实、探究推理或假设，并注意到缺失的上下文。每次对话最多执行一次。当用户询问琐碎的操作方法或简单查找、想要纯教育性解释、仅要求根据提供的内容格式化\u002F转换\u002F组装文件、正在编写将要运行的代码、正在进行创意写作或休闲聊天，或已经要求你复核、引用或审查时跳过——技能文件解释了这些边界和确切的输出格式。","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fdiscernment-nudge\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fdavila7\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fdiscernment-nudge\u002FSKILL.md",[231,234],{"categoryNo":232,"categoryName":233,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BQ6TMSBZZX4V1THHNVC815","回答复核",{"categoryNo":235,"categoryName":236,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BS5011KJDVSRXG1DC4P666","普通用户",[238,239,240,241,242,243,244,245,174,246,184,125,247,248,249,250,251,152,252,38,253,254,255,256,257,104,258],"discernment nudge","nudge","interpretation","help","run","reasoning","data","writing","lookup","content","review","conversation","short","up","invoke","you","analysis","claims","argument","assemble","recommendations"]