drizzle-integration
SKILL.md
Drizzle Integration
Goal
Set up Drizzle ORM end-to-end with:
drizzle-ormdrizzle-kitpg- project-aligned schema discovery, migration output, and runtime db client
This skill should implement files and scripts, not only propose a plan.
Bundled Reusable Templates
Use these templates as the default source when integrating into a Next.js App Router project:
templates/next-app-router/drizzle.config.tstemplates/next-app-router/.env.exampletemplates/next-app-router/lib/db.tstemplates/next-app-router/lib/schema.example.db.tstemplates/next-app-router/package.scripts.snippet.jsontemplates/next-app-router/drizzle/*.sqltemplates/next-app-router/drizzle/meta/*.jsontemplates/next-app-router/README.md
Reference Implementation
Use this repo-specific reference when the target project follows the same conventions:
reference/sembilan-registry-radix-node/drizzle.config.tsreference/sembilan-registry-radix-node/lib/db.tsreference/sembilan-registry-radix-node/drizzle/*.sqlreference/sembilan-registry-radix-node/drizzle/meta/*.jsonreference/sembilan-registry-radix-node/drizzle/README.mdreference/sembilan-registry-radix-node/README.md
Workflow
- Detect existing project conventions before editing.
- Framework/runtime (
next,vite,node) frompackage.json. - Package manager from lockfile.
- Existing alias/path conventions from
tsconfig.json. - Existing logging approach and env naming conventions.
- Ensure required dependencies exist.
- Runtime deps:
drizzle-orm,pg,@types/pgwhen TypeScript needs it. - Dev deps:
drizzle-kit. - Use the repo package manager (
pnpm,npm,yarn, orbun).
- Add
drizzle.config.ts.
- Load env values predictably (for Next.js, use
@next/env+loadEnvConfig). - Set
dialect: "postgresql". - Set
schemaglob to where*.db.tsfiles live. - Set migration output directory (
./drizzleby default). - Wire
dbCredentials.urltoprocess.env.DATABASE_URL.
- Add a typed runtime db client.
- Create a pooled
pgclient. - Create a
drizzleclient with imported schema modules. - Keep pool tuning explicit (
max,idleTimeoutMillis,connectionTimeoutMillis). - Gate noisy logs behind env flags.
- Add or align schema files.
- Keep schema in
*.db.tsfiles to match drizzle-kit discovery. - Export table objects for type-safe queries.
- Keep naming convention consistent (
snake_casevs default).
- Add migration and workflow scripts.
- Add scripts similar to:
drizzle:generatedrizzle:migratedrizzle:pushdrizzle:studio
- Copy the baseline migration bundle into every target project.
- Always copy all files from
templates/next-app-router/drizzle/to targetdrizzle/. - Include both SQL migration files and
meta/snapshot/journal files. - Keep baseline filenames and ordering unchanged.
- If target already has migrations, append new migrations after baseline and do not rewrite existing history.
- Generate first project-specific migration when appropriate.
- Run
drizzle-kit generateonly after baseline migrations are present. - Review SQL output under
drizzle/. - Do not modify historical migrations unless explicitly requested.
- Validate integration.
- Run type-check and lint commands available in the repo.
- Ensure at least one query compiles against imported schema.
- Verify
DATABASE_URLis documented.
Implementation Rules
- Prefer existing project patterns over introducing new architecture.
- Keep edits minimal and additive.
- Reuse project logger if present; otherwise keep db logging off by default.
- Keep migration history deterministic; never rewrite old migration files silently.
- If project already has partial Drizzle setup, fill missing pieces instead of duplicating.
Completion Checklist
drizzle.config.tsexists and resolves env values.- Runtime db client exists and exports a typed Drizzle instance.
- Schema files are discoverable by the configured glob.
- Migration scripts are present in
package.json. - Baseline migration bundle exists in target
drizzle/(*.sql+meta/*.json). - Additional migrations are generated only after baseline is copied.
- Type-check passes for changed files.
Weekly Installs
1
Repository
comradesharf/se…n-skillsFirst Seen
9 days ago
Security Audits
Installed on
amp1
cline1
opencode1
cursor1
kimi-cli1
codex1