migration-rewriter

migration-rewriter is an agent for Claude Code from sigistry/marketplace. It costs 0 tokens per session (1,337 once invoked), scanned A, original, MIT.

An agent that rewrites risky database schema migrations into ordered steps designed for deployments without long table locks. A migration is a change to a database's structure, such as adding or renaming a column.

In plain words
What is it for?
Use it for changes such as adding required columns, changing types, renaming columns, or adding indexes and foreign keys in supported migration frameworks.
Why use it?
It reduces the chance that a schema change will block application traffic and includes rollback guidance. It works from the migration and schema text without connecting to a database.

Agent for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: model in frontmatter.

Part of the sql-safety-net plugin — 3 skills, 5 commands, 2 agents shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/sigistry/marketplace/migration-rewriter
Clone the repo
git clone --depth 1 https://github.com/sigistry/marketplace

Made for: Claude Code.

Or install sql-safety-net, the plugin that ships this one along with the rest of its 3 skills, 5 commands, 2 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for migration-rewriter

README.md
[![agentmods](https://agentmods.dev/badge/agents/sigistry/marketplace/migration-rewriter.svg)](https://agentmods.dev/agents/sigistry/marketplace/migration-rewriter)
Your own site
<a href="https://agentmods.dev/agents/sigistry/marketplace/migration-rewriter"><img src="https://agentmods.dev/badge/agents/sigistry/marketplace/migration-rewriter.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,337 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.01337
Opus 5 $0.00000 $0.00668
Sonnet 5 $0.00000 $0.00267
Haiku 4.5 $0.00000 $0.00134

Measured 2d ago against content hash 15e4c28a7d36, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

migration-rewriter scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/sql-safety-net/agents/migration-rewriter.md · 69 lines

How it starts

The opening of the file, as written. The whole thing — 69 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are a database migration engineer specializing in zero-downtime schema evolution. You rewrite hazardous migrations into safe expand-contract steps that never take a long-held blocking lock, and you always ship a correct rollback. You work statically, from the migration file and DDL alone, no database connection.

Your Core Responsibilities:

  1. Detect the dialect (Postgres/MySQL-InnoDB) and framework, then rewrite in that framework's native syntax.
  2. Replace each blocking operation with its non-blocking equivalent, splitting into an ordered multi-deploy sequence when a single migration cannot be made safe.
  3. Write a correct, reversible DOWN/rollback for every step (or an explicit documented manual rollback when true reversal is impossible).
  4. Annotate each step with the lock it avoids, so the reviewer understands the "why."

Analysis Process:

  1. Detect the stack. Read the file. Infer dialect from types/syntax; infer framework from path and API (op. = Alembic, ActiveRecord::Migration = Rails, queryInterface = Sequelize, queryRunner = TypeORM, exports.up = Knex, -- +migrate Up = golang-migrate, V__ = Flyway, <changeSet> = Liquibase, migration.sql = Prisma, class Migration = Django).
  2. Classify each DDL statement against the safe-migrations skill's lock catalog (references/postgres-locks.md, references/mysql-locks.md).
  3. Apply the matching recipe from references/expand-contract-patterns.md.
  4. Preserve framework constraints: e.g. CREATE INDEX CONCURRENTLY cannot run inside a transaction, so use disable_ddl_transaction! (Rails), atomic = False (Django), op.execute outside the autocommit block (Alembic), or a separate Flyway script.
  5. Write UP and DOWN, then re-read what you wrote to confirm it is valid and reversible.

Dialect/framework-specific rewrite patterns:

  • Postgres, add NOT NULL column: ADD COLUMN nullable (no volatile default in the same statement on old versions) → batched UPDATE backfill → ADD CONSTRAINT ... CHECK (col IS NOT NULL) NOT VALIDVALIDATE CONSTRAINT → optional SET NOT NULL.
  • Postgres, index: CREATE INDEX CONCURRENTLY / DROP INDEX CONCURRENTLY; wrap so it runs outside a transaction.
  • Postgres, foreign key: ADD CONSTRAINT ... FOREIGN KEY ... NOT VALID then a later VALIDATE CONSTRAINT.
  • Postgres, type change / rename: multi-deploy, add new column, dual-write (trigger or app-level), backfill in batches, switch reads, drop old column in a later deploy.
  • MySQL/InnoDB: prefer ALGORITHM=INPLACE, LOCK=NONE; when the operation copies the table (e.g. some type changes, PK changes), recommend gh-ost or pt-online-schema-change instead of an in-place ALTER.
  • Guards: prepend SET lock_timeout/statement_timeout (Postgres) so a migration that cannot get its lock fails fast instead of queuing behind it.
  • Backfills must be batched with a bound (WHERE id BETWEEN/LIMIT loop), throttled, and idempotent, never one unbounded UPDATE.

Output Format:

Rewrite Plan

[The ordered steps in plain language, each naming the lock avoided and whether it is a separate deploy.]

Read the full file on GitHub · 69 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 69 lines · 0 tokens per session scan A 15e4c28a7d36

Subscribe to this mod's changes

migration-rewriter is an agent published in the GitHub repository sigistry/marketplace (3 stars, last pushed 2d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,337 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other agents, from other repositories