drizzle-safe-migrations — Claude Code skill for safe Drizzle migrations
drizzle-safe-migrations plans safe Drizzle migrations: data backfills, enum/check/default tightening, migration ordering, and rollback. Use it when a schema change touches existing rows.
no license 348 installs ★ 655 updated 2026-10-20
npx skills add pedronauck/skills --skill drizzle-safe-migrations -a claude-codeWhat drizzle-safe-migrations does
The skill sets ground rules for Drizzle migrations. Schema files come from the project's own generate script and stay untouched by hand. Data backfills go into separate custom migrations, and normalization happens before any constraint tightening.
It walks through a fixed sequence: classify the change as schema-only or data-plus-schema, create a custom migration with bun run db:generate -- --custom --name <name> for the backfill, then run bun run db:generate for the schema. After that, check drizzle/meta/_journal.json so the backfill sits before the tightening migration. Finally, run the migration suite against existing data and a fresh install, and write down lock risks and the rollback path.
There is a pointer to references/production-playbook.md with command templates and review checklists. For PostgreSQL under strict uptime, it suggests staged validation with NOT VALID / VALIDATE CONSTRAINT, though that only covers supported constraint kinds. Anti-patterns are explicit: no hand-editing generated files, no tightening before backfill, no hiding one-off logic in app startup code.
What it helps with
- plan a data backfill before tightening constraints
- verify migration order in the Drizzle journal
- write idempotent UPDATEs with narrow WHERE clauses
- run migrations against existing data and a fresh install
- record lock risks and rollback steps
Example prompts for the agent
- Plan a migration that removes
legacy_valuefrom an enum on the orders table - Check the backfill and constraint order in
drizzle/meta/_journal.json - Create a custom migration to normalize old rows before changing a default
How to install drizzle-safe-migrations
1Skills CLI (Vercel)
npx skills add pedronauck/skills --skill drizzle-safe-migrations -a claude-code2Manually: put the files in place
~/.claude/skills/drizzle-safe-migrations/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/drizzle-safe-migrations/
1Skills CLI (Vercel)
npx skills add pedronauck/skills --skill drizzle-safe-migrations -a codex2Manually: put the files in place
.agents/skills/drizzle-safe-migrations/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add pedronauck/skills --skill drizzle-safe-migrations -a cursor2Manually: put the files in place
.cursor/skills/drizzle-safe-migrations/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install pedronauck/skills skills/mine/drizzle-safe-migrations2Manually: put the files in place
.github/skills/drizzle-safe-migrations/SKILL.md1Skills CLI (Vercel)
npx skills add pedronauck/skills --skill drizzle-safe-migrations -a gemini-cli2Platform CLI
gemini skills install https://github.com/pedronauck/skills --path skills/mine/drizzle-safe-migrationsManually: put the files in place
.devin/skills/drizzle-safe-migrations/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add pedronauck/skills --skill drizzle-safe-migrations -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about drizzle-safe-migrations
How do I install drizzle-safe-migrations in Claude Code?
Run npx skills add pedronauck/skills --skill drizzle-safe-migrations -a claude-code. The skill lands in ~/.claude/skills/drizzle-safe-migrations/SKILL.md.
What does drizzle-safe-migrations do?
It enforces a safe order for Drizzle migrations: backfill data with a custom migration first, then generate the schema and tighten constraints. It also checks journal ordering and requires running migrations on both existing data and a fresh install.
How is a custom migration different from a schema migration?
Schema migrations are generated by the project script and should not be edited by hand. Custom migrations are created with bun run db:generate -- --custom --name <name> and only their SQL is edited, for data backfills.