#What it does
The /migrate skill handles the full lifecycle of code and data migrations -- from database schema changes and API version bumps to framework upgrades and library replacements. It generates migration files, plans the rollback strategy, and ensures zero-downtime transitions by breaking large migrations into safe, reversible steps.
#How to use
bash
/migrate Add a "role" column to the users table with default "member"bash
/migrate Upgrade from Next.js 14 to Next.js 15bash
/migrate Replace moment.js with date-fns across the project#Workflow
- Assess -- Analyze the current state: existing schema, API consumers, framework version, dependency graph. Identify the blast radius of the change
- Plan -- Break the migration into atomic, reversible steps. Each step should be independently deployable and rollback-safe
- Generate -- Create migration files (SQL, ORM migration, codemods) with both
upanddownoperations - Validate -- Check for breaking changes: foreign key constraints, type mismatches, removed fields still in use, API consumers that depend on old behavior
- Execute -- Apply the migration with verification at each step. For database changes, test against a copy of production data first
- Rollback Plan -- Document the exact commands to reverse every step if something goes wrong
#Example
bash
> /migrate Split the "name" column into "first_name" and "last_name"
## Migration Plan (3 phases, zero downtime)
### Phase 1: Add new columns (backward compatible)
- Add first_name VARCHAR(100) nullable
- Add last_name VARCHAR(100) nullable
- Deploy: app writes to both old and new columns
### Phase 2: Backfill data
- UPDATE users SET first_name = split(name)[0], last_name = split(name)[1]
- Verify: SELECT count(*) WHERE first_name IS NULL
- Deploy: app reads from new columns
### Phase 3: Drop old column (after verification period)
- ALTER TABLE users DROP COLUMN name
- Rollback window: 7 days before this step#Safety features
- Never generates destructive migrations without a rollback step
- Warns about migrations that lock large tables
- Checks for dependent views, triggers, and foreign keys before dropping columns
- Recommends expand-contract pattern for breaking schema changes