/model-citizen:migration-safetyfrom Model Citizen
Writes, reviews, and applies database schema migrations without destroying data. Covers safe patterns for adding, renaming, and changing columns, plus destructive-operation safeguards.
Ships in Model Citizen. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Staging and demo environments hold real data more often than anyone admits, and a migration that destroys data in staging demonstrates that the same operation would run in production. There is no "it's just staging" exception. Never write a migration that could silently destroy existing data.
Do not generate these autonomously. Describe what you intend and why, and wait for confirmation before writing the file:
DROP TABLE, DROP COLUMN, TRUNCATE — destroys rows or values permanently.ALTER COLUMN … TYPE with a lossy cast — the database rewrites the column; values that
cannot be cast are lost.NOT NULL and then dropping the column — same as above.DELETE FROM inside a migration — data loss with no recovery short of a backup.Adding a column. Add it nullable first, even if the final intent is NOT NULL. Backfill in
a separate migration or deploy step. Add the constraint only after the backfill is confirmed.
Three small migrations beat one that rewrites data and adds a constraint at once.
Renaming a column. Never rename in a single deploy. Expand-contract: add the new column nullable; write to both; backfill new from old; switch reads; drop the old column in a later release once confirmed safe.
Changing a type. Lossless (VARCHAR → TEXT) may proceed with a note in the migration
comment. Lossy (TEXT → INTEGER, shrinking a VARCHAR) stops and asks.
Removing a column. Only after confirming no deployed code reads or writes it, and a backup exists or the column is confirmed empty. In the migration direction that removes it, archive and verify row counts and retained values while the column still exists, before the drop. A downgrade cannot archive a column an earlier upgrade already removed:
CREATE SCHEMA IF NOT EXISTS archive;
CREATE TABLE IF NOT EXISTS archive.<table>_<revision>_before_drop AS
SELECT id, <dropped_column> FROM <table>;
The archive is retained indefinitely; nobody drops it without explicit sign-off.
Additive first. Adding a column or table is always safer than modifying one. If the goal can be reached by adding, add.
upgrade() contains no DROP TABLE, DROP COLUMN, TRUNCATE or DELETE FROM without
explicit human sign-off recorded in the PR.NOT NULL column either has a server default or is added nullable with a separate
backfill.downgrade() is implemented, or is an explicit no-op with a comment saying why rollback is
impossible for this change.Once a migration has been applied to any shared environment, it is immutable. Create a new migration to correct mistakes.
If iterating on one logical change produced several files, collapse them into one before opening the PR — delete and regenerate, which is safe while nothing has been applied to a shared environment. This is different from the deliberate add-nullable → backfill → constrain sequence, which stays as separate migrations by design.
Long-lived branches frequently produce two divergent heads even without a content conflict.
Check immediately after merging (alembic heads, or the equivalent for the tool) and reconcile
with a no-op merge revision before running tests or committing.
What SKILL.md sets; muted values are Claude Code's defaults
15 skills in this plugin
/api-verificationProve a search, filter or API answer is real before relying on it, and budget web search across a fan-out. Use when querying an unfamiliar API, a filter returns suspiciously clean results, a per-item error may have been swallowed, or briefing research agents./architecture-viewerOpen or update an architecture diagram with the selected builtin or custom viewer, preserving a neutral session handoff. Use when asked to inspect architecture interactively or continue an existing diagram session./code-quality-instrumentsMeasure whether a test suite is any good, not only that it passes — branch coverage, mutation score, complexity-times-coverage risk, duplication. Use when adding or reviewing tests on a change that matters, a suite passes but a bug still shipped, coverage is high and confidence is not, or before promising a module is well tested.npx claudepluginhub jakeselby/model-citizen --plugin model-citizenOther plugins' skills for the same job