db-migration-safety

db-migration-safety is a skill for Claude Code, Codex from luqiang-code/claude-code-skills. It costs 39 tokens per session (686 once invoked), scanned A, original, MIT.

A checklist for reviewing database schema changes, which alter the structure of stored data, before they reach production. It covers risks such as table locks, failed conversions, data loss, and slow operations.

In plain words
What is it for?
Use it to review migration files, column additions or removals, indexes, type changes, foreign keys, rollback plans, and backfills on relational databases.
Why use it?
It helps find migration problems before they affect a live database or its existing records. It also checks whether old code still depends on data being removed or changed.

Skill for Claude CodeCodex

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 skills/luqiang-code/claude-code-skills/db-migration-safety
Any agent
npx skills add luqiang-code/claude-code-skills --skill db-migration-safety
Clone the repo
git clone --depth 1 https://github.com/luqiang-code/claude-code-skills

Made for: Claude Code, Codex.

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 db-migration-safety

README.md
[![agentmods](https://agentmods.dev/badge/skills/luqiang-code/claude-code-skills/db-migration-safety.svg)](https://agentmods.dev/skills/luqiang-code/claude-code-skills/db-migration-safety)
Your own site
<a href="https://agentmods.dev/skills/luqiang-code/claude-code-skills/db-migration-safety"><img src="https://agentmods.dev/badge/skills/luqiang-code/claude-code-skills/db-migration-safety.svg" alt="Measured on agentmods" height="20"></a>
Per session 39 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 686 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 $0.00039 $0.00686
Opus 5 $0.00019 $0.00343
Sonnet 5 $0.00008 $0.00137
Haiku 4.5 $0.00004 $0.00069

Measured 4d ago against content hash d381c07a967f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

db-migration-safety 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 4d 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.

community-skills/db-migration-safety/SKILL.md · 91 lines

How it starts

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

Database Migration Safety Review

Review migrations for safety risks before they hit production.

When to Use

  • About to run a migration on a large table
  • Reviewing a PR with migration files
  • User mentions "migration", "schema change", "alter table"

When NOT to Use

  • Writing new migrations (use normal review for that)
  • NoSQL databases (different safety profile)
  • Small dev databases with no data

Workflow

  1. Read the migration file(s)
  2. For each operation, check:

Adding a column

  • Does it have a DEFAULT? (instant in PG11+, slow without)
  • Is it NOT NULL without DEFAULT? (DANGER: will fail on existing rows)
  • Is there a backfill plan for existing rows?

Removing a column

  • Are there any code references still using it? (grep the codebase)
  • Is it part of any indexes or constraints?

Adding an index

  • Is it CREATE INDEX CONCURRENTLY? (non-blocking, preferred)
  • Estimated index size and creation time on table with N rows?

Changing a column type

  • Will it lock the table? (most type changes require ACCESS EXCLUSIVE lock)
  • Is there data that won't convert cleanly?

Adding a foreign key

  • Are both tables on the same database?
  • Is the referenced column indexed?
  1. Check for rollback safety: does the down migration actually revert the up?
  2. Flag any operations that will cause downtime
  3. Output a risk assessment

Output Format

## Migration Safety Review: 0042_add_user_preferences.sql

### Risk: HIGH
- Line 12: ALTER TABLE users ADD COLUMN preferences JSONB NOT NULL
  → Will fail if users table has rows. Add DEFAULT '{}' first.

### Risk: MEDIUM
- Line 8: CREATE INDEX idx_users_email ON users(email)
  → Consider CREATE INDEX CONCURRENTLY to avoid table lock
  → Table has ~500K rows, estimated time: ~3s

### Safe
- Line 3: CREATE TABLE user_preferences — new table, no risk
- Line 15: ALTER TABLE users ADD COLUMN timezone VARCHAR DEFAULT 'UTC' — has DEFAULT, PG11+, instant

### Rollback: PARTIAL
- Down migration removes user_preferences table (destructive, data loss)
  → Consider RENAME instead of DROP for rollback safety

Read the full file on GitHub · 91 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. 4d ago First seen · 91 lines · 39 tokens per session scan A d381c07a967f

Subscribe to this mod's changes

db-migration-safety is a skill published in the GitHub repository luqiang-code/claude-code-skills (2 stars, last pushed 3mo ago), licensed MIT. It adds 39 tokens to every session and 686 once invoked, about $0.0002 per session on Opus 5. 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-31.