Agent skill

Migration Patterns

by softspark in softspark/ai-toolkit

Zero-downtime DB migrations: expand-contract, double-write, backfill, blue-green.

Apache-2.0Auto-check passedDatabases

Install Migration Patterns

skills CLI
$ npx skills add softspark/ai-toolkit --skill migration-patterns -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install softspark/ai-toolkit migration-patterns --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/softspark/ai-toolkit.git skills-src && mkdir -p .claude/skills && cp -r skills-src/app/skills/migration-patterns .claude/skills/migration-patterns && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
migration-patterns
GitHub stars
179
Token cost
~2.2k tokens
SKILL.md length
510 words
Files
1
Skills in repo
112
Repo updated
First seen
Licence
Apache-2.0

At a glance

Zero-downtime DB migrations: expand-contract, double-write, backfill, blue-green.

  • Works in 3 steps: Expand-Contract Pattern → Safe Column Operations → Rename Column Safely
  • Tasks that involve Database migrations
  • SKILL.md covers Database Migration Tools, Zero-Downtime Migration…, Data Backfill Patterns and API Versioning, plus 7 more sections
  • Calls php, npx and python

What it does

Migration Patterns is an agent skill from softspark/ai-toolkit. Zero-downtime DB migrations: expand-contract, double-write, backfill, blue-green. Triggers: migration, schema change, backfill, ALTER TABLE, online DDL.

Its SKILL.md is about 2.2k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Databases, covering Database migrations, Deployment and Backend development. The repository describes itself as: Professional-grade AI coding toolkit: 94 skills, 44 agents, multi-platform (Claude, Cursor, Windsurf, Copilot, Gemini, Cline, Roo Code, Aider, Augment, Antigravity, Codex CLI… The licence is Apache-2.0.

When your agent uses it

  • Tasks that involve Database migrations
  • Tasks that involve Deployment
  • Tasks that involve Backend development

Example prompts

  • “/migration-patterns”

Requirements

  • Python 3
  • Node.js
  • Docker
  • Pre-approved tools (allowed-tools): Read

Workflow steps

3 steps, taken from the step headings in SKILL.md.

  1. Expand-Contract Pattern
  2. Safe Column Operations
  3. Rename Column Safely

What it can do on your machine

Read from SKILL.md and the folder at commit d64db2b. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • php
    • npx
    • python
    • git
    • kubectl
    • docker

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use npx, git, kubectl and docker, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Migration Patterns loads about 2.2k tokens when it runs. Until then it costs about 43 tokens; SKILL.md has 510 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~43
When it runs · the whole SKILL.md, loaded when a task matches
~2.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from softspark/ai-toolkit at commit d64db2b, republished under its Apache-2.0 licence (© softspark). 510 words, ~2,158 tokens.

Download SKILL.mdSave it as .claude/skills/migration-patterns/SKILL.md (or your agent's skills folder).
name
migration-patterns
description
Zero-downtime DB migrations: expand-contract, double-write, backfill, blue-green. Triggers: migration, schema change, backfill, ALTER TABLE, online DDL.
allowed-tools
Read
effort
medium
user-invocable
false

Migration Patterns

Database Migration Tools

Alembic (Python/SQLAlchemy)
bash
# Initialize
alembic init migrations

# Create migration
alembic revision --autogenerate -m "add users table"

# Apply
alembic upgrade head

# Rollback
alembic downgrade -1
python
# migrations/versions/001_add_users.py
def upgrade():
    op.create_table(
        "users",
        sa.Column("id", sa.Integer, primary_key=True),
        sa.Column("email", sa.String(255), unique=True, nullable=False),
        sa.Column("created_at", sa.DateTime, server_default=sa.func.now()),
    )
    op.create_index("idx_users_email", "users", ["email"])

def downgrade():
    op.drop_index("idx_users_email")
    op.drop_table("users")
Prisma (TypeScript)
bash
# Create migration
npx prisma migrate dev --name add_users

# Apply in production
npx prisma migrate deploy

# Reset (dev only)
npx prisma migrate reset
Laravel (PHP)
bash
# Create migration
php artisan make:migration create_users_table

# Apply
php artisan migrate

# Rollback
php artisan migrate:rollback --step=1

# Dry run
php artisan migrate --pretend
Django (Python)
bash
# Create migration from models
python manage.py makemigrations

# Apply
python manage.py migrate

# Rollback
python manage.py migrate app_name 0001

# Show plan
python manage.py showmigrations
Flyway (Java/SQL)
bash
flyway migrate
flyway info
flyway undo    # Undo last migration (Teams edition)
flyway repair  # Fix metadata table

Zero-Downtime Migration Strategies

1. Expand-Contract Pattern
Phase 1 (Expand): Add new column, keep old
  ALTER TABLE users ADD COLUMN full_name VARCHAR(200);

Phase 2 (Migrate): Copy data
  UPDATE users SET full_name = first_name || ' ' || last_name;

Phase 3 (Switch): Update code to use new column
  Deploy new code that reads/writes full_name

Phase 4 (Contract): Remove old columns
  ALTER TABLE users DROP COLUMN first_name;
  ALTER TABLE users DROP COLUMN last_name;
2. Safe Column Operations
sql
-- Safe: Add nullable column
ALTER TABLE users ADD COLUMN phone VARCHAR(20);

-- Safe: Add column with default (PostgreSQL 11+, instant)
ALTER TABLE users ADD COLUMN status VARCHAR(20) DEFAULT 'active';

-- Safe: Create index concurrently (no lock)
CREATE INDEX CONCURRENTLY idx_users_status ON users(status);

-- UNSAFE: Add NOT NULL without default (locks table)
-- Instead, do it in 3 steps:
ALTER TABLE users ADD COLUMN email VARCHAR(255);
UPDATE users SET email = 'unknown@example.com' WHERE email IS NULL;
ALTER TABLE users ALTER COLUMN email SET NOT NULL;
3. Rename Column Safely
Step 1: Add new column
Step 2: Write to both old and new columns (dual-write)
Step 3: Backfill new column from old
Step 4: Read from new column
Step 5: Stop writing to old column
Step 6: Drop old column (next release)

Data Backfill Patterns

Batch Processing
python
BATCH_SIZE = 1000

def backfill_users():
    last_id = 0
    while True:
        batch = db.execute(
            "SELECT id, first_name, last_name FROM users "
            "WHERE id > :last_id ORDER BY id LIMIT :limit",
            {"last_id": last_id, "limit": BATCH_SIZE}
        ).fetchall()

        if not batch:
            break

        for row in batch:
            db.execute(
                "UPDATE users SET full_name = :name WHERE id = :id",
                {"name": f"{row.first_name} {row.last_name}", "id": row.id}
            )

        db.commit()
        last_id = batch[-1].id
        logger.info(f"Backfilled up to id={last_id}")

API Versioning

URL-Based (Most Common)
GET /api/v1/users
GET /api/v2/users
Header-Based
GET /api/users
Accept: application/vnd.myapp.v2+json
Implementation Pattern
python
# FastAPI
from fastapi import APIRouter

v1_router = APIRouter(prefix="/api/v1")
v2_router = APIRouter(prefix="/api/v2")

@v1_router.get("/users")
def get_users_v1():
    return [{"name": user.name} for user in users]  # Old format

@v2_router.get("/users")
def get_users_v2():
    return [{"full_name": user.name, "id": user.id} for user in users]  # New format

Feature Flags for Gradual Rollout

python
# Simple feature flag
import os

def is_feature_enabled(feature: str, user_id: str | None = None) -> bool:
    flag = os.getenv(f"FF_{feature.upper()}", "false")
    if flag == "true":
        return True
    if flag.endswith("%") and user_id:
        percentage = int(flag[:-1])
        return hash(user_id) % 100 < percentage
    return False

# Usage
if is_feature_enabled("new_search", user_id=request.user.id):
    return new_search(query)
else:
    return old_search(query)

Rollback Strategies

Database Rollback
bash
# Always test rollback before deploying
alembic downgrade -1   # Alembic
npx prisma migrate resolve --rolled-back 20240101_migration  # Prisma
php artisan migrate:rollback --step=1  # Laravel
Application Rollback
bash
# Git-based rollback
git revert HEAD --no-edit
git push

# Container rollback
kubectl rollout undo deployment/api
docker service rollback api

Migration Checklist

  • Forward migration tested on staging
  • Rollback migration tested on staging
  • No data loss in either direction
  • Performance impact assessed (large tables?)
  • Backward compatible with current code
  • Backfill script tested (if needed)
  • Feature flag in place (if needed)
  • Monitoring/alerts configured
  • Team notified of migration window

Anti-Patterns

  • Running migrations without rollback plan
  • Locking large tables during peak hours
  • Mixing schema and data migrations
  • Not testing rollback path
  • Deploying code before migration completes
  • Dropping columns before removing code references

Rules

  • MUST use expand-contract for any column rename, type change, or NOT NULL addition in production — single-step migrations block deploys
  • MUST test the rollback migration on staging with production-like data — an untested rollback is a wish, not a plan
  • NEVER drop a column while code still references it — the deploy window overlaps and some requests will fail
  • NEVER backfill in one big transaction on a large table — batch with explicit progress tracking and resumability
  • CRITICAL: schema changes deploy before the code that uses them. Code deploys before the schema means 500 errors until both complete.
  • MANDATORY: any migration that affects >1M rows or takes >30 seconds on staging runs behind a feature flag — not a schema lock
Show full SKILL.md (262 more words)Show less

Gotchas

  • ALTER TABLE ... ADD COLUMN NOT NULL DEFAULT <value> in Postgres rewrites the whole table before version 11 (fast since 11 for non-volatile defaults). On older versions this locks the table for minutes. Add as NULL + default, backfill, then apply NOT NULL.
  • CREATE INDEX CONCURRENTLY cannot run inside a transaction, which means many migration tools (Alembic default, Rails) need an override to use it. Check the tool's docs for non-transactional migrations.
  • Double-write strategies need explicit reconciliation. "Write to both old and new, then cut over" leaves stale data in the old store unless you schedule a reconciliation pass before the cutover.
  • Feature flags for migration safety must be per-row or per-tenant, not global. A global flag gates the whole deploy; a per-row flag lets a small cohort validate before full rollout.
  • Rolling back an expand-contract migration mid-transition is ambiguous — the reverse direction depends on which phase was partially applied. Document the allowed rollback points in the migration itself.
  • ORM query caches may retain the old schema shape. After an additive migration, services often need a cache flush or restart to see the new column — plan this into the deploy sequence.

When NOT to Load

  • For executing a migration with the detected tool — use /migrate
  • For schema design from scratch — use /database-patterns
  • For pipeline migrations outside the database (config, file formats) — generic patterns here do not apply; use /refactor-plan
  • For zero-downtime application deploys (blue-green, canary) — use /ci-cd-patterns
  • When the database is small and can tolerate downtime — simpler single-step migrations are fine; expand-contract is overhead for tables with <100k rows and no concurrent writers

© softspark, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in app/skills/migration-patterns of softspark/ai-toolkit.

Open the folder on GitHubat commit d64db2b

Compare with similar skills

Migration Patterns next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Migration Patterns compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Migration Patterns this skillsoftspark/ai-toolkit179—~2.2kAutomated safety check: PassApache-2.0
Generate Migrationgetsentry/sentry46k—~2.2kAutomated safety check: PassCustom licence
Migration Risk AnalyzerMathews-Tom/armory328—~2.5kAutomated safety check: PassMIT
Lovableaiskillstore/marketplace4301 repos~2.7kAutomated safety check: NotesNone
Wtfnoobnooc/agent1.4k—~2.1kAutomated safety check: NotesNone
Database Migrationagulli/atlas-agents579—~702Automated safety check: PassMIT

Similar skills

  • Generate Migration

    getsentry/sentry

    Official

    Generate or review Django database migrations for Sentry. An agent skill from getsentry/sentry.

    46k GitHub stars~2.2k tokensUpdated today
    DatabasesAuto-check passed
  • Migration Risk Analyzer

    Mathews-Tom/armory

    Analyzes database migration scripts for lock contention, downtime, rollback strategy, and deployment risk.

    328 GitHub stars~2.5k tokensUpdated 2 days ago
    DatabasesAuto-check passed
  • Lovable

    aiskillstore/marketplace

    Integration skill for Lovable.dev projects. An agent skill from aiskillstore/marketplace.

    430 GitHub starsUsed in 1 repo~2.7k tokens
    DatabasesAuto-check: notes
  • Wtf

    noobnooc/agent

    Pre-launch and pre-commit audit for vibe coding projects. An agent skill from noobnooc/agent.

    1.4k GitHub stars~2.1k tokensUpdated 1 mo ago
    DatabasesAuto-check: notes
  • Database Migration

    agulli/atlas-agents

    Safely run database schema migrations. An agent skill from agulli/atlas-agents.

    579 GitHub stars~702 tokensUpdated 2 mo ago
    DatabasesAuto-check passed
  • Applies ClawHub's repository-specific Convex rules and routes work to the right managed Convex skill for performance, migrations, retention and deployments.

    9.5k GitHub stars~1.4k tokensUpdated yesterday
    DatabasesAuto-check: notes

More from softspark/ai-toolkit

All 112 skills in this repo
  • Prepare Test Env

    softspark/ai-toolkit

    Prepare or verify a project QA environment with source identity, readiness, browser access, evidence paths and owned cleanup.

    179 GitHub stars~1.8k tokensUpdated yesterday
    Auto-check: notes
  • A11y Validate

    softspark/ai-toolkit

    Accessibility validator: WCAG 2.1 AA, EN 301 549, EAA. An agent skill from softspark/ai-toolkit.

    179 GitHub stars~3.8k tokensUpdated yesterday
    Auto-check: notes
  • Analyze

    softspark/ai-toolkit

    Analyzes code quality, complexity, patterns across codebase.

    179 GitHub stars~1k tokensUpdated yesterday
    Auto-check passed
  • Autonomous Dev

    softspark/ai-toolkit

    Drives a brief, specification, issue or existing PR through implementation, review, tests and QA to a ready PR.

    179 GitHub stars~2.6k tokensUpdated yesterday
    Auto-check: notes
  • Brand Voice

    softspark/ai-toolkit

    Direct technical voice for docs, README, user-facing text. An agent skill from softspark/ai-toolkit.

    179 GitHub stars~2.1k tokensUpdated yesterday
    Auto-check passed
  • CI

    softspark/ai-toolkit

    Detect/generate/debug CI pipeline config (GitHub Actions, GitLab CI).

    179 GitHub stars~1.1k tokensUpdated yesterday
    Auto-check: notes

Categories

Questions about Migration Patterns

What does Migration Patterns do?

Zero-downtime DB migrations: expand-contract, double-write, backfill, blue-green. Migration Patterns is an agent skill from softspark/ai-toolkit. Zero-downtime DB migrations: expand-contract, double-write, backfill, blue-green.

When should I use Migration Patterns?

Migration Patterns fits situations like: tasks that involve Database migrations; tasks that involve Deployment; tasks that involve Backend development.

How do I install Migration Patterns in Claude Code?

Run `npx skills add softspark/ai-toolkit --skill migration-patterns -a claude-code`. Or copy the skill folder (app/skills/migration-patterns in softspark/ai-toolkit) into .claude/skills/migration-patterns in your project. Claude Code loads it when a task matches its description.

How do I install Migration Patterns in Codex?

Run `npx skills add softspark/ai-toolkit --skill migration-patterns -a codex`. Or copy the skill folder (app/skills/migration-patterns in softspark/ai-toolkit) into .agents/skills/migration-patterns in your project. Codex loads it when a task matches its description.

Can I use Migration Patterns in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add softspark/ai-toolkit --skill migration-patterns -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/migration-patterns, .gemini/skills/migration-patterns, .github/skills/migration-patterns and .opencode/skills/migration-patterns in your project.

What does Migration Patterns need to run?

Going by SKILL.md and its folder, Migration Patterns needs the command-line tools its instructions call (php, npx, python, git, kubectl and docker). Our summary lists: Python 3; Node.js; Docker. Its frontmatter pre-approves these tools: Read.

Does Migration Patterns access the network?

SKILL.md contains no URLs. Its commands use npx, git and docker, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Migration Patterns safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Migration Patterns use?

Migration Patterns is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Migration Patterns use?

About 2.2k tokens (SKILL.md is roughly 8.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Migration Patterns?

Skills that share tags, products or a category with Migration Patterns: Generate Migration (getsentry/sentry, 46k stars), Migration Risk Analyzer (Mathews-Tom/armory, 328 stars), Lovable (aiskillstore/marketplace, 430 stars) and Wtf (noobnooc/agent, 1.4k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Migration Patterns?

softspark (a GitHub user) maintains it in softspark/ai-toolkit, which has 179 GitHub stars. The repository holds 112 skills in this directory. The repository was last updated on October 7, 2026.

Source: softspark/ai-toolkit on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.