migrate-check
Pre-flight safety check for Prisma/SQL migrations. MUST be run before creating or applying any migration in a project whose database is shared Postgres. Opens with a written GO or NO-GO verdict, then classifies every SQL statement additive vs destructive, checks migration-history drift and folder reuse, enforces create-only plus deploy discipline, and identifies the backup path first. Never fixes anything - it blocks and explains.
- License 许可
- MIT
- 最近更新
- 2026-09-28
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- migrate-check
- description
- Pre-flight safety check for Prisma/SQL migrations. MUST be run before creating or applying any migration in a project whose database is shared Postgres. Opens with a written GO or NO-GO verdict, then classifies every SQL statement additive vs destructive, checks migration-history drift and folder reuse, enforces create-only plus deploy discipline, and identifies the backup path first. Never fixes anything - it blocks and explains.
- allowed-tools
- Read, Grep, Glob, Bash(git diff:*), Bash(git log:*), Bash(git status:*), Bash(ls:*), Bash(cat:*), Bash(npx prisma migrate status:*)
- argument-hint
- [prisma/migrations/<folder>]
02 资源文件 2
- 参考文档references/gate-shape.md3.5 KB
- 参考文档references/sql-classification.md3.0 KB
03 SKILL.md 正文
/migrate-check — the gate before the shared database
A teammate's migration once dropped a table from a shared production
database. This skill exists so that never happens again. It is structurally
read-only: the tool whitelist has no Edit, no Write, and no prisma
subcommand that mutates anything. It blocks and explains; it never fixes.
(One residual: git log and git diff accept --output=FILE, which a
prefix grant can't exclude; the skill never uses it — see check.sh §13.)
Adjacent skills: /secure (security review; /migrate-check is DB-change
safety) · /audit code (defects in code; this gates schema changes).
<!-- acstack:runtime --> Run before the skill's steps — per invocation, not per session (4.36); failures degrade to markdown:
link="$(readlink "$HOME/.claude/skills/health" 2>/dev/null || true)" # empty = not symlinked
pack="$(dirname "$(dirname "$link")")" # NEVER trust this unless $link was non-empty
if [ "${link#/}" != "$link" ] && [ -x "$pack/bin/acstack-config" ] && ! "$pack/bin/acstack-config" runtime | grep -q '=off'; then
"$pack/bin/acstack-config" || true # resolved keys, with sources
"$pack/bin/acstack-update-check" || true # ≤1 fetch/day; silent ONLY if already checked today
"$pack/bin/acstack-recall" || true # LEARNINGS.md + bug-class names, capped 3KB
else
echo "runtime off — proceeding without recall/update-check"
fi
<!-- /acstack:runtime -->
<!-- acstack:principles -->
Operating principles
- Be direct. Push back in writing when the plan or the user is wrong. No sycophancy.
- Never delete a decision. Supersede it:
~~old~~ → **Verdict (YYYY-MM-DD):** new call — reason. - Never fix, tune, or delete a test or eval case to raise a score. Log the miss honestly and leave the case unchanged.
- Name exact things: regex patterns, function signatures, model names, before → after numbers. Never "fixed bugs".
- Attribution: follow the project's
attributionsetting (defaultnone) — no AI-tool mentions in generated docs, no attribution trailers in commits or PRs. Commit with explicit-m/-Fmessages only. - Config: read
.claude/acstack.mdat the project root (fall back to~/.claude/acstack.md) before acting.## Settingskeys override pack defaults; a## <skill-name>section overrides both. Unknown keys and sections are ignored. - Docs: BRIEF.md (frozen seed) / PLAN.md (living plan) / JOURNAL.md (rolling journal). If the repo uses legacy names (PLANNING_PROMPT.md / PLANNING.md / STATUS.md), use those instead — never create both.
- Recall: if
LEARNINGS.mdexists at the project root, read it before starting. - Conduct: follow the
acstack-conductblock in this repo's AGENTS.md — the word is the mode; the user sets the pace. - Hackathon lane: if the project's AGENTS.md carries the
acstack:hackathon-laneblock, only/dochanges the repository during the event. Any other skill that would write a tracked file, commit or push says what it would have done and stops; a change that is not a task goes through the lane's operator route. <!-- /acstack:principles -->
Procedure
-
Resolve the safety level from config
db:. Default when unspecified is shared-prod — the conservative assumption.local→ lighter path (step 8).none→ say so in one line and stop.No-database autodetect. When
db:is unset AND the project shows no database signal at all — noprisma/, nomigrations/directory, no*.sql, noalembic.ini/Gemfile, no ORM or driver dependency in a manifest, noDATABASE_URLin.env/.env.example— open with "no database in this project — nothing to pre-flight" and stop there. That is the honest answer up front, rather than reaching it the long way through a failed stack lookup in step 2. The conservative default is unchanged whenever a database MIGHT exist: any one signal present, ordb:set explicitly, means shared-prod strictness as before. Absence of every signal is the only trigger — never a partial match, and never an inference from "I couldn't find the stack." -
Identify the target: the folder or file named in the arguments, else the newest unapplied migration. Resolution is stack-dependent —
npx prisma migrate statusfor Prisma; otherwise the newest unapplied file in the project's migrations directory (Drizzle, Rails, Alembic, Flyway, plain SQL). If the stack cannot be determined or the target cannot be resolved, say exactly that and ask for the target path — never assume Prisma.Honest scope on non-Prisma stacks. Steps 3 (backup path) and 4 (classification) are stack-agnostic and run normally. Steps 5, 6, 7, and 8 name Prisma commands specifically, and the
allowed-toolswhitelist deliberately permits no migration CLI exceptprisma migrate status— running an arbitrary stack's CLI is exactly the mutation risk this skill exists to prevent. So on Drizzle/Alembic/Rails/Flyway/plain SQL, say plainly: "history-drift and command-discipline checks skipped — <stack> CLI is outside this skill's read-only whitelist; verify applied-migration history manually before the GO." A narrowed verdict stated is honest; a full verdict implied from a partial check is not. -
Backup and undo path FIRST. Name the exact backup command (default
pg_dump "$DATABASE_URL" > backups/pre_<timestamp>.sql; config## migrate-checkbackup-commandoverrides) and the restore step. If no undo path can be identified, the verdict is NO-GO — automatically. -
Classify every statement in the migration SQL per
references/sql-classification.md. Output a per-statement table: statement / class / risk / safe alternative where one exists. -
History drift and folder reuse. Compare
migrate statusoutput withprisma/migrations/. Enforce the re-land rule: re-landing a previously dropped migration requires a NEW timestamped folder — a reused folder name already recorded in_prisma_migrationsis silently skipped and the table never created. Flag any drift between recorded history and the folder set. -
Command discipline (shared-prod): author with
npx prisma migrate dev --create-only, apply withnpx prisma migrate deploy. NEVER plainmigrate devand neverdb pushagainst a shared database — both can reset or drift it. -
Sequencing. Migrations are applied manually BEFORE merging code that depends on them: CI/hosting builds run
prisma generate && next build(or equivalent) and never run migrations, so merged code referencing a not-yet-existing column fails at runtime. Confirm the ordering plan. -
db: locallighter path: file backup (cp prisma/dev.db prisma/dev.db.backup_<timestamp>), plainmigrate devacceptable, but statement classification (step 4) still runs — destructive is destructive on any database.
The verdict
The verdict is the report's FIRST line, then the evidence that earned it — a reader who stops after one line must still get the answer. Restate it at the end as a written block, always:
**Verdict: GO**— only when every statement is additive, history is clean, and the backup path is named. Include the exact next commands in order.**Verdict: NO-GO — <reason>**— for any destructive statement without an explicit user-acknowledged plan, missing undo path, folder reuse, or history drift. Include: what to check (expected row counts, expectedmigrate statusoutput), and a symptom → cause → action table for the likely failure modes.
Destructive operations are never a hard stop forever — they are a stop until the user explicitly acknowledges the classification table and the backup is confirmed taken. The skill's job is to make "I didn't realize it would drop that" impossible.
04 同仓库更多 Skills
why
Decision archaeology - answers why the code, config, or plan is the way it is by searching the record in a fixed order: BRIEF constraints, dated PLAN decisions, JOURNAL entries, then git history. Stops at the first real answer, cites it with a date, and says no recorded rationale rather than inventing one. Use when someone asks why something is this way, why a choice was made, or where a decision is written down.
verify
Audit a completion claim made by someone else - another session, agent, or teammate - against the running system rather than the diff. Re-derives what the claim's acceptance demands, runs it, and returns CONFIRMED, OVERSTATED, FALSE or UNVERIFIABLE with the command and its output. Never fixes, never edits the claim or the acceptance. Use when handed a "done", "all green", "merged" or "it works" you did not produce yourself.
triage
Backlog hygiene sweep - stale items, duplicate pairs, missing acceptance criteria, unblocked-but-unassigned work, and milestone burn, delivered as a report first with only user-approved actions applied. Works on GitHub Issues in tickets mode and on PLAN.md checkboxes in document mode. Use when the user asks to triage, groom, or clean up the backlog or the plan's open tasks.
ticket
Capture a brain-dump as a well-formed work item - verb-first title, acceptance criteria, file paths when known, an out-of-scope line. Files a GitHub issue in tickets mode or appends a numbered PLAN.md task in document mode; unknowns are marked TBD, never invented. Use when the user brain-dumps an idea, bug, or task to capture for later, or asks to ticket, file, or note something as work.
ship
Branch-level release with five gates before the act - clean-state, tests, eval-vs-target, docs drift, and attribution sweep; any failing gate stops the release with its output. Then push, and under push: branch-pr open a report-shaped PR wiring the issue-closing reference in tickets mode or PLAN task IDs in document mode. Use when the user asks to ship, release, cut, or open the PR for a feature or branch.
secure
Security review with a confidence gate - a finding exists only with a concrete exploit scenario and a high/medium/low confidence rating; everything else goes to a worth-hardening list, never inflated. Sweeps five surfaces: auth gates, secrets hygiene, injection and unsafe sinks, unsafe deserialization/crypto/transport, and LLM tool-use trust boundaries. Reports only, never fixes. Use when the user asks for a security review or to check vulnerabilities, secrets, or auth.