Drizzle ORM patterns for PostgreSQL schemas, queries, migrations, and Zod integration. Triggers on drizzle, pgTable, db.select, db.insert, migration.
Builds PostgreSQL schemas and queries using Drizzle ORM with TypeScript type inference. Triggers on drizzle, pgTable, db.select, db.insert, and migration patterns.
/plugin marketplace add settlemint/agent-marketplace/plugin install devtools@settlemintThis skill inherits all available tools. When active, it can use any tool Claude has access to.
templates/queries.ts.mdtemplates/table-schema.ts.md<mcp_first> CRITICAL: Always fetch Drizzle documentation before implementing.
MCPSearch({ query: "select:mcp__plugin_devtools_context7__query-docs" })
// Drizzle schema patterns
mcp__context7__query_docs({
libraryId: "/drizzle-team/drizzle-orm",
query: "How do I define tables with pgTable, text, boolean, and timestamp?",
});
// Query patterns
mcp__context7__query_docs({
libraryId: "/drizzle-team/drizzle-orm",
query: "How do I use db.select, db.insert, db.update, and db.delete?",
});
// Relations
mcp__context7__query_docs({
libraryId: "/drizzle-team/drizzle-orm",
query: "How do I define relations with one and many, and use db.query?",
});
// Migrations
mcp__context7__query_docs({
libraryId: "/drizzle-team/drizzle-orm",
query: "How do I use drizzle-kit for generate, migrate, and push?",
});
Note: Context7 v2 uses server-side filtering. Use descriptive natural language queries. </mcp_first>
<quick_start> Templates:
| Template | Purpose |
|---|---|
templates/table-schema.ts.md | Table definition with types |
templates/queries.ts.md | CRUD query patterns |
Define a table:
import { pgTable, text, boolean, timestamp, index } from "drizzle-orm/pg-core";
export const contacts = pgTable(
"contact",
{
id: text("id").primaryKey(),
name: text("name").notNull(),
email: text("email").notNull().unique(),
enabled: boolean("enabled").default(true),
userId: text("user_id")
.notNull()
.references(() => user.id, { onDelete: "cascade" }),
createdAt: timestamp("created_at", { withTimezone: true })
.defaultNow()
.notNull(),
},
(table) => [index("idx_contact_user_id").on(table.userId)],
);
// Always export inferred types
export type InsertContact = typeof contacts.$inferInsert;
export type SelectContact = typeof contacts.$inferSelect;
Query patterns:
import { eq, and, desc } from "drizzle-orm";
// Select with filter
const results = await db
.select()
.from(contacts)
.where(eq(contacts.userId, userId))
.orderBy(desc(contacts.createdAt));
// Insert
await db
.insert(contacts)
.values({ id: crypto.randomUUID(), name, email, userId });
// Update
await db.update(contacts).set({ enabled: false }).where(eq(contacts.id, id));
// Delete
await db.delete(contacts).where(eq(contacts.id, id));
</quick_start>
<constraints> **Banned:** - Raw SQL without `sql` template - Manual connection management - Editing migration files - Re-exports via barrel files (import from canonical source) - PGLite test database in production (`NODE_ENV` guard required) - Dev credentials or test mocks in production - Premature abstractions (three similar lines better than early helper)Required:
$inferInsert and $inferSelect types{ withTimezone: true }onDelete action specifiedNODE_ENV === "production" checkNaming: Schema files=lowercase-with-hyphens.ts, Tables=singular noun
</constraints>
<success_criteria>
$inferInsert and $inferSelect type exports{ withTimezone: true }onDelete actionThis skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.