← Back to Library|SkillsMigration Writer
Install this skill: copy and save to ~/.claude/skills/migration-writer/SKILL.md

Migration Writer

Writes safe database migrations with up/down, handles data transformations, and warns about destructive changes.

3 min|Intermediate
BuildQuick WinDeveloper
SKILL.md~/.claude/skills/migration-writer/
---
name: migration-writer
description: |
  Writes safe database migrations with rollback support.
  IMPORTANT: Activate this skill whenever the user asks to "write a migration",
  "add a column", "change the schema", or "database migration".
  This skill MUST be used for all migration writing requests.
---

# Migration Writer

Writes safe database migrations that handle schema changes, data transformations, and rollbacks. Warns about destructive operations and suggests safe alternatives.

**Trigger:**

Say any of these to activate this skill:
- "write a migration to [change]"
- "add a column to [table]"
- "change the schema"
- "Use skill: migration writer"

**How It Works:**

1. Read the current schema to understand the existing table structure
2. Determine the migration type: add column, modify column, add table, drop column, add index
3. Detect the migration tool (Prisma Migrate, Drizzle Kit, Knex, raw SQL files)
4. Write the UP migration with proper SQL
5. Write the DOWN migration for rollback capability
6. If the migration involves data loss (dropping columns, changing types), add a warning and suggest a two-step migration
7. For data transformations, include the data migration logic
8. Test the migration against the current schema

**Guidelines:**

- Never drop a column in a single migration; first deploy code that stops using it, then drop
- Add new columns as nullable first, backfill data, then add NOT NULL if needed
- Always include a DOWN migration for rollback
- Test migrations on a copy of production data when possible
- Warn explicitly about any operation that could lose data

**Works With:**

- Best with: Claude Code CLI (can read schema, generate migration, and test it)
- Also works: Cursor, Windsurf
- Expects: A project with a database and migration tooling

**Output Format:**

- Migration file in the project's format (SQL, TypeScript, Prisma schema change)
- UP and DOWN operations
- Warnings for any destructive operations

Writes safe database migrations that handle schema changes, data transformations, and rollbacks. Warns about destructive operations and suggests safe alternatives.

Say any of these to activate this skill: - "write a migration to [change]" - "add a column to [table]" - "change the schema" - "Use skill: migration writer"

1. Read the current schema to understand the existing table structure 2. Determine the migration type: add column, modify column, add table, drop column, add index 3. Detect the migration tool (Prisma Migrate, Drizzle Kit, Knex, raw SQL files) 4. Write the UP migration with proper SQL 5. Write the DOWN migration for rollback capability 6. If the migration involves data loss (dropping columns, changing types), add a warning and suggest a two-step migration 7. For data transformations, include the data migration logic 8. Test the migration against the current schema

  • Never drop a column in a single migration; first deploy code that stops using it, then drop
  • Add new columns as nullable first, backfill data, then add NOT NULL if needed
  • Always include a DOWN migration for rollback
  • Test migrations on a copy of production data when possible
  • Warn explicitly about any operation that could lose data
  • Best with: Claude Code CLI (can read schema, generate migration, and test it)
  • Also works: Cursor, Windsurf
  • Expects: A project with a database and migration tooling
  • Migration file in the project's format (SQL, TypeScript, Prisma schema change)
  • UP and DOWN operations
  • Warnings for any destructive operations
Migration Writer | Library | Modern Vibe Coding