agentleFS
lautioliverlautioliver/barrilete-kit/.claude/skills/db-migration/SKILL.md

db-migration

Skill6 starsChanged 7 days agoMITView on GitHub

Plans and writes schema changes and database migrations safely (compatibility, backfill, rollback, validation). Use whenever a change touches the schema or migrations, with "/db-migration", "add a column", "change table X" or similar.

26 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 6 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

    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

  • Microsoft AzureSkill

    verify

    End-to-end app testing pipeline for browser-based web apps on cloud browsers via Azure Playwright Workspaces: verify the live app, author tests for working flows, heal failing tests, then re-run with video and produce one consolidated report. Three phases (app verification, test authoring, test healing) plus a scoped final sanity run; each phase emits a sub-report. Use when asked to "verify my app", "make sure my app works and has good test coverage", "do a full QA pass", "add tests where I'm missing coverage", "fix failing tests and add new ones", "smoke test before deploy", "QA my deployment", or any combined verify-and-test ask. Requires Azure CLI (`az login`) and a Playwright Workspace resource ID — bootstraps configs on first invocation. Browser-based web apps with Playwright only — not for unit/API tests, native mobile/desktop, load/perf, or full accessibility audits.

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

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 22 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Never: run migrations against shared environments or production.

    line 33
  2. Distinctive:

    Run it locally / in tests from scratch and over existing data.

    line 38

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

A schema change is among the hardest things to revert: data that is already migrated does not come back on its own. That is why it requires approval (AGENTS.md, "Agent autonomy" section) and this plan before writing the migration.

The concrete commands (generate a migration, run it locally, tests) are in AGENTS.md. TODO: if the project has a migration tool (Drizzle, Prisma, Alembic, hand-written SQL…), document its particulars here.

1. Plan (show it and wait for approval)

Touching the schema also requires the approval that the "Agent autonomy" section of AGENTS.md asks for: ask for both in the same message, with this table. Then the full table goes into the PR.

PointWhat to answer
Current schemaTables/columns/indexes/constraints involved, as they are today (read it from the schema code, not from memory).
Desired schemaThe exact change.
CompatibilityDoes the code deployed today keep working with the new schema? (versions coexist during the deploy). Are there external readers (reports, other services)?
MigrationSQL steps. Does it lock the table? How long does it take with the production volume?
BackfillDoes existing data need to be filled in? How, in batches, idempotent?
RollbackHow to go back. If it cannot be done without losing data, say so explicitly.
ValidationHow to check afterwards that it came out right (queries, counts, tests).

2. Rules

  • Destructive changes in two steps (expand / contract): first add the new thing and make the code use both; in a later PR, when nothing uses the old one, delete it. Never rename or drop a column in use in a single deploy.
  • New NOT NULL column on a table with data: add it nullable or with a default → backfill → only then NOT NULL.
  • Indexes on large tables: concurrently if the engine allows it.
  • Invariants in the database (constraints, CHECK, UNIQUE) when the rule has to hold always; not only in the code.
  • Migrations are immutable once merged: if something has to be fixed, a new migration.
  • Never run migrations against shared environments or production. Only local or the test database.

3. Implement

  1. Change the schema and generate the migration with the project's tool. Review the generated SQL line by line.
  2. Run it locally / in tests from scratch and over existing data.
  3. Tests: the new behavior, and that the old data is still valid.
  4. Docs: docs/reference/domain.md (and whatever agents_map.py says). If it is a data-model decision that is hard to revert, an ADR.

4. PR

In the PR body, the full table from step 1, rollback included. If it is a two-step change, say which step it is in and open the issue for the next one (create-issue, blocked by this one).

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.