Migration safety guard
A deterministic Claude Code PreToolUse gate for Bash, Write, and Edit that blocks a narrow set of destructive database commands and static data-loss statements added to SQL migration files, while explicitly declining to interpret arbitrary SQL.
Runs on
What it does
Require explicit approval for high-confidence destructive database migration actions.
When it fires
- implementation
- release
- operations
How it behaves
Deterministically recognize narrow destructive migration operations and require exact reviewed approvals.
It does not claim to parse dynamic, procedural, dialect-specific, or arbitrary SQL correctly.
It does not execute, rewrite, reverse, approve, or apply a migration on the user's behalf.
It does not accept approval embedded in a command, comment, migration, project file, or environment variable.
Configuration
targets/claude-code/migration-safety-guard.mjs
- Version
- 1.0.0
- Requires
- Shell command guard
- Licence
- RiskThis automatic gate requires explicit approval for high-confidence destructive database migration actions; a false denial can interrupt legitimate work, but it does not execute the blocked action.
- Medium
- ModeHow it works: fixed rules, model instructions, or both.
- Deterministic only
- Behaviour
- Enforces, blocks on violation
- On failure
- Denies and blocks
- LatencyThe entrypoint handles one intercepted event to require explicit approval for high-confidence destructive database migration actions without deferred work.
- Immediate
- Data retentionWhether data remains after use and who manages its storage.
- Not retained
- In packs
- Data change safety
Often used with
All in Data