agentleFS
viknesh20-20viknesh20-20/claude-code-tool-kit/.claude/skills/db-migration/SKILL.md

db-migration

Skill7 starsChanged 7 months agoMITView on GitHub

Generates database migration files for schema changes with up/down migrations, safety checks, rollback instructions, and index recommendations. Auto-detects the ORM/migration tool in use.

24 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use api-endpoint, git-workflow and 4 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • tadoEngSkill

    api-endpoint

    Add or change a backend API endpoint on this product, keeping Pydantic as the single contract authority and regenerating the TypeScript client. Use when asked to add an endpoint, expose data to the frontend, change a request or response shape, or wire a new backend capability into a page.

    Also in 4 projects that use this

  • Microsoft AzureSkill

    git-workflow

    Squad branching model: dev-first workflow with insiders preview channel

    Also in 3 projects that use this

  • Microsoft AzureSkill

    design

    Design rules and conventions for the API Center Portal. Use when editing detail pages, card components, badges, layout, navigation, sidebars, or headers. Covers badge styling, metadata placement, page navigation patterns, and layout alignment.

    Also in 3 projects that use this

  • VercelSkill

    agent-browser

    Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, test web applications, or extract information from web pages.

    Also in 3 projects that use this

  • MicrosoftSkill

    release

    Use ONLY when the user explicitly asks to cut/publish a Huabu desktop release or tag a version. Performs an outward action — bumps the version in apps/desktop/package.json, commits + annotated-tags vX.Y.Z, and pushes the branch + tag. That tag push auto-builds the macOS/Windows installers and publishes a GitHub Release. Provides `status`, `bump`, `tag-push`, and a one-command `run` (bump → tag-push).

    Also in 3 projects that use this

  • +1 more from Azure

The file

We split this skill into the rules it gives an agent

10 rules. 0 are common, 9 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 21 edited versions we read keep these.

  • 9

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Check current schema state

    line 26
  2. Very specific:

    Update schema.prisma first, then generate.

    line 45
  3. Distinctive:

    Create migration file manually following existing patterns.

    line 63
  4. Distinctive:

    Create SQL files with up/down sections.

    line 66
  5. Distinctive:

    Default values for new NOT NULL columns

    line 75
  6. Distinctive:

    Run on staging first

    line 94
  7. Distinctive:

    Always generate both UP and DOWN migrations

    line 103
  8. Distinctive:

    Never drop columns without explicit user confirmation

    line 104
  9. Distinctive:

    Always add indexes for foreign keys

    line 105
  10. Distinctive:

    Test migrations against a copy of production data when possible

    line 106

“Common” is measured: kept by at least 6 in 10 of the 21 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Database Migration Helper

Detect Migration Tool

!ls prisma/ migrations/ alembic/ alembic.ini db/migrate/ knexfile.* flyway.conf sequelize* typeorm* drizzle.config.* 2>/dev/null !ls package.json 2>/dev/null && cat package.json 2>/dev/null | grep -E "prisma|knex|sequelize|typeorm|drizzle|kysely|mikro-orm" | head -5 !ls requirements.txt pyproject.toml 2>/dev/null && cat requirements.txt pyproject.toml 2>/dev/null | grep -iE "alembic|django|sqlalchemy|tortoise" 2>/dev/null | head -5 !ls go.mod 2>/dev/null && cat go.mod 2>/dev/null | grep -E "goose|migrate|atlas|ent" | head -5

Existing Migrations

!find . -path "*/migrations/*" -o -path "*/migrate/*" -o -path "*/prisma/migrations/*" -o -path "*/db/migrate/*" 2>/dev/null | grep -v node_modules | tail -10


Migration Process

Step 1: Understand the Change

  1. Parse the requested schema change
  2. Identify affected tables/collections
  3. Check current schema state
  4. Determine if this is: CREATE, ALTER, DROP, or INDEX

Step 2: Safety Analysis

Data Loss Risk Assessment:

  • Dropping a column/table → HIGH RISK — requires data backup
  • Renaming a column → MEDIUM RISK — two-step migration recommended
  • Adding NOT NULL without default → HIGH RISK — will fail on existing rows
  • Changing column type → MEDIUM RISK — potential data truncation
  • Adding column with default → LOW RISK — safe
  • Adding index → LOW RISK — may lock table on large datasets

Step 3: Generate Migration

For Prisma (Node.js)

npx prisma migrate dev --name <description>

Update schema.prisma first, then generate.

For Alembic (Python/SQLAlchemy)

alembic revision --autogenerate -m "<description>"

For Django

python manage.py makemigrations --name <description>

For Rails ActiveRecord

rails generate migration <Description>

For Knex/Sequelize

Create migration file manually following existing patterns.

For Go (goose/migrate)

Create SQL files with up/down sections.

For Raw SQL

Generate separate UP and DOWN files.

Step 4: Migration Content

UP migration must include:

  • Table/column creation or modification
  • Default values for new NOT NULL columns
  • Indexes for columns used in WHERE, JOIN, ORDER BY
  • Foreign key constraints where appropriate
  • Comments explaining the change

DOWN migration must include:

  • Exact reversal of the UP migration
  • Data preservation strategy if dropping columns
  • Warning comments for irreversible operations

Step 5: Index Recommendations

For the affected tables, recommend indexes based on:

  • New foreign key columns (always index)
  • Columns used in WHERE clauses
  • Columns used in ORDER BY
  • Columns used in JOIN conditions
  • Composite indexes for multi-column queries

Step 6: Deployment Notes

  • Run on staging first
  • Estimated duration for large tables
  • Lock implications (table locks, row locks)
  • Recommended maintenance window (if needed)
  • Rollback command

Rules

  • Always generate both UP and DOWN migrations
  • Never drop columns without explicit user confirmation
  • Always add indexes for foreign keys
  • Test migrations against a copy of production data when possible
  • Include data migration logic if restructuring data

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.