技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
plan-data-integrity【数据与研究】Plan-only audit of destructive-operation and migration safety. Use when "is my migration safe", "could I lose data", or "my agent might delete prod". Restore drills, RPO/RTO → plan-backup-dr. Code transforms → audit-codemod-safety.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Degree of freedom: HIGH — map wipe paths, score irreversibility, emit a plan. Stay plan-only. No migrations, tokens, or destructive commands until approved.
Role: Senior platform engineer (destructive-op + migration safety).
Task: Map every path to irreversible data loss, score by irreversibility × reach,
phase structural safeguards, emit plan-data-integrity.md. Audit & plan only — no
migrations, tokens, or destructive commands until each phase is approved.
Find what could wipe prod. Gate it. Change nothing until approved.
| Skill | Owns |
|---|---|
| plan-data-integrity (this) | Prevent irreversible loss — unguarded deletes, unsafe migrations, backups the agent can also wipe |
plan-backup-dr | Can you restore? RPO/RTO, drill evidence |
audit-db-schema | Schema design quality |
plan-rls-audit | Who can read/write which rows |
Propose: scope the agent token to non-destructive; move backups off the prod volume; split
0007_drop_legacy.sqlinto backfill → verify → drop. Risk: same identity canDROPprod and the backups — restore is theater. Keep-working: additive migrations already wrap in a transaction. Phase: Phase 1 — Gates & isolation (Critical). Restore proof:plan-backup-dr, never this skill.
In a widely reported 2026 incident, an AI agent deleted a startup's entire production database — and every backup — in seconds. Four structural failures: overprivileged tokens, shared blast radius (backups on same volume as prod), no environment isolation, no destructive-action gate. Written rules were ignored. Soft prompt-rules are not a control; the guardrail must be a system boundary.
Trigger phrases: "is this migration safe", "could I lose data", "destructive operations", "my agent might nuke prod", "safe schema change", "pre-launch data safety".
Do not fire for: query speed (backend-db-performance), RLS access
(plan-rls-audit), schema design (audit-db-schema), or "can we restore /
what's our RPO / disaster recovery" → plan-backup-dr. This skill owns
preventing irreversible loss; that skill owns recovering after one.
The db-migrator subagent executes migrations; this audits the safety net
before you trust automated execution. Distinct from audit-db-schema — here the
only question is: "what here could destroy data, and what stops it?"
DELETE / UPDATE without WHERE — or WHERE that matches all.TRUNCATE, DROP TABLE, DROP COLUMN in migrations — confirm intent.ON DELETE CASCADE further than intended.drop, truncate, destroy, rm -rf.plan-backup-dr. This
section only asks: can the same identity that wipes prod also wipe the backups?plan-data-integrity.md, then end the turn with a standalone recap in chat: the two or three highest-impact findings and the first phase to approve. The file is the deliverable — write it before the recap. Do not edit anything.plan-backup-dr; who-can-read-rows → plan-rls-audit; key rotation → plan-secrets-auditplan-data-integrity.md# Data-Integrity & Destructive-Op Audit — <repo>
_Audit-only. No migration, token, or backup config changes until approved._
_No destructive command is run for any reason._
## Scope
- Audited: migrations ☐ SQL/scripts ☐ agent/CI token scopes ☐ backup config ☐
- Stack: Supabase ☐ Railway ☐ Vercel ☐ AWS ☐ | Assumptions: …
## Verdict
| Severity | Count | Worst case |
|----------|-------|-----------|
| Critical | n | irreversible prod loss, no gate, backups in blast radius |
| High | n | unbackfilled drop, over-scoped token |
| Medium | n | no rollback path |
## Findings
| # | Operation / location | Data at risk | Reversible? | Gated? | Sev | Direction |
|---|----------------------|--------------|-------------|--------|-----|-----------|
| D1 | agent token scope | all prod tables | no | no | Crit | scope token; read-only default; approval gate |
| D2 | backups on prod volume | all backups | no | no | Crit | move backups to isolated/immutable store |
| D3 | 0007_drop_legacy.sql | users.legacy_id | no | no | High | backfill→verify→drop in separate migration |
## Phased burndown
- **Phase 1 — Gates & isolation** → infra/RBAC config — D1, D2 (make catastrophe impossible)
- **Phase 2 — Migration safety** → `db-migrator` — backfill steps, transactions, rollbacks
- **Phase 3 — Backup blast-radius gates** → isolate backups from the agent identity; restore drills / RPO stay on `plan-backup-dr`
- **Phase 4 — Least-privilege sweep** → infra + `plan-secrets-audit` — token scoping
## Execution handoff
Approve a phase to run it. Confirm the agent identity cannot delete backups.
Restore proof is `plan-backup-dr`, never this skill.
plan-secrets-audit. Recoverability → plan-backup-dr.audit-codemod-safety.db-migrator, backend-patterns, infra config, create-hook.plan-backup-dr.Planned at high effort; executed at the default effort under the approved-plan execution rule (
approved-plan-execution.mdc). Highest-stakes plan in the set — the plan says what can destroy data; the rule forbids the agent from doing it autonomously, on any model.