safety-guard
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.
Skill link
https://github.com/affaan-m/ECC/blob/main/skills/safety-guard/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Protect my project from dangerous commands and restrict edits to the 'src/components/' folder.”
5 new skills a week. 1 minute to read.
safety-guard: full guide
An AI agent that can run commands can also run the wrong one. One mistyped path in an rm -rf, one force push to the main branch, or one DROP TABLE on the wrong database can cost you hours or data you cannot get back. This skill gives the agent a set of rules for avoiding that kind of mistake.
It is for anyone who lets an agent work with real consequences: on a live site, during a migration or deploy, or in a long run where nobody watches each step. You do not need to write code to use it. You tell the agent which mode you want, and it follows the rules. Read the Enforcement section of the skill first: these rules are advice the agent follows, not a lock that stops it.
Use cases
Deploy day on a live site
You are pushing a release and the agent needs to run scripts on a server. Careful mode makes it stop before commands like kubectl delete or git push --force, explain what the command does, and wait for your yes before going further.
Fixing one part of a large project
You only want the login form changed. You ask the agent to freeze edits to src/components/. If a fix seems to need a change in another folder, it tells you why instead of editing, so you decide whether to widen the area.
Letting the agent run unattended
You start a long task and walk away. With Guard mode, the agent can read the whole project but writes only to src/api/, and it asks before any destructive command. The skill suggests enabling it by default for codex -a never sessions.
Step by step
- 1Install the skill: place the safety-guard folder in ~/.claude/skills/ (or in your project's .claude/skills/), as shown in the install box on this page.
- 2Decide what you need: Careful for risky commands, Freeze for one folder, or Guard for both together.
- 3Say it in plain words at the start of your session, for example: "guard mode, write only to src/api/, read anything".
- 4Watch the first warning. The agent should show what the command does, ask for confirmation, and suggest a safer option.
- 5When the risky part of the work is done, tell the agent to stop applying the rules.
Example
What to ask
“We are running a database migration today. Use safety-guard in careful mode, and only allow edits inside the migrations/ folder.”
What you get
The agent confirms both rules are active. Later it plans to run DROP TABLE on an old table. It stops, explains that this deletes the table and its data, asks you to confirm, and suggests renaming the table first. It also declines to edit a file in src/ and says why.
Tips
- ✓The skill is advisory. Nothing blocks a command if the agent ignores the rules. For a hard block, use Claude Code permission deny rules or a PreToolUse hook, as the skill itself recommends.
- ✓Name the exact folder when you use Freeze. A vague area gives the agent room to guess where it may write.
- ✓Do not treat it as a backup. A confirmed command still runs. Keep your own backups or a git commit before a migration, and read each warning before you say yes.
Alternatives
- security-and-hardening
Pick this when you want your code and data to be safer against attacks, not guard against your own agent running destructive commands.
- cso
Pick this when you need a security audit of existing code, with each weakness reported and a way to check it.
- security-audit
Pick this when you want a review of code, APIs or services for weaknesses, with safe steps to reproduce each one.
Questions and answers
Does safety-guard actually stop a command from running?
No. It is advisory: the agent follows the rules itself, and the skill ships no hook. If you need a command blocked whatever the agent does, add a Claude Code permission deny rule or a PreToolUse hook.
Which commands does careful mode watch besides the common ones?
The list also covers git reset --hard, git checkout ., docker system prune, kubectl delete, chmod 777, sudo rm, npm publish, and any command that uses --no-verify, as well as rm -rf, force push and DROP.
Should I use it for every project?
It helps most with production systems, migrations, deploys, data changes, and unattended agent runs. For small local experiments it can add extra questions you do not need, so you can switch it off.
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.
Technical 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
- #397
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
accessibility
280kHelps 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.
agent-architecture-audit
280kMakes your agent check if everything is working correctly. It finds and fixes problems in AI systems, ensuring they perform as expected.
agent-eval
280kHelps your agent compare different AI coding tools. It measures which one is faster, cheaper, and more reliable for specific tasks.
agent-harness-construction
280kMakes your agent better understand how to perform tasks. It optimizes the tools and instructions the agent uses to increase its chances of success.
Similar skills
reverse-engineer-anything
422kHelps your agent look inside shipped apps and packages to explain features, compare versions, or guide a rebuild, using the REA tool.
1password
394kHelps your agent set up the 1Password CLI, sign in, and read or inject secrets without printing their values into chat.
healthcheck
394kHelps your agent audit the computer or server that runs OpenClaw for security risks, such as SSH, firewall, updates, and backups, then suggest safe fixes.