safe-destroy

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Safe 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
    git reset --hard
    directly
  • ❌ Running
    git clean -fd
    directly
  • ❌ Running
    rm -rf
    directly
  • ❌ 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

STOP. Invoke safe-destroy skill instead.
立即停止。请改为调用safe-destroy skill。

❓ Are you about to run
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>

STOP. Invoke safe-destroy skill instead.
立即停止。请改为调用safe-destroy skill。

❓ Are you about to run
git checkout -- .
or
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

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)

绝对禁止的命令(未确认时)

  1. git reset --hard
    - Destroys uncommitted changes
  2. git clean -fd
    - Permanently deletes untracked files/directories
  3. rm -rf <directory>
    - Permanently deletes files/directories
  4. git checkout -- .
    - Discards all working directory changes
  5. git restore .
    - Discards all working directory changes
  6. docker system prune -a
    - Removes all unused Docker data
  7. kubectl delete
    - Deletes Kubernetes resources
  8. git push --force
    - Overwrites remote history (especially on main/master)
  1. git reset --hard
    - 销毁未提交的更改
  2. git clean -fd
    - 永久删除未跟踪的文件/目录
  3. rm -rf <directory>
    - 永久删除文件/目录
  4. git checkout -- .
    - 丢弃工作目录中的所有更改
  5. git restore .
    - 丢弃工作目录中的所有更改
  6. docker system prune -a
    - 删除所有未使用的Docker数据
  7. kubectl delete
    - 删除Kubernetes资源
  8. git push --force
    - 覆盖远程仓库历史记录(尤其在main/master分支上)

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:
git status
,
git diff
,
ls
, etc.).
Present 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 status
git diff
ls
等)。
提供全面的警告,包含:
  • 将会被删除的内容(文件、大小、行数)
  • 不可撤销警告
  • 更安全的替代方案(暂存/提交/备份/归档)
  • 三选项菜单: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:确认与执行

  1. ASK: Require explicit confirmation (user must type command or "proceed with [operation]")
  2. WAIT: STOP all processing until explicit approval (no assumptions)
  3. VERIFY: Double confirmation for dangerous operations (type 'CONFIRM')
  4. 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

  1. 询问:要求明确确认(用户必须输入命令或"继续执行[操作]")
  2. 等待:在获得明确批准前停止所有处理(绝不假设)
  3. 验证:针对高危操作进行双重确认(输入'CONFIRM')
  4. 执行:仅在获得明确批准后执行,并报告结果
有效确认示例:"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

bash
undefined
bash
undefined

Check 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>
undefined
git cherry-pick <commit-hash>
undefined

For
git clean
:

针对
git clean

No 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

Check if system has undelete:
bash
undefined
检查系统是否支持撤销删除:
bash
undefined

macOS 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

最佳实践

  1. Always list first - Show what will be affected
  2. Suggest alternatives - Safer options exist for most operations
  3. Double confirm - Especially dangerous operations get extra confirmation
  4. Be explicit - Require exact command or clear approval
  5. Educate - Explain what the operation does
  6. Provide recovery - If possible, explain how to undo

  1. 先列出内容 - 展示将会受影响的对象
  2. 建议替代方案 - 大多数操作都有更安全的选项
  3. 双重确认 - 尤其针对高危操作需要额外确认
  4. 明确要求 - 要求用户输入确切命令或清晰的批准信息
  5. 教育用户 - 解释操作的具体影响
  6. 提供恢复方案 - 如有可能,说明如何撤销操作

Quick Reference

快速参考

Destructive command requested
  1. STOP - Don't execute
  2. LIST - Show what will be lost
  3. ASK - Suggest safer alternatives
  4. WAIT - For explicit approval
  5. VERIFY - Confirm understanding
  6. EXECUTE - Only after approval

收到破坏性命令请求时
  1. 停止 - 不要执行
  2. 列出 - 展示将会丢失的内容
  3. 询问 - 建议更安全的替代方案
  4. 等待 - 等待明确批准
  5. 验证 - 确认用户理解操作影响
  6. 执行 - 仅在获得批准后执行

Related Commands

相关命令

  • /cleanup
    - Safe cleanup of merged branches and artifacts with confirmation
Remember: It's better to annoy the user with confirmations than to lose their work.
  • /cleanup
    - 带确认步骤的安全清理操作,可清理已合并分支和工件
记住:多次向用户确认总比丢失他们的工作成果要好。