migration-agent

migration-agent is an agent for Claude Code from ThibautBaissac/rails_ai_agents. It costs 0 tokens per session (941 once invoked), scanned A, original, MIT.

A Rails database-migration agent for changing the database structure safely. A migration is a versioned code file that adds or changes tables, columns, indexes, and constraints.

In plain words
What is it for?
Adding or changing tables and columns, creating indexes and constraints, and planning production-safe, reversible PostgreSQL schema updates.
Why use it?
It reduces the risk of locked tables, lost data, one-way changes, and deployment failures when the schema changes. It also keeps migrations reversible where possible.

Agent for Claude Code

Written for Claude Code: effort in frontmatter. Also seen: model in frontmatter.

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/thibautbaissac/rails_ai_agents/migration-agent
Clone the repo
git clone --depth 1 https://github.com/ThibautBaissac/rails_ai_agents

Made for: Claude Code.

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-agent

README.md
[![agentmods](https://agentmods.dev/badge/agents/thibautbaissac/rails_ai_agents/migration-agent.svg)](https://agentmods.dev/agents/thibautbaissac/rails_ai_agents/migration-agent)
Your own site
<a href="https://agentmods.dev/agents/thibautbaissac/rails_ai_agents/migration-agent"><img src="https://agentmods.dev/badge/agents/thibautbaissac/rails_ai_agents/migration-agent.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 941 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.00941
Opus 5 $0.00000 $0.00470
Sonnet 5 $0.00000 $0.00188
Haiku 4.5 $0.00000 $0.00094

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

Security

Grade A, and why

migration-agent 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 7d 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.

.claude/agents/migration-agent.md · 101 lines

How it starts

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

You are an expert in ActiveRecord migrations, PostgreSQL, and schema best practices. Your mission: create safe, reversible, production-optimized migrations. You NEVER modify a migration that has already been executed.

Migration Commands

bin/rails generate migration AddColumnToTable column:type
bin/rails db:migrate   &&   bin/rails db:rollback STEP=N

Rails 8 Features

create_virtual (generated columns), add_check_constraint, deferrable: :deferred (FK).

Reversible Migrations

# Automatically reversible -- prefer `change` when possible
class AddEmailToUsers < ActiveRecord::Migration[8.1]
  def change
    add_column :users, :email, :string, null: false
    add_index :users, :email, unique: true
  end
end

# Use up/down when `change` cannot infer the reverse
class ChangeColumnType < ActiveRecord::Migration[8.1]
  def up   = change_column :items, :price, :decimal, precision: 10, scale: 2
  def down = change_column :items, :price, :integer
end

Production-Safe Migrations

Concurrent indexes -- avoids table lock:

class AddEmailIndexToUsers < ActiveRecord::Migration[8.1]
  disable_ddl_transaction!
  def change = add_index :users, :email, algorithm: :concurrently
end

Column with default on large table -- three migrations:

add_column :users, :active, :boolean              # 1. Nullable column
User.in_batches.update_all(active: true)          # 2. Backfill in a job
change_column_null :users, :active, false         # 3. NOT NULL + default
change_column_default :users, :active, true

Column removal -- two deploys:

self.ignored_columns += ["old_column"]            # Deploy 1: ignore in model
safety_assured { remove_column :users, :old_column, :string }  # Deploy 2: drop
t.string  :name                                # varchar(255)
t.text    :description                         # unlimited text
t.citext  :email                               # case-insensitive (extension)
t.integer :count                               # integer
t.bigint  :external_id                         # bigint (external IDs)
t.decimal :price, precision: 10, scale: 2      # exact decimal
t.datetime :published_at                       # timestamp with tz
t.timestamps                                   # created_at + updated_at
t.boolean :active, null: false, default: false
t.jsonb   :metadata                            # binary JSON (indexable)
t.uuid    :token, default: "gen_random_uuid()"
t.integer :status, null: false, default: 0     # Rails enum backing

Read the full file on GitHub · 101 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. 7d ago First seen · 101 lines · 0 tokens per session scan A 53cf84548d71

Subscribe to this mod's changes

migration-agent is an agent published in the GitHub repository ThibautBaissac/rails_ai_agents (659 stars, last pushed 3mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 941 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-08-30.

Related

Other agents, from other repositories

MS-SQL Database Administrator

Work with Microsoft SQL Server databases using the MS SQL extension.

github/awesome-copilot · 18 tokens

core-data-auditor

Use this agent when the user mentions Core Data review, schema migration, production crashes, or data safety checking. Automatically scans Core Data code for the 5 most critical safety violations - schema migration risks, thread-confinement errors, N+1 query patterns, production data loss risks, and performance issues…

CharlesWiltgen/Axiom · 261 tokens

lens

Turns raw data into actionable decisions — dashboards, metric definitions, SQL analytics, funnel and cohort analysis across BI platforms. Use when designing a dashboard, defining KPIs, or running funnel analysis. Trigger with "design a dashboard", "analyze our funnel".

jeremylongshore/tons-of-skills-marketplace · 53 tokens

ecto-schema-designer

Ecto schema architect - designs migrations, data models, and query patterns. Use proactively when planning database structure for new features.

oliver-kriska/claude-elixir-phoenix · 30 tokens

django-migrations-specialist

Database specialist for Django, runs in the "database" extra phase after development. Finalizes model field types and Meta indexes/constraints, runs makemigrations, reviews generated SQL with sqlmigrate, runs migrate, verifies with migrate --check. Do NOT use for: application logic (django-architect), tests…

AratKruglik/claude-sdlc · 85 tokens

sql-expert

Usa este agente para cualquier tarea relacionada con base de datos en FacturaScripts: diseñar esquemas de tabla XML, optimizar consultas con DbQuery y Where, crear índices y constraints, escribir migraciones SQL, analizar rendimiento de queries, usar transacciones, trabajar con DataBaseWhere/DataBase/DbQuery, diseñar…

FacturaScripts/fs-claude-plugin · 102 tokens