skills/safety/ai-safety-guardrails/destructive-operation-guard/SKILL.md
CRITICAL SAFETY SKILL - Always active. Use this skill to prevent destructive operations without explicit user confirmation. Activate BEFORE any operation that deletes data, resets state, overwrites files, force pushes, drops tables, truncates data, runs migrations, or performs any irreversible action. This skill MUST be consulted before executing potentially harmful commands.
npx skillsauth add latestaiagents/agent-skills destructive-operation-guardInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
CRITICAL: This skill defines mandatory safety protocols for AI agents.
NEVER execute a destructive operation without EXPLICIT user confirmation.
"Destructive" means any operation that:
DROP TABLE, DROP DATABASETRUNCATE TABLEDELETE without specific WHERE clauseDELETE affecting more than 10 rowsUPDATE without specific WHERE clauseUPDATE affecting more than 10 rows--force flag on database commandsrm -rf on any directoryrm on multiple filesgit push --force or git push -fgit reset --hardgit clean -fdgit checkout . (discards all changes)git stash dropgit branch -D (force delete)git rebase on shared branchesBefore ANY potentially destructive operation, assess:
## Risk Assessment
**Operation:** [What you're about to do]
**Scope:** [What will be affected]
**Reversibility:** [Can this be undone? How?]
**Data at Risk:** [What data could be lost]
**Affected Users:** [Who will be impacted]
ALWAYS show the user:
⚠️ **DESTRUCTIVE OPERATION WARNING**
I'm about to perform an operation that could result in data loss.
**Action:** [Specific command/operation]
**Impact:**
- [Specific impact 1]
- [Specific impact 2]
**Data that will be affected:**
- [Specific data 1]
- [Specific data 2]
**This action is [REVERSIBLE/IRREVERSIBLE].**
[If reversible: "Recovery method: [how to recover]"]
[If irreversible: "⛔ THIS CANNOT BE UNDONE"]
Do you want me to proceed? Please confirm with "yes" or "proceed".
ONLY proceed if user explicitly says:
DO NOT proceed if user says:
# For database operations
pg_dump database_name > backup_$(date +%Y%m%d_%H%M%S).sql
# For file operations
cp -r target_directory target_directory.backup.$(date +%Y%m%d_%H%M%S)
# For git operations
git stash
git branch backup-$(date +%Y%m%d_%H%M%S)
# Log the operation
echo "[$(date)] DESTRUCTIVE OP: [command]" >> ~/.destructive_ops.log
echo "[$(date)] USER CONFIRMED: yes" >> ~/.destructive_ops.log
echo "[$(date)] BACKUP LOCATION: [backup_path]" >> ~/.destructive_ops.log
# Execute
[actual command]
# Log result
echo "[$(date)] RESULT: $?" >> ~/.destructive_ops.log
WRONG:
User: "Run the migration"
AI: [Runs migration immediately]
RIGHT:
User: "Run the migration"
AI: "Before running the migration, I need to check a few things:
1. **Checking migration status...**
- 3 pending migrations found
- Migration `2024_01_15_drop_users_table` will DROP the `legacy_users` table
2. **Checking existing data...**
- `legacy_users` table has 1,247 records
⚠️ **WARNING: This migration will permanently delete 1,247 user records.**
Before proceeding, I recommend:
- [ ] Creating a backup: `pg_dump -t legacy_users db > legacy_users_backup.sql`
- [ ] Verifying these records are not needed
- [ ] Confirming you have a rollback plan
Do you want me to:
A) Create a backup first, then run migration
B) Show me the migration file content first
C) Run migration without backup (NOT RECOMMENDED)
D) Cancel
Please choose an option."
WRONG:
User: "Reset the database"
AI: [Runs db:reset immediately]
RIGHT:
User: "Reset the database"
AI: "I'll help you reset the database. First, let me check the current state:
**Current database:** myapp_development
**Tables:** 47 tables
**Total records:** 15,234 records
**Records by table (top 5):**
- users: 523 records
- orders: 8,921 records
- products: 1,245 records
- logs: 4,102 records
- sessions: 443 records
⚠️ **A database reset will:**
1. Drop ALL tables
2. Delete ALL 15,234 records
3. Recreate schema from migrations
4. Run seeders (if configured)
**Is this a development or production database?**
If development, I can proceed with your confirmation.
If production, I STRONGLY recommend against this operation.
Type 'yes, reset development database' to confirm, or 'cancel' to abort."
WRONG:
User: "Force push to fix the history"
AI: git push --force
RIGHT:
User: "Force push to fix the history"
AI: "Before force pushing, I need to verify this is safe:
**Current branch:** feature/user-auth
**Remote tracking:** origin/feature/user-auth
**Local commits ahead:** 3
**Remote commits that will be OVERWRITTEN:** 2
⚠️ **Force pushing will:**
- Overwrite 2 commits on the remote
- These commits may be lost if not backed up elsewhere
- Other developers pulling this branch will have conflicts
**Safety checks:**
- [ ] Is this a shared branch? (Others may have based work on it)
- [ ] Do you have the overwritten commits backed up?
- [ ] Have you notified team members?
I recommend using `--force-with-lease` instead of `--force`:
```bash
git push --force-with-lease origin feature/user-auth
This will fail if the remote has commits you haven't seen, preventing accidental data loss.
Proceed with:
A) --force-with-lease (safer)
B) --force (I understand the risks)
C) Cancel"
## Recovery Information
Always provide recovery information BEFORE the operation:
```markdown
## Recovery Plan
**If something goes wrong:**
1. **Backup location:** [path]
2. **Restore command:** [command]
3. **Point of no return:** [when recovery becomes impossible]
4. **Who to contact:** [if applicable]
If you encounter these, STOP and ask for clarification:
Production indicators:
NODE_ENV=productionScale indicators:
Ambiguous requests:
Missing context:
development
Test skills for correct activation, content quality, and regression — both automated checks (frontmatter validity, lint) and manual verification (query-suite activation testing). Covers CI integration and how to catch skill regressions before users do. Use this skill when adding skills to a repo, setting up CI for a skill library, or debugging "the skill exists but doesn't work". Activate when: test skills, validate skills, skill CI, skill linting, skill activation test, skill regression.
documentation
Write the YAML frontmatter for a SKILL.md file so it activates reliably — name, description, and activation keywords that the model matches against. Covers length, tone, and the most common frontmatter mistakes. Use this skill when authoring a new skill, fixing a skill that isn't auto-activating, or reviewing skills for publication. Activate when: SKILL.md frontmatter, skill description, skill activation, skill YAML, write a skill, author a skill.
development
Design skills that fire at the right moment — neither over-eager (noise) nor under-eager (silent). Covers activation specificity, trigger phrases, disambiguation between overlapping skills, and debugging activation. Use this skill when multiple skills could fire on the same query, a skill never fires, or a skill fires too often. Activate when: skill won't activate, skill over-activates, overlapping skills, skill triggers, skill selection, skill disambiguation.
development
Structure SKILL.md content so the model reads just enough — concise summary up front, progressively deeper detail, examples on demand. Covers section ordering, length budgets, when to split into multiple skills. Use this skill when writing or refactoring a skill body, one skill has grown too long, or a skill is wordy but not useful. Activate when: SKILL.md structure, skill content, skill too long, split skill, progressive disclosure, skill body.