agentleFS
bInference-LabbInference-Lab/bInference/.agents/skills/add-migration/SKILL.md

add-migration

Skill2 starsChanged 2 days agoMITView on GitHub

Adds a database migration to the store package. Use when a change needs a new table, column or index, or a change to stored data.

17 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use add-provider.

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.
  • PydanticSkill

    add-provider

    Add a new inference provider to genai-prices, including provider data, matching, usage extractors, update automation, cassettes, agentic checks, generated artifacts, and Python/JavaScript/Go parity tests. Use for a new provider, not a new model on an existing provider.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 15 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Never edit, rename or renumber a migration that has shipped.

    line 14
  2. Very specific:

    Write its Postgres form under the same file name in src/migrations/<database>-postgres/ (database spec, section 6.3): times and integers …

    line 27
  3. Distinctive:

    Write transactions stay synchronous: plan the async work first, reread the rows that decide, then write and commit.

    line 36
  4. Distinctive:

    Run the store's contract suite and the migration runner test.

    line 43
  5. Very specific:

    Run postgres-forms.postgres.test.ts, which compares both databases after each version, on BINFERENCE_TEST_POSTGRES_URL or Docker.

    line 44

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

Add a migration

Migrations are numbered, forward-only and never edited after a release. binference check --fix runs them after it takes a backup.

1. Name the file

  • The next free number, four digits, then a snake_case name: 0007_add_order_tags.ts.
  • Never edit, rename or renumber a migration that has shipped. A mistake is fixed by the next migration.
  • There is no down step.

2. Write it

  • One migration runs in one transaction; a failure rolls all of it back.
  • Tables and columns are snake_case.
  • Ids are UUIDv7 text with their type prefix (int_, ord_, cnf_, tx_, agt_, wal_).
  • Times are epoch milliseconds in UTC.
  • Amounts are decimal strings of base units, never integers: SQLite integers stop at 64 bits.
  • The ledger is append-only. A migration never updates or deletes ledger rows.
  • Raw SQL belongs in migrations and the schema bootstrap only. Queries elsewhere use Kysely.
  • Write its Postgres form under the same file name in src/migrations/<database>-postgres/ (database spec, section 6.3): times and integers bigint, flags smallint checked to 0 or 1, amounts numeric(78,0), JSON text checked IS JSON, other text COLLATE "C", a GLOB as a regular expression, a trigger as PL/pgSQL with SET search_path FROM CURRENT, no schema named. A write-order key takes its value from counters. check:store fails a migration without it.

3. Move the code with it

  • The store port and its SQLite adapter change in the same commit as the migration.
  • Write transactions stay synchronous: plan the async work first, reread the rows that decide, then write and commit.
  • A new money column gets a contract test that round-trips 2^64 + 1.

4. Test

  • The migrated-schema test sees the new table or column.
  • Run the store's contract suite and the migration runner test.
  • Run postgres-forms.postgres.test.ts, which compares both databases after each version, on BINFERENCE_TEST_POSTGRES_URL or Docker.
  • Run pnpm check.

5. Report

Name the migration, what it changes, and the tests that cover it. Mention it in the pull request body, since it changes every user's database on the next start.

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.