Guide
What you get: Before a migration runs, the subagent reports long locks, data loss, compatibility with deployed code, missing indexes and rollback steps, and ends with GO / NO-GO, without editing files or running migrations. Best for Teams running schema migrations against large production tables..
Before you start
- Claude Code: save as .claude/agents/migration-checker.md
- Fill migrations_path and database (we used db/migrations and PostgreSQL 16)
- Codex: save as .codex/agents/migration-checker.toml (name, description, developer_instructions); in our run Codex didn't load it as an agent role
Worked example (Nov 14, 2026, Claude Code 2.1.318 (claude-opus-5-5); Codex 0.151.0 (gpt-5.6-sol))
Input
crumb-orders: a 40M-row orders table; new untracked migration 0007 adds fulfillment_status NOT NULL DEFAULT 'pending', changes total_cents to bigint, adds a non-concurrent index, creates order_events without an index on order_id, copies notes and drops legacy_notes (still read by src/orders.js), and adds a validated FK. Prompt: 'Use the migration-checker subagent to review the new migration in db/migrations before we deploy it tonight.'
Result
Claude Code (subagent): "Verdict: NO-GO for tonight." Critical: DROP COLUMN legacy_notes breaks src/orders.js:6; int to bigint rewrites 40M rows under ACCESS EXCLUSIVE. Then non-concurrent index, FK without NOT VALID, missing order_events(order_id) index, exact rollback SQL. Codex: "NO-GO for tonight" with the same blockers.
Claude Code delegated to the migration-checker subagent, which used only Glob, Grep and Read; file hashes were identical before and after both runs and nothing was executed against a database. It found all six planted problems, correctly said the constant-DEFAULT column is not a rewrite on PG 11+, and gave exact rollback statements. Codex found the same blockers but FAILED as an agent test: spawn_agent was called without an agent type and the child had agent_role=null, so the .codex/agents file was not used as a role (the child only saw its text because the parent printed the file before forking); it also gave no exact rollback steps, only 'a verified backup/PITR recovery path is required'. After this test the lock list was corrected (a constant DEFAULT isn't a table rewrite on PostgreSQL 11+) and rollback steps must be SQL.
How to check it worked
- Plant a known-bad statement (DROP COLUMN still used by code) and check it's flagged
- Check git status / file hashes: the agent must not edit anything
- Check the report ends with GO or NO-GO and lists rollback statements
Common problems
- Template item 1 calls 'adding NOT NULL with defaults' a long lock; on PostgreSQL 11+ a constant default is metadata-only
- Codex may not load project agent TOML files as roles; check its session for agent_role
Log in to join the discussion.