[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6R4FW9BQB66W1ATFAHVHZWN":3,"skill-same:01M6R4FW9BQB66W1ATFAHVHZWN":75},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":26,"publishedAt":48,"linkOnly":49,"markdownContent":50,"markdownBody":51,"frontMatter":52,"refName":54,"commitSha":55,"skillDirectory":56,"forksCount":57,"repositoryHtmlUrl":58,"repositoryHomepageUrl":6,"ownerHtmlUrl":59,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":60,"install":61,"resources":74},"01M6R4FW9BQB66W1ATFAHVHZWN","drizzle-orm-expert",null,"Expert in Drizzle ORM for TypeScript — schema design, relational queries, migrations, and serverless database integration. Use when building type-safe database layers with Drizzle.","Mishit18\u002Fclaude-code-templates","Mishit18","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F244127857?v=4","01M6QXBYKWM76HSKYDNWSKKE41","Mishit Sharma","01M6QXBYRJ0CAVM51S1RTEKTZZ",1,"MIT","https:\u002F\u002Fgithub.com\u002FMishit18\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fweb-development\u002Fdrizzle-orm-expert\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000015","视觉设计",[27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47],"drizzle orm expert","orm","drizzle orm","drizzle","expert","queries","2026","when","for","layers","with","type","relational","community","design","schema design","schema","use","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.\"\nrisk: safe\nsource: community\ndate_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\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\n",{"name":5,"risk":47,"source":40,"date_added":53,"description":7},"2026-03-04","main","015422534a7457348a313b6381f0255d3364eb8c","cli-tool\u002Fcomponents\u002Fskills\u002Fweb-development\u002Fdrizzle-orm-expert",0,"https:\u002F\u002Fgithub.com\u002FMishit18\u002Fclaude-code-templates","https:\u002F\u002Fgithub.com\u002FMishit18","2026-11-14 17:36:32",{"source":8,"skillName":5,"commands":62,"prompt":72,"zipAvailable":73},[63,66,69],{"tool":64,"command":65},"npx","npx skills add Mishit18\u002Fclaude-code-templates --skill drizzle-orm-expert",{"tool":67,"command":68},"bunx","bunx skills add Mishit18\u002Fclaude-code-templates --skill drizzle-orm-expert",{"tool":70,"command":71},"pnpm","pnpm dlx skills add Mishit18\u002Fclaude-code-templates --skill drizzle-orm-expert","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FMishit18\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fweb-development\u002Fdrizzle-orm-expert\u002FSKILL.md",true,[],[76,105,134,159,185,196],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":80,"licenseFileUrl":81,"sourceHtmlUrl":82,"categories":83,"keywords":87,"publishedAt":104},"01M6R194Y2CS39V9VPAVRVW1ZV","skill-creation-guide","Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.","Apache-2.0","https:\u002F\u002Fgithub.com\u002FMishit18\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fdevelopment\u002Fskill-creation-guide\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FMishit18\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fdevelopment\u002Fskill-creation-guide\u002FSKILL.md",[84],{"categoryNo":85,"categoryName":86,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,37,35,103,34],"skill creation guide","guide","creation","skill creation","workflows","create","update","capabilities","knowledge","tool","integrations","specialized","new skill","existing skill","users","Existing","2026-11-11 15:11:14",{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":80,"licenseFileUrl":109,"sourceHtmlUrl":110,"categories":111,"keywords":115,"publishedAt":48},"01M6R4ARN4W2VZRDERDTMN1KP0","web-artifacts-builder","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.","https:\u002F\u002Fgithub.com\u002FMishit18\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Futilities\u002Fweb-artifacts-builder\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FMishit18\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Futilities\u002Fweb-artifacts-builder\u002FSKILL.md",[112],{"categoryNo":113,"categoryName":114,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000009","前端开发",[116,117,118,119,120,121,122,123,124,125,126,127,128,129,44,130,131,132,35,133],"web artifacts builder","web","artifacts","artifacts builder","builder","frontend","css","components","react","routing","state management","state","file","Tailwind","single-file","ui components","multi","single",{"skillNo":135,"name":136,"nameZh":6,"description":137,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":80,"licenseFileUrl":138,"sourceHtmlUrl":139,"categories":140,"keywords":145,"publishedAt":48},"01M6R45GXREM5DP8T08MAC788H","webapp-testing","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.","https:\u002F\u002Fgithub.com\u002FMishit18\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fsecurity\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FMishit18\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fsecurity\u002Fwebapp-testing\u002FSKILL.md",[141,144],{"categoryNo":142,"categoryName":143,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量",{"categoryNo":113,"categoryName":114,"taxonomyType":21,"taxonomyTypeDesc":22},[146,147,148,121,149,150,117,151,152,153,154,155,156,157,158,37,35],"testing","webapp testing","webapp","screenshots","playwright","debugging","toolkit","browser","ui","logs","applications","behavior","local",{"skillNo":160,"name":161,"nameZh":6,"description":162,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":163,"sourceHtmlUrl":164,"categories":165,"keywords":166,"publishedAt":48},"01M6R2GYJ470X8EB7R58V0B68K","think-tank","Run a Virtual Think Tank — a structured multi-persona debate — before planning or making architectural\u002Fdesign\u002Fstrategic decisions. Use this skill whenever the user is about to plan a system, make a technology choice, evaluate trade-offs, decide on an approach, or faces any decision where multiple perspectives would sharpen the outcome. Also trigger when the user says \"think tank\", \"debate this\", \"perspectives on\", \"trade-offs\", \"should I use X or Y\", \"help me decide\", \"before we plan\", or asks for pros\u002Fcons of competing approaches. This skill should run BEFORE any implementation planning begins — it produces a structured analysis that feeds into better plans.","https:\u002F\u002Fgithub.com\u002FMishit18\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fthink-tank\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FMishit18\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fthink-tank\u002FSKILL.md",[],[167,168,41,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,34],"think tank","think","run","feeds","analysis","persona","plan","sharpen","virtual","decision","choice","decide","perspectives","outcome","me","debate","make","trade-offs",{"skillNo":186,"name":187,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":80,"licenseFileUrl":188,"sourceHtmlUrl":189,"categories":190,"keywords":192,"publishedAt":48},"01M6R2FSR55AVRFA9YZ8SC2GZG","skill-creator","https:\u002F\u002Fgithub.com\u002FMishit18\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fskill-creator\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FMishit18\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fskill-creator\u002FSKILL.md",[191],{"categoryNo":85,"categoryName":86,"taxonomyType":21,"taxonomyTypeDesc":22},[193,194,92,93,94,95,96,97,98,99,89,100,101,102,37,35,103,34,195],"skill creator","creator","new",{"skillNo":197,"name":198,"nameZh":6,"description":199,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":200,"categories":201,"keywords":202,"publishedAt":48},"01M6R2FK42ZZ4HJTJVVK9WJBBP","ship-learn-next","Transform learning content (like YouTube transcripts, articles, tutorials) into actionable implementation plans using the Ship-Learn-Next framework. Use when user wants to turn advice, lessons, or educational content into concrete action steps, reps, or a learning quest.","https:\u002F\u002Fgithub.com\u002FMishit18\u002Fclaude-code-templates\u002Fblob\u002Fmain\u002Fcli-tool\u002Fcomponents\u002Fskills\u002Fproductivity\u002Fship-learn-next\u002FSKILL.md",[],[203,204,205,206,207,208,209,210,44,211,212,213,214,215,216,217,218,219,220,34],"learn","ship learn next","ship","next","framework","learning","read","write","advice","implementation","youtube","plans","quest","transform","actionable","action","lessons","youtube transcripts"]