drizzle-db
Skill2 starsChanged 40 days agoMITView on GitHub
Drizzle ORM schema design, migrations, and query patterns for PostgreSQL. Use when creating tables, writing queries, defining relations, managing migrations, or working with NeonDB. Covers pgTable, indexes, enums, jsonb columns, transactions, soft delete, pagination, drizzle-kit generate/migrate, and serverless connection patterns.
- Reads credentials
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 3 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 116
Use neon-http driver for serverless (one-shot queries, no persistent connection)
- Very specific: line 117
Use neon-serverless with WebSocket for transactions
- Distinctive: line 158
Don't use raw SQL when Drizzle query builder works
- Very specific: line 159
Don't skip .returning() on insert/update when you need the result
- Distinctive: line 160
Don't forget indexes on columns used in WHERE clauses
- Very specific: line 161
Don't use drizzle-kit push in production — use migrations
- Very specific: line 162
Don't store dates without timezone — always use { withTimezone: true }
- Distinctive: line 163
Don't forget to close connections in serverless (use connection pooling)
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Drizzle ORM Patterns
Schema Definition
import { pgTable, text, timestamp, integer, boolean, jsonb, uuid, index } from 'drizzle-orm/pg-core';
export const users = pgTable('users', {
id: uuid('id').defaultRandom().primaryKey(),
email: text('email').notNull().unique(),
name: text('name').notNull(),
role: text('role', { enum: ['admin', 'user', 'guest'] }).notNull().default('user'),
metadata: jsonb('metadata').$type<UserMetadata>(),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
}, (table) => [
index('users_email_idx').on(table.email),
]);Relations
import { relations } from 'drizzle-orm';
export const usersRelations = relations(users, ({ many }) => ({
posts: many(posts),
}));
export const postsRelations = relations(posts, ({ one }) => ({
author: one(users, {
fields: [posts.authorId],
references: [users.id],
}),
}));Queries
// Select with relations
const result = await db.query.users.findMany({
where: eq(users.role, 'admin'),
with: { posts: true },
limit: 10,
});
// Insert
const [newUser] = await db.insert(users)
.values({ email: 'user@example.com', name: 'User' })
.returning();
// Update
await db.update(users)
.set({ name: 'Updated' })
.where(eq(users.id, userId));
// Delete
await db.delete(users).where(eq(users.id, userId));
// Transaction
await db.transaction(async (tx) => {
const [user] = await tx.insert(users).values(userData).returning();
await tx.insert(profiles).values({ userId: user.id });
});Migrations
# Generate migration from schema changes
drizzle-kit generate
# Apply migrations
drizzle-kit migrate
# Push schema directly (dev only)
drizzle-kit push// drizzle.config.ts
import { defineConfig } from 'drizzle-kit';
export default defineConfig({
schema: './src/schema/*.ts',
out: './drizzle',
dialect: 'postgresql',
dbCredentials: {
url: process.env.DATABASE_URL!,
},
});NeonDB (Serverless)
import { neon } from '@neondatabase/serverless';
import { drizzle } from 'drizzle-orm/neon-http';
const sql = neon(process.env.DATABASE_URL!);
const db = drizzle(sql, { schema });- Use
neon-httpdriver for serverless (one-shot queries, no persistent connection) - Use
neon-serverlesswith WebSocket for transactions - Branch databases for dev/test/staging
Common Patterns
Soft Delete
export const posts = pgTable('posts', {
// ...
deletedAt: timestamp('deleted_at', { withTimezone: true }),
});
// Always filter
const activePosts = await db.query.posts.findMany({
where: isNull(posts.deletedAt),
});Pagination
const page = await db.query.posts.findMany({
limit: 20,
offset: (pageNum - 1) * 20,
orderBy: [desc(posts.createdAt)],
});Type-Safe JSON
interface UserPrefs {
theme: 'light' | 'dark';
notifications: boolean;
}
export const users = pgTable('users', {
prefs: jsonb('prefs').$type<UserPrefs>().default({ theme: 'light', notifications: true }),
});Common Mistakes to Avoid
- Don't use raw SQL when Drizzle query builder works
- Don't skip
.returning()on insert/update when you need the result - Don't forget indexes on columns used in WHERE clauses
- Don't use
drizzle-kit pushin production — use migrations - Don't store dates without timezone — always use
{ withTimezone: true } - Don't forget to close connections in serverless (use connection pooling)
Skill by RevealUI Studio — the agentic business runtime.
Other versions1 project uses a version of this.
Word for word · 1
- RevealUIStudio/revskills★ 2100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository29 other files it gives its agents.
- skills/revealui-design/CLAUDE.mdCLAUDE.md
- electric-syncSkill
- exhaustive-auditSkill
- grok-bot-checkpointSkill
- knowledge-graphSkill
- mcp-serverSkill
- multi-agent-memorySkill
- next-best-practicesSkill
- redundancy-scanSkill
- revealui-checkpointSkill
- revealui-cleanupSkill
- coordinateSkill
- revealui-designSkill
- revealui-design-statusSkill
- revealui-doctorSkill
- revealui-opsSkill
- revealui-pickupSkill
- revealui-recoverSkill
- revealui-rollupSkill
- revealui-skills-testSkill
- revealui-snapshotSkill
- revealui-sync-ltsSkill
- revealui-sync-rulesSkill
- revealui-trackerSkill
- revvault-resolveSkill
- security-hardeningSkill
- tailwind-v4Skill
- vitest-testingSkill
- yjs-collaborationSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

