跳到正文
Skillpedia
安全280k · #397

safety-guard

它能做什么

这个智能体就像你操作过程中的保镖。它能阻止危险命令被意外执行,还能把修改范围限制在项目的某个特定区域。

适用场景

  • ✓在处理重要的(生产环境)系统时。
  • ✓想让 AI 只在受限区域内独立工作时。
  • ✓进行重要更新或数据变更期间。

技能链接

https://github.com/affaan-m/ECC/blob/main/skills/safety-guard/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/affaan-m/ECC/blob/main/skills/safety-guard/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“保护我的项目,阻止危险命令,并把修改限制在 'src/components/' 文件夹内。”

每周 5 个新技能,1 分钟读完。

工作原理

它的原理是检查 AI 即将执行的命令。如果某条命令被认为有危险(比如删除所有内容),或者 AI 试图修改允许范围之外的内容,它就会停下来,请你确认。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Safety Guard — Prevent Destructive Operations

When to Use

  • When working on production systems
  • When agents are running autonomously (full-auto mode)
  • When you want to restrict edits to a specific directory
  • During sensitive operations (migrations, deploys, data changes)

How It Works

Three modes of protection:

Mode 1: Careful Mode

Intercepts destructive commands before execution and warns:

Watched patterns:
- rm -rf (especially /, ~, or project root)
- git push --force
- git reset --hard
- git checkout . (discard all changes)
- DROP TABLE / DROP DATABASE
- docker system prune
- kubectl delete
- chmod 777
- sudo rm
- npm publish (accidental publishes)
- Any command with --no-verify

When detected: shows what the command does, asks for confirmation, suggests safer alternative.

Mode 2: Freeze Mode

Locks file edits to a specific directory tree:

/safety-guard freeze src/components/

Any Write/Edit outside src/components/ is blocked with an explanation. Useful when you want an agent to focus on one area without touching unrelated code.

Mode 3: Guard Mode (Careful + Freeze combined)

Both protections active. Maximum safety for autonomous agents.

/safety-guard guard --dir src/api/ --allow-read-all

Agents can read anything but only write to src/api/. Destructive commands are blocked everywhere.

Unlock

/safety-guard off

Implementation

Uses PreToolUse hooks to intercept Bash, Write, Edit, and MultiEdit tool calls. Checks the command/path against the active rules before allowing execution.

Integration

  • Enable by default for codex -a never sessions
  • Pair with observability risk scoring in ECC 2.0
  • Logs all blocked actions to ~/.claude/safety-guard.log
常见问题

它会拦截哪些危险命令?

它会拦截诸如“删除所有内容”(rm -rf)、版本控制系统中的强制推送(git push --force),以及删除数据库表(DROP TABLE)之类的命令。

我怎样让它停止保护?

输入 '/safety-guard off' 即可关闭保护。

能不能让 AI 可以读取所有内容,但只能在一个地方写入?

可以,“守护模式”(Guard Mode)就支持这种设置。你可以指定一个 AI 可以写入的文件夹,它就无法修改项目的其他部分。

详情

作者的原始描述

Guard against destructive operations with three modes: Careful intercepts dangerous commands (rm -rf, git push --force, DROP TABLE) for confirmation, Freeze locks writes to one directory, and Guard combines both via PreToolUse hooks. Use when working on production systems, running agents autonomously, restricting edits to a directory, or during migrations, deploys, and data changes.

repo: affaan-m/ECC

热度

GitHub 星标
280k
排名
#397
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能