agentleFS
chatquillchatquill/claude-code-websites/.claude/skills/db-migration/SKILL.md

db-migration

Skill1 starsChanged 24 days agoMITView on GitHub

Creates a safe database migration with the project's ORM or migration tool: designs the change, generates it locally, reviews the SQL, plans expand/contract for breaking changes, and writes rollback notes. Never applies migrations to shared, staging or production databases. Use for any schema change.

27 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use api-endpoint, add-api-endpoint and 8 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

  • dream-horizon-orgSkill

    add-api-endpoint

    Step-by-step workflow for adding a new REST API endpoint to pulse-server. Use when creating a new backend endpoint, route, resource, or API in backend/server/.

    Also in 3 projects that use this

  • SentrySkill

    write-tests

    Write tests following project conventions. Use when adding new tests or modifying existing ones.

    Also in 3 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

  • AnthropicSkill

    debug

    Structured debugging session — reproduce, isolate, diagnose, and fix. Trigger with an error message or stack trace, "this works in staging but not prod", "something broke after the deploy", or when behavior diverges from expected and the cause isn't obvious.

    Also in 3 projects that use this

  • +1 more from Azure

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 23 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Update the schema file (Prisma schema, Drizzle tables, SQLAlchemy/Django/Eloquent/ ActiveRecord models), then generate with the stack's …

    line 44
  2. Distinctive:

    Read the generated SQL and check:

    line 52
  3. Very specific:

    no unintended DROP or table rewrite

    line 53
  4. Very specific:

    Write a rollback note in the migration folder or the story's ## Notes: the reverse migration or the follow-up migration that undoes it, and …

    line 63

“Common” is measured: kept by at least 6 in 10 of the 23 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

DB Migration

Schema changes are the one kind of code that can destroy data. This skill generates and reviews the migration locally and prints the deploy step for the user. It never runs migrate deploy, db push, migrate reset, supabase db push or anything that touches a shared database.

Inputs

  • The change (argument) and the story/spec it serves
  • docs/architecture/data-model.md (update it alongside)
  • project.yaml → stack.database, stack.orm, .claude/docs/stack-matrix.md (migration commands)
  • Existing migrations folder (prisma/migrations, drizzle/, alembic/versions, */migrations, database/migrations, db/migrate)

Phases

Phase 1: Design

Spawn data-engineer (+ the data specialist for the stack) to propose the change: columns, types, constraints, indexes, defaults, and the data impact.

Classify it:

  • Additive (new table, nullable column, new index): one migration.
  • Breaking (rename, drop, type change, NOT NULL on existing data): expand → migrate → contract across separate deploys:
    1. Expand: add the new column/table; code writes both.
    2. Backfill: batched data migration (script or job), idempotent.
    3. Switch reads to the new shape.
    4. Contract: drop the old column in a later release.

Show the plan and ask "Proceed?"

Phase 2: Generate locally

Update the schema file (Prisma schema, Drizzle tables, SQLAlchemy/Django/Eloquent/ ActiveRecord models), then generate with the stack's create-only/generate command (e.g. npx prisma migrate dev --create-only --name <slug>, npx drizzle-kit generate, alembic revision --autogenerate -m, python manage.py makemigrations). Ask before each write and command.

Phase 3: Review the SQL

Read the generated SQL and check:

  • no unintended DROP or table rewrite
  • large tables: indexes CONCURRENTLY (Postgres), no long locks; NOT NULL added after backfill
  • defaults that are cheap (no volatile defaults rewriting big tables)
  • foreign keys indexed; constraints named
  • RLS policies for new tables on Supabase

Report findings; fix and regenerate as needed.

Phase 4: Rollback and docs

Write a rollback note in the migration folder or the story's ## Notes: the reverse migration or the follow-up migration that undoes it, and whether data can be lost. Update docs/architecture/data-model.md. Ask before writing.

Phase 5: Hand off

Tell the user the commands to apply it, in order:

  • local: npx prisma migrate dev (or equivalent), which they may let you run on the local dev DB
  • deploy: the CI/deploy step (e.g. npx prisma migrate deploy run by the pipeline), after a backup

Next step

Back to /dev-story for the code that uses the new schema.

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.