Agent skill

DB Migrate

by simstudioai in simstudioai/sim

Author or review a Drizzle DB migration for zero-downtime safety — expand/contract phasing, backward-compatibility with the deployed app version, and writing the -- migration-safe acknowledgment the…

Apache-2.0Auto-check passedDatabases

Install DB Migrate

skills CLI
$ npx skills add simstudioai/sim --skill db-migrate -a claude-code

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

GitHub CLI
$ gh skill install simstudioai/sim db-migrate --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/simstudioai/sim.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/db-migrate .claude/skills/db-migrate && 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
db-migrate
GitHub stars
30k
Token cost
~2k tokens
SKILL.md length
1,066 words
Files
1
Skills in repo
40
Repo updated
First seen
Licence
Apache-2.0

At a glance

Author or review a Drizzle DB migration for zero-downtime safety — expand/contract phasing, backward-compatibility with the deployed app version, and writing the -- migration-safe acknowledgment the…

  • Works in 2 steps: Expand (this PR): additive,… → Contract (a later PR, after expand is…
  • Adding/editing files under packages/db/migrations/
  • SKILL.md covers The window (why this matters), Expand / contract, Tracking the contract (don't… and The judgment the lint can't do, plus 2 more sections
  • Calls bun and bunx

What it does

DB Migrate is an agent skill from simstudioai/sim. Author or review a Drizzle DB migration for zero-downtime safety — expand/contract phasing, backward-compatibility with the deployed app version, and writing the -- migration-safe acknowledgment the check:migrations lint requires. Use when adding/editing files under packages/db/migrations/ or changing packages/db/schema.ts.

Its SKILL.md is about 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, Linting and formatting and ORMs and data access. The repository describes itself as: Sim is the collaborative workspace to build, deploy, and monitor AI agents and workflows. Used by 100,000+ builders. The licence is Apache-2.0.

When your agent uses it

  • Adding/editing files under packages/db/migrations/
  • Changing packages/db/schema.ts

Example prompts

  • “/db-migrate”

Workflow steps

2 steps, taken from the first numbered list in SKILL.md.

  1. Expand (this PR): additive, backward-compatible schema + code that tolerates both the old and new shape.
  2. Contract (a later PR, after expand is fully deployed): remove the old thing, now that nothing reads it.

What it can do on your machine

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

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • bun
    • bunx

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

  • Network

    No URLs in SKILL.md. Its commands use bunx, 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

DB Migrate loads about 2k tokens when it runs. Until then it costs about 86 tokens; SKILL.md has 1,066 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~86
When it runs · the whole SKILL.md, loaded when a task matches
~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 simstudioai/sim at commit 546d4e7, republished under its Apache-2.0 licence (© simstudioai). 1,066 words, ~2,031 tokens.

Download SKILL.mdSave it as .claude/skills/db-migrate/SKILL.md (or your agent's skills folder).
name
db-migrate
description
Author or review a Drizzle DB migration for zero-downtime safety — expand/contract phasing, backward-compatibility with the deployed app version, and writing the `-- migration-safe` acknowledgment the check:migrations lint requires. Use when adding/editing files under `packages/db/migrations/` or changing `packages/db/schema.ts`.

DB Migrate Skill

You make schema changes that survive a deploy without downtime. The check:migrations lint (scripts/check-migrations-safety.ts) is the deterministic gate; you are the judgment that decides whether a flagged change is actually safe and writes the annotation that satisfies it.

The window (why this matters)

A deploy runs the migration, then rolls out the new app image via blue/green. The two are not atomic and cannot be — during cutover the old task set keeps serving against the already-migrated schema. So:

Every migration must be backward-compatible with the app version that is already deployed.

If a migration drops a column the old code still reads, renames one, or adds a NOT NULL the old inserts don't populate, the old code throws until traffic fully shifts — the downtime we're guarding against. You can't fix this by reordering the pipeline; the only fix is discipline.

Expand / contract

Split every breaking change across two deploys:

  1. Expand (this PR): additive, backward-compatible schema + code that tolerates both the old and new shape.
  2. Contract (a later PR, after expand is fully deployed): remove the old thing, now that nothing reads it.

Never put expand and contract in the same PR. If this PR both removes the code that used a column and drops the column, the old code is still live during cutover — split it.

Per-operation playbook
You want toDo (deploy 1 = expand)Do (deploy 2 = contract)
Add a required columnADD COLUMN nullable or DEFAULT; code writes itbackfill, then SET NOT NULL
Rename a column/tableadd the new name; code dual-writes / reads new-then-olddrop the old name
Drop a column/tablestop all reads/writes in code; ship itDROP (annotate)
Change a column typeadd a new column of the new type; dual-writebackfill, swap reads, drop old
Add FK / CHECKADD CONSTRAINT ... NOT VALIDVALIDATE CONSTRAINT separately
Index an existing tableCOMMIT; breakpoint → SET lock_timeout = 0 → CREATE INDEX CONCURRENTLY IF NOT EXISTS (see packages/db/scripts/migrate.ts)—
Drop an indexCOMMIT; breakpoint → DROP INDEX CONCURRENTLY IF EXISTS — plain DROP INDEX takes ACCESS EXCLUSIVE on the table—
Backfill databatched + idempotent UPDATE (keyset/WHERE, bounded)—

A CREATE INDEX, ADD COLUMN, or ADD CONSTRAINT against a table created in the same migration is always safe (no rows, no live traffic) — the lint already suppresses those.

Tracking the contract (don't let it rot)

The contract half is deferred to a later deploy — and that is exactly when it gets forgotten, leaving dead columns, orphaned tables, and NOT NULLs that never land. Every deferred contract must become a durable, greppable TODO.

When an expand defers a drop, leave a contract-pending marker on the legacy column/table in packages/db/schema.ts — that is the file you will be editing when you finally do the drop, so the reminder lives where the work happens:

ts
// contract-pending(after #5035 is fully deployed): drop once permission-check.ts stops reading it
workspaceId: text('workspace_id'),

Format: contract-pending(<precondition>): <what to drop> — <why it's safe once the precondition holds>. The precondition names the PR/release that removes the last reader and must be fully deployed before the contract ships.

  • The TODO list is a grep — always accurate, never drifts: grep -rn "contract-pending" packages/db apps/sim. Run it when starting migration work to see what is owed.
  • While a drop is pending, tag each doomed column @deprecated and make every read of that table name its columns: no argless select().from(t), findFirst() without columns, argless .returning(), or bare getTableColumns(t) — use omit(getTableColumns(t), [...]). check:pending-drop-tables enforces this.
  • For anything with a real owner or schedule, also open a tracking issue and put its number in the marker.
  • Close the loop in the contract PR: the contract migration's -- migration-safe: annotation references the expand, and you delete the contract-pending marker in the same PR:
    sql
    -- migration-safe: contract of #5035 — workspace_id readers removed there, deployed 2026-06-10
    ALTER TABLE "permission_group" DROP COLUMN "workspace_id";
  • An expand merged without a marker for the drop it defers, or a contract merged without removing its marker, is a bug — flag it in review.
Show full SKILL.md (442 more words)Show less

The judgment the lint can't do

The lint flags risky shapes; it cannot know whether a given drop is safe right now. For each flagged statement, do the work it can't:

  1. Is the dependency gone? Grep the app for the table/column: search apps/sim and packages for the column name, the Drizzle field (camelCase), and the table object. If any live read/write remains, it is not safe — fix the code first.
  2. Did the expand already ship? The removal of that read/write must be in a deploy that is already out, not this same PR. If it's in this PR, split: land the code change now, do the destructive migration in a follow-up after it deploys.
  3. Backfills: confirm the UPDATE/DELETE is batched (bounded WHERE/keyset, not a single whole-table statement), idempotent (safe to replay — a failed migration re-runs unjournaled files from the top), and safe under concurrent writes from the still-live old app.

Workflow

  1. Edit packages/db/schema.ts, then cd packages/db && bunx drizzle-kit generate to produce the SQL. If this is an expand that defers a drop, leave a contract-pending marker on the legacy column (see "Tracking the contract"). If this is the contract, delete the marker it resolves.
  2. Hand-edit the generated SQL where the playbook requires it: CONCURRENTLY + COMMIT; breakpoint for indexes on existing tables, NOT VALID for constraints, batching for backfills.
  3. Run bun run check:migrations (base defaults to origin/staging).
    • Hard errors (add-not-null-no-default, rename, index-not-concurrent, concurrent-index-not-idempotent, concurrent-index-no-commit, drop-index-not-concurrent, concurrent-drop-index-not-idempotent, concurrent-drop-index-no-commit, constraint-not-valid, …): rewrite into expand/contract. Do not try to annotate them away — the lint won't accept it.
    • Annotate tier (drop-table, drop-column, drop-constraint, drop-default, set-not-null, alter-type): only after you've confirmed steps 1–3 above, add a comment on the line directly above the statement:
      sql
      -- migration-safe: `secret` read removed in v0.6.1 (#1234), shipped two deploys ago
      ALTER TABLE "webhook" DROP COLUMN "secret";
      The reason must be specific and name the PR/version that removed the dependency. An empty reason fails the lint.
    • Warnings (data-backfill): non-blocking, but confirm the batching/idempotency before merging.
  4. Regenerate the test schema mock: bun run scripts/generate-schema-mock.ts (check:schema-mock in check:audits fails after any schema.ts change until you do).
  5. Re-run (cd packages/db && bunx drizzle-kit generate) once your migration is written: it must report no schema changes and write no new file, or CI fails on the schema and migrations disagreeing.
  6. Verify locally: cd packages/db && bun run db:migrate against a dev DB.

Hard rule

Never annotate a destructive statement just to make the lint pass. The annotation is a claim that you verified the old code no longer depends on it. If you can't make that claim truthfully, the change belongs in a later deploy — tell the user to split it.

© simstudioai, 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 .agents/skills/db-migrate of simstudioai/sim.

Open the folder on GitHubat commit 546d4e7

Compare with similar skills

DB Migrate 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.

DB Migrate compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
DB Migrate this skillsimstudioai/sim30k—~2kAutomated safety check: PassApache-2.0
DB Migrationskurealnum/dotfiles290—~820Automated safety check: PassNone
Change Database Schemamartin-ueding/geo-activity-playground100—~225Automated safety check: PassCustom licence
Drizzlekurealnum/dotfiles290—~1.3kAutomated safety check: PassNone
Migrationkortix-ai/suna20k—~1.2kAutomated safety check: PassCustom licence
Specx Sqlalchemy Migrationsmaksimzayats/specx202—~822Automated safety check: PassMIT

Similar skills

  • DB Migrations

    kurealnum/dotfiles

    A skill your agent uses when generating or regenerating Drizzle migration files, changing database schema tables or columns, resolving migration sequence conflicts after rebase, reviewing migration…

    290 GitHub stars~820 tokensUpdated 5 mo ago
    DatabasesAuto-check passed
  • Change Database Schema

    martin-ueding/geo-activity-playground

    How to change the SQLAlchemy data model and generate the matching Alembic migration.

    100 GitHub stars~225 tokensUpdated 10 days ago
    DatabasesAuto-check passed
  • Drizzle

    kurealnum/dotfiles

    Drizzle ORM schema and database guide. An agent skill from kurealnum/dotfiles.

    290 GitHub stars~1.3k tokensUpdated 5 mo ago
    DatabasesAuto-check passed
  • Migration

    kortix-ai/suna

    How to change the database schema in this repo. An agent skill from kortix-ai/suna.

    20k GitHub stars~1.2k tokensUpdated today
    DatabasesAuto-check passed
  • Specx Sqlalchemy Migrations

    maksimzayats/specx

    Add or repair Alembic migrations for specx SQLAlchemy services.

    202 GitHub stars~822 tokensUpdated 2 mo ago
    DatabasesAuto-check passed
  • Sqlalchemy

    kid-sid/claude-spellbook

    A skill your agent uses when using async SQLAlchemy 2.0 — defining models, writing queries, managing async sessions, loading relationships without N+1, or setting up and debugging Alembic migrations.

    189 GitHub stars~3.5k tokensUpdated 2 mo ago
    DatabasesAuto-check passed

More from simstudioai/sim

All 40 skills in this repo
  • Sim Helm

    simstudioai/sim

    Install, upgrade, and operate the Sim Helm chart on Kubernetes.

    30k GitHub stars~2.2k tokensUpdated today
    Auto-check passed
  • Add Column Type

    simstudioai/sim

    Add a new table column type to Sim — registry entry, icon, storage shape, coercion, and the behavioral hooks the grid and API read.

    30k GitHub stars~2.9k tokensUpdated today
    Auto-check passed
  • Add Enrichment

    simstudioai/sim

    Add a code-defined table enrichment (registry entry) under apps/sim/enrichments/ backed by an ordered provider cascade, ensuring every provider tool it calls has hosted-key support.

    30k GitHub stars~2.2k tokensUpdated today
    Auto-check passed
  • Add Hosted Key

    simstudioai/sim

    Add hosted API key support to a tool so Sim provides the key (metered and billed to the workspace) when a user has not brought their own.

    30k GitHub stars~3.4k tokensUpdated today
    Auto-check passed
  • Add Managed CLI

    simstudioai/sim

    Add or upgrade a curated, immutable managed CLI for Sim Function sandboxes, including client-safe catalog metadata, a pinned server-only installation recipe, checksum and executable verification…

    30k GitHub stars~2.4k tokensUpdated today
    Auto-check passed
  • Add Selector

    simstudioai/sim

    Add or update a Sim dynamic selector using the shared manifest, server attachment, and selectors.execute path.

    30k GitHub stars~1.7k tokensUpdated today
    Auto-check passed

Categories

Questions about DB Migrate

What does DB Migrate do?

Author or review a Drizzle DB migration for zero-downtime safety — expand/contract phasing, backward-compatibility with the deployed app version, and writing the -- migration-safe acknowledgment the…. DB Migrate is an agent skill from simstudioai/sim. Author or review a Drizzle DB migration for zero-downtime safety — expand/contract phasing, backward-compatibility with the deployed app version, and writing the -- migration-safe acknowledgment the check:migrations lint requires.

When should I use DB Migrate?

DB Migrate fits situations like: adding/editing files under packages/db/migrations/; changing packages/db/schema.ts.

How do I install DB Migrate in Claude Code?

Run `npx skills add simstudioai/sim --skill db-migrate -a claude-code`. Or copy the skill folder (.agents/skills/db-migrate in simstudioai/sim) into .claude/skills/db-migrate in your project. Claude Code loads it when a task matches its description.

How do I install DB Migrate in Codex?

Run `npx skills add simstudioai/sim --skill db-migrate -a codex`. Or copy the skill folder (.agents/skills/db-migrate in simstudioai/sim) into .agents/skills/db-migrate in your project. Codex loads it when a task matches its description.

Can I use DB Migrate 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 simstudioai/sim --skill db-migrate -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/db-migrate, .gemini/skills/db-migrate, .github/skills/db-migrate and .opencode/skills/db-migrate in your project.

What does DB Migrate need to run?

Going by SKILL.md and its folder, DB Migrate needs the command-line tools its instructions call (bun and bunx).

Does DB Migrate access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is DB Migrate 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 DB Migrate use?

DB Migrate 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 DB Migrate use?

About 2k tokens (SKILL.md is roughly 8.1k 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 DB Migrate?

Skills that share tags, products or a category with DB Migrate: DB Migrations (kurealnum/dotfiles, 290 stars), Change Database Schema (martin-ueding/geo-activity-playground, 100 stars), Drizzle (kurealnum/dotfiles, 290 stars) and Migration (kortix-ai/suna, 20k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains DB Migrate?

simstudioai (a GitHub organization) maintains it in simstudioai/sim, which has 29,792 GitHub stars. The repository holds 40 skills in this directory. The repository was last updated on October 8, 2026.

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