Database Migration Script Writer skill for Claude and Codex
Writes a migration you can run on production with confidence: forward and rollback steps in your ORM or raw SQL, a preflight check on the data, and a note on…
Install it once and Claude or Codex runs it for you. When your request matches, your AI loads the skill, asks for anything it is missing, and works through the template itself. Prefer to fill it in by hand? See the full prompt template.
Download the skill (.zip) · View SKILL.md
When it is used
Use when a schema change such as adding, renaming, or dropping a column, table, index, or foreign key needs a migration script with rollback for a specific database and ORM. Do not use for designing a schema from scratch, planning a multi-step refactor across many tables, or writing application queries. Related topics: coding, database, migration.
What it will ask you for
- Database system (choose one: PostgreSQL, MySQL, SQLite, MSSQL, MongoDB (schema migration), Other)
- ORM or migration tool (choose one: Raw SQL, Prisma, Drizzle, Knex.js, Alembic (Python), ActiveRecord (Rails), Flyway, Liquibase, None)
- Migration type (choose one: Add column, Rename column, Drop column, Add table, Drop table, Add index, Add foreign key, Change column type, Data transformation)
- Table name (free text, e.g. "The table being modified")
- Change description (longer free text)
- Current schema (optional) (longer free text)
- Approximate row count (free text, e.g. "2 million")
- Include rollback (down migration) (choose one: Yes, No)
- Add data validation before migrating (choose one: Yes, No)
- Wrap in a transaction (choose one: Yes, No)
How it works
- Write the up migration in the tool's idiom and the database's dialect, noting every dialect-specific decision.
- Split the change into non-locking steps for large tables: nullable add, batched backfill, then constraint.
- Write the preflight validation query that must return zero rows when requested, with the action to take when it does not.
- Write the down migration when requested and state exactly what it cannot restore.
- Give the run order, expected locks and downtime, and the query that confirms the migration applied.
What you get
Fenced code blocks for the up migration, the validation query when requested, and the down migration when requested, followed by a short section on run order, locking, downtime, and a confirmation query.
What it watches out for
- Adding a NOT NULL column with a default in one statement on a large table, which rewrites every row under a lock on older database versions.
- Writing a down migration for a dropped column that recreates it empty and calling it a rollback; say the data is gone.
- Wrapping CREATE INDEX CONCURRENTLY or certain DDL in a transaction, which the database rejects or silently downgrades.
How to install
Claude.ai and the Claude desktop app
- Download the skill .zip.
- Open Settings, then Capabilities, and find Skills.
- Choose Upload skill and select the .zip.
- Ask Claude for help with the task. It loads the skill when your request matches.
Claude Code
- Download the skill .zip.
- Unzip it into ~/.claude/skills/ (or .claude/skills/ inside a project).
- Start a new session. Claude Code loads the skill when your request matches.
Codex
- Download the skill .zip.
- Unzip it into ~/.agents/skills/ (or .agents/skills/ inside a project).
- Codex picks it up on its own. Type $ and the skill name to use it, or just ask for the task.
Cursor
- Download the Cursor rule (.mdc).
- Save it in .cursor/rules/ inside your project.
- Cursor's agent applies the rule when your request matches its description.
AGENTS.md (Codex, Cursor, and other coding agents)
- Copy the AGENTS.md section.
- Paste it into AGENTS.md at the root of your repository, creating the file if needed.
- Coding agents that read AGENTS.md follow it when your request fits.