migration-check
Skill0 starsChanged 4 months agoMITView on GitHub
Catch dangerous DB schema migrations before they hit the primary DB or any replica — verify single head, reversibility, and no unguarded destructive ops
- Deletes or force-pushes
In this repository29 other files it gives its agents.
- adopt-existing-projectSkill
- adrSkill
- branch-conflict-checkSkill
- ci-watchSkill
- compound-learningsSkill
- config-auditSkill
- cost-checkSkill
- coverage-ratchetSkill
- doc-syncSkill
- eval-harnessSkill
- flaky-triageSkill
- followup-trackingSkill
- incident-captureSkill
- kit-doctorSkill
- kit-updateSkill
- logging-initSkill
- new-project-bootstrapSkill
- nightly-auditSkill
- observability-checkSkill
- parallel-workSkill
- perf-budgetSkill
- pr-babysitterSkill
- pre-prSkill
- prompt-regressionSkill
- releaseSkill
- session-handoffSkill
- sync-healthSkill
- using-the-kitSkill
- writing-kit-skillsSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 17
Run this as part of pre-pr whenever a PR touches */versions/* (Alembic) or any equivalent migration directory.
- Very specific: line 37
If the output is empty, this skill is done — report New migration files: none — done and skip steps 2–6.
- Distinctive: line 86
Add column as NULLABLE — deploy.
- Very specific: line 88
Add NOT NULL constraint in a follow-up migration after backfill completes.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Migration Check
Applies when capabilities.migrations.enabled is true (else skip, report N/A).
Profile-driven. The migration tool command comes from capabilities.migrations.heads_cmd and the file-path glob from capabilities.migrations.versions_glob in .claude/kit.yaml; edit the profile to adapt to Flyway, Prisma, or any other tool.
Run this as part of pre-pr whenever a PR touches */versions/* (Alembic) or
any equivalent migration directory. Its job is to stop a destructive or
un-reversible migration from reaching the primary DB and, for projects that
write-through to a replica, from causing a replica divergence that is painful to
recover from. Catch these locally, not mid-deploy. It reports findings and
mitigations; it does not run alembic merge heads, edit downgrade() bodies,
or apply schema fixes itself — those changes stay the author's to make.
Language-agnostic: the same three invariants apply to any migration tool (Django, Flyway, Liquibase, Prisma Migrate, sqitch): (1) single active head, (2) every migration is reversible, (3) no unguarded destructive ops. Substitute your tool's
heads/statuscommand and grep over the files it generates.
Workflow
1. Identify new migration files in this branch
# path glob: capabilities.migrations.versions_glob
git diff main...HEAD --name-only -- '*/versions/*'If the output is empty, this skill is done — report New migration files: none — done
and skip steps 2–6.
Only continue with steps 2–6 when step 1 found at least one file.
2. Confirm exactly one migration head
# kit.yaml → capabilities.migrations.heads_cmd
uv run alembic headsMore than one head means two branches added migrations independently and neither
created a merge migration. Fix: run alembic merge heads -m "merge_heads" and
commit the result before opening the PR.
3. Confirm every new migration has a down_revision and a non-trivial downgrade()
# List new files
NEW=$(git diff main...HEAD --name-only -- '*/versions/*')
# Flag any file where downgrade() body is only 'pass' (anchored to avoid false positives
# on comments containing "bypass", "password", etc.)
while IFS= read -r f; do
grep -A 5 'def downgrade' "$f" | grep -qE '^[[:space:]]*pass[[:space:]]*$' && echo "TRIVIAL DOWNGRADE: $f"
done <<< "$NEW"A pass-body downgrade() is not a downgrade — it is a trap. If rolling back
is genuinely impossible, that must be an explicit comment with a documented
runbook, not a silent no-op.
4. Flag destructive ops
git diff main...HEAD -- '*/versions/*' | grep -iE \
'(DROP TABLE|DROP COLUMN|RENAME TABLE|RENAME COLUMN|ALTER.*TYPE|ALTER.*USING)'Each hit requires a human decision. The standard mitigations:
| Pattern | Risk | Mitigation |
DROP TABLE | data loss | verify backfill/archive landed in a prior migration, add safety check |
DROP COLUMN | data loss | two-migration strategy: nullify → deploy → drop |
RENAME TABLE/COLUMN | breaks readers | add alias view or migrate readers first |
ALTER COLUMN TYPE (narrowing) | truncation / errors | widen first, backfill, narrow in follow-up |
5. Flag NOT NULL additions without a server_default or backfill
git diff main...HEAD -- '*/versions/*' | grep -iE 'NOT NULL|server_default|nullable=False'Adding a NOT NULL column to a populated table without a server_default fails
on Postgres and SQLite alike. The safe sequence:
- Add column as NULLABLE — deploy.
- Backfill existing rows (in a separate migration or a data script).
- Add
NOT NULLconstraint in a follow-up migration after backfill completes.
6. Flag data migrations on large tables (lock risk)
git diff main...HEAD -- '*/versions/*' | grep -iE \
'op\.execute|connection\.execute|UPDATE|INSERT.*SELECT'Bulk DML in a migration acquires locks for the full duration. Flag any
UPDATE <table> SET ... where the table could be large. Mitigation: batched
updates outside the migration (a background job), or LOCK_TIMEOUT + retry.
Output
## Migration Check
- [ ] New migration files: <list or "none — done">
- [ ] Single head: <rev / MULTIPLE — merge needed>
- [ ] All downgrades non-trivial: <yes / FLAGGED: <files>>
- [ ] Destructive ops: <none / FLAGGED: <ops + files>>
- [ ] NOT NULL safety: <clean / FLAGGED: <columns + files>>
- [ ] Lock-risk DML: <none / FLAGGED: <tables + files>>
Verdict: PASS / BLOCK — <blocking issues with suggested fix>Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

