safety-guard
Protects against destructive operations on systems. It can confirm dangerous commands or restrict edits to a directory.
What it does
This AI agent acts like a bodyguard for your operations. It stops dangerous commands from running accidentally and can limit changes to a specific area of your project.
When to use it
- ✓When working on important (production) systems.
- ✓When you want the AI to work alone in a restricted area.
- ✓During important updates or data changes.
Example of what to ask your AI
“Protect my project from dangerous commands and restrict edits to the 'src/components/' folder.”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
It works by checking the commands the AI is about to run. If a command is considered dangerous (like deleting everything) or if the AI tries to edit something outside the allowed area, it will stop and ask for your confirmation.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add affaan-m/ECC --skill safety-guardOr download just the file:
curl -L https://raw.githubusercontent.com/affaan-m/ECC/main/skills/safety-guard/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from 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 neversessions - Pair with observability risk scoring in ECC 2.0
- Logs all blocked actions to
~/.claude/safety-guard.log
FAQ
What kinds of dangerous commands does it block?
It blocks commands like 'delete everything' (rm -rf), forcing pushes in version control systems (git push --force), and dropping database tables (DROP TABLE).
How do I make it stop protecting?
You can turn off the protection by typing '/safety-guard off'.
Can I let the AI read everything but only write in one place?
Yes, 'Guard Mode' allows this. You can specify a folder where the AI can write, but it won't be able to modify other parts of your project.
Details
Original description by the author
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
Popularity
- GitHub stars
- 280k
- Ranking position
- #272
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
accessibility
Helps your agent create interfaces that everyone can use. Ensures websites and apps work well for people with disabilities, like those who are blind or have reduced mobility.
affaan-m/ECC
agent-architecture-audit
Makes your agent check if everything is working correctly. It finds and fixes problems in AI systems, ensuring they perform as expected.
affaan-m/ECC
agent-eval
Helps your agent compare different AI coding tools. It measures which one is faster, cheaper, and more reliable for specific tasks.
affaan-m/ECC
agent-harness-construction
Makes your agent better understand how to perform tasks. It optimizes the tools and instructions the agent uses to increase its chances of success.
affaan-m/ECC
Similar skills
template-skill
This is a generic template for new skills. It needs a specific description to be useful.
anthropics/skills
shipping-and-launch
Prepares your code to be safely launched into production. Helps ensure everything is ready, monitored, and has a rollback plan.
addyosmani/agent-skills
using-agent-skills
Has your agent discover and use other skills. It's useful for deciding which tool or workflow to use for a specific task.
addyosmani/agent-skills