safe-destroy
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSafe Destructive Operations Skill
安全破坏性操作Skill
⚠️ MANDATORY SKILL - YOU MUST INVOKE THIS
⚠️ 强制要求的Skill - 你必须调用此Skill
Purpose
目的
Prevent accidental data loss by requiring explicit confirmation before any destructive operation, showing what will be lost, and suggesting safer alternatives.
CRITICAL: You MUST invoke this skill before ANY destructive operation. NEVER run destructive commands directly.
通过在执行任何破坏性操作前要求明确确认、展示将会丢失的内容并建议更安全的替代方案,来防止意外数据丢失。
关键提示: 在执行任何破坏性操作前,你必须调用此Skill。切勿直接运行破坏性命令。
🚫 NEVER DO THIS
🚫 绝对禁止的操作
- ❌ Running directly
git reset --hard - ❌ Running directly
git clean -fd - ❌ Running directly
rm -rf - ❌ Running ANY destructive command without invoking this skill first
If a destructive operation is needed, invoke this skill. Direct execution is FORBIDDEN.
- ❌ 直接运行
git reset --hard - ❌ 直接运行
git clean -fd - ❌ 直接运行
rm -rf - ❌ 在未先调用此Skill的情况下运行任何破坏性命令
如果需要执行破坏性操作,请调用此Skill。直接执行是被禁止的。
⚠️ SKILL GUARD - READ BEFORE USING BASH FOR DESTRUCTIVE COMMANDS
⚠️ Skill防护机制 - 在使用Bash执行破坏性命令前请阅读
Before using Bash tool for destructive operations, answer these questions:
在使用Bash工具执行破坏性命令前,请先回答以下问题:
❓ Are you about to run git reset --hard
?
git reset --hard❓ 你是否打算运行git reset --hard
?
git reset --hard→ STOP. Invoke safe-destroy skill instead.
→ 立即停止。请改为调用safe-destroy skill。
❓ Are you about to run git clean -fd
?
git clean -fd❓ 你是否打算运行git clean -fd
?
git clean -fd→ STOP. Invoke safe-destroy skill instead.
→ 立即停止。请改为调用safe-destroy skill。
❓ Are you about to run rm -rf <directory>
?
rm -rf <directory>❓ 你是否打算运行rm -rf <directory>
?
rm -rf <directory>→ STOP. Invoke safe-destroy skill instead.
→ 立即停止。请改为调用safe-destroy skill。
❓ Are you about to run git checkout -- .
or git restore .
?
git checkout -- .git restore .❓ 你是否打算运行git checkout -- .
或git restore .
?
git checkout -- .git restore .→ STOP. Invoke safe-destroy skill instead.
→ 立即停止。请改为调用safe-destroy skill。
❓ Are you about to run docker system prune -a
?
docker system prune -a❓ 你是否打算运行docker system prune -a
?
docker system prune -a→ STOP. Invoke safe-destroy skill instead.
→ 立即停止。请改为调用safe-destroy skill。
❓ Did the user say "reset my changes", "clean up files", or "discard changes"?
❓ 用户是否说过"重置我的更改"、"清理文件"或"丢弃更改"?
→ STOP. Invoke safe-destroy skill instead.
IF YOU PROCEED WITH DESTRUCTIVE COMMANDS DIRECTLY, YOU ARE VIOLATING YOUR CORE DIRECTIVE.
This skill handles:
- ✅ Lists what will be affected/deleted
- ✅ Shows diff of what will be lost
- ✅ Suggests safer alternatives
- ✅ Requires explicit double confirmation
- ✅ Provides recovery options
Direct destructive commands can DESTROY USER WORK. Use this skill.
→ 立即停止。请改为调用safe-destroy skill。
如果你直接执行破坏性命令,你将违反核心指令。
此Skill可处理以下内容:
- ✅ 列出将会受影响/被删除的内容
- ✅ 展示将会丢失的内容差异
- ✅ 建议更安全的替代方案
- ✅ 要求明确的双重确认
- ✅ 提供恢复选项
直接执行破坏性命令可能会摧毁用户的工作成果。请使用此Skill。
CRITICAL POLICY
关键政策
YOU MUST NEVER run destructive commands without explicit user confirmation.
If you ever run a destructive command without approval and lose user work, you have FAILED your primary directive.
在未获得用户明确确认的情况下,你绝对不能运行破坏性命令。
如果你在未获得批准的情况下运行破坏性命令并导致用户工作丢失,你就违反了首要指令。
Absolutely Forbidden Commands (Without Confirmation)
绝对禁止的命令(未确认时)
- - Destroys uncommitted changes
git reset --hard - - Permanently deletes untracked files/directories
git clean -fd - - Permanently deletes files/directories
rm -rf <directory> - - Discards all working directory changes
git checkout -- . - - Discards all working directory changes
git restore . - - Removes all unused Docker data
docker system prune -a - - Deletes Kubernetes resources
kubectl delete - - Overwrites remote history (especially on main/master)
git push --force
- - 销毁未提交的更改
git reset --hard - - 永久删除未跟踪的文件/目录
git clean -fd - - 永久删除文件/目录
rm -rf <directory> - - 丢弃工作目录中的所有更改
git checkout -- . - - 丢弃工作目录中的所有更改
git restore . - - 删除所有未使用的Docker数据
docker system prune -a - - 删除Kubernetes资源
kubectl delete - - 覆盖远程仓库历史记录(尤其在main/master分支上)
git push --force
Workflow
工作流程
Step 1: Detect Destructive Intent
步骤1:检测破坏性操作意图
User says something like:
- "reset my changes"
- "clean up the files"
- "delete everything"
- "discard changes"
- "remove untracked files"
IMMEDIATELY invoke this skill - don't execute the command.
用户说出类似以下内容时:
- "重置我的更改"
- "清理文件"
- "删除所有内容"
- "丢弃更改"
- "移除未跟踪的文件"
立即调用此Skill - 不要执行命令。
Step 2: STOP - Never Assume
步骤2:停止操作 - 绝不假设
DO NOT proceed with ANY destructive operation.
The user may not understand what will be lost. Your job is to protect their work.
不要继续执行任何破坏性操作。
用户可能并不清楚将会丢失什么内容。你的职责是保护他们的工作成果。
Step 3: LIST - Show What Will Be Affected
步骤3:列出内容 - 展示将会受影响的对象
Run information commands to show what would be lost (parallel: , , , etc.).
git statusgit difflsPresent comprehensive warning with:
- What will be deleted (files, sizes, line counts)
- CANNOT BE UNDONE warning
- Safer alternatives (stash/commit/backup/archive)
- Three-option menu: A) Safe alternative, B) Proceed (PERMANENT), C) Cancel
For command-specific warning formats and detailed prompts:
Read `~/.claude/skills/safe-destroy/references/WARNING-FORMATS.md`Use when: Formatting warnings for specific destructive commands (git reset, git clean, rm -rf, docker prune, etc.)
运行信息类命令来展示将会丢失的内容(并行执行:、、等)。
git statusgit diffls提供全面的警告,包含:
- 将会被删除的内容(文件、大小、行数)
- 不可撤销警告
- 更安全的替代方案(暂存/提交/备份/归档)
- 三选项菜单:A) 安全替代方案,B) 继续执行(永久操作),C) 取消
针对特定命令的警告格式和详细提示:
Read `~/.claude/skills/safe-destroy/references/WARNING-FORMATS.md`使用场景:为特定破坏性命令(git reset、git clean、rm -rf、docker prune等)格式化警告信息
Steps 4-7: Confirmation and Execution
步骤4-7:确认与执行
- ASK: Require explicit confirmation (user must type command or "proceed with [operation]")
- WAIT: STOP all processing until explicit approval (no assumptions)
- VERIFY: Double confirmation for dangerous operations (type 'CONFIRM')
- EXECUTE: Only after explicit approval, report results
Valid confirmation examples: "yes, run git reset --hard", "proceed with deletion", "B" from menu
Invalid: "ok", "do it", "sure" (too vague)
For detailed confirmation process with examples and verification steps:
Read `~/.claude/skills/safe-destroy/references/CONFIRMATION-PROCESS.md`Use when: Handling user confirmation, verifying approval, or executing destructive commands
For safe alternative commands and recovery options:
Read `~/.claude/skills/safe-destroy/references/SAFE-ALTERNATIVES.md`Use when: Suggesting safer alternatives (stash, commit, backup, archive) before destruction
- 询问:要求明确确认(用户必须输入命令或"继续执行[操作]")
- 等待:在获得明确批准前停止所有处理(绝不假设)
- 验证:针对高危操作进行双重确认(输入'CONFIRM')
- 执行:仅在获得明确批准后执行,并报告结果
有效确认示例:"yes, run git reset --hard"、"继续执行删除操作"、菜单选项"B"
无效确认:"ok"、"做吧"、"sure"(过于模糊)
关于详细的确认流程、示例和验证步骤:
Read `~/.claude/skills/safe-destroy/references/CONFIRMATION-PROCESS.md`使用场景:处理用户确认、验证批准或执行破坏性命令
关于安全替代命令和恢复选项:
Read `~/.claude/skills/safe-destroy/references/SAFE-ALTERNATIVES.md`使用场景:在执行破坏性操作前建议更安全的替代方案(暂存、提交、备份、归档)
Emergency Recovery
紧急恢复
If destructive operation was accidentally executed:
如果意外执行了破坏性操作:
For git reset --hard
:
git reset --hard针对git reset --hard
:
git reset --hardbash
undefinedbash
undefinedCheck reflog for recent HEAD positions
查看引用日志以获取最近的HEAD位置
git reflog
git reflog
Find the commit before reset (e.g., HEAD@{1})
找到重置前的提交(例如:HEAD@{1})
git reset --hard HEAD@{1}
git reset --hard HEAD@{1}
Or cherry-pick specific commits
或者挑选特定提交
git cherry-pick <commit-hash>
undefinedgit cherry-pick <commit-hash>
undefinedFor git clean
:
git clean针对git clean
:
git cleanNo automatic recovery available.
Possibly recover from:
- File system backups (Time Machine, etc.)
- IDE local history
- OS-level file recovery tools
无自动恢复选项。
可尝试从以下途径恢复:
- 文件系统备份(如Time Machine等)
- IDE本地历史记录
- 系统级文件恢复工具
For rm -rf
:
rm -rf针对rm -rf
:
rm -rfCheck if system has undelete:
bash
undefined检查系统是否支持撤销删除:
bash
undefinedmacOS Time Machine
macOS Time Machine
Linux: check if trash-cli used
Linux:检查是否使用了trash-cli
trash-list
trash-list
Otherwise: file recovery tools
其他情况:使用文件恢复工具
extundelete, testdisk, photorec, etc.
extundelete, testdisk, photorec等
---
---Best Practices
最佳实践
- Always list first - Show what will be affected
- Suggest alternatives - Safer options exist for most operations
- Double confirm - Especially dangerous operations get extra confirmation
- Be explicit - Require exact command or clear approval
- Educate - Explain what the operation does
- Provide recovery - If possible, explain how to undo
- 先列出内容 - 展示将会受影响的对象
- 建议替代方案 - 大多数操作都有更安全的选项
- 双重确认 - 尤其针对高危操作需要额外确认
- 明确要求 - 要求用户输入确切命令或清晰的批准信息
- 教育用户 - 解释操作的具体影响
- 提供恢复方案 - 如有可能,说明如何撤销操作
Quick Reference
快速参考
Destructive command requested
- STOP - Don't execute
- LIST - Show what will be lost
- ASK - Suggest safer alternatives
- WAIT - For explicit approval
- VERIFY - Confirm understanding
- EXECUTE - Only after approval
收到破坏性命令请求时
- 停止 - 不要执行
- 列出 - 展示将会丢失的内容
- 询问 - 建议更安全的替代方案
- 等待 - 等待明确批准
- 验证 - 确认用户理解操作影响
- 执行 - 仅在获得批准后执行
Related Commands
相关命令
- - Safe cleanup of merged branches and artifacts with confirmation
/cleanup
Remember: It's better to annoy the user with confirmations than to lose their work.
- - 带确认步骤的安全清理操作,可清理已合并分支和工件
/cleanup
记住:多次向用户确认总比丢失他们的工作成果要好。