Skip to content
Skillpedia
Misc280k · #272

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

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

Ready-to-paste message

Use this skill to help me: https://github.com/affaan-m/ECC/blob/main/skills/safety-guard/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
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-guard

Or download just the file:

curl -L https://raw.githubusercontent.com/affaan-m/ECC/main/skills/safety-guard/SKILL.md -o SKILL.md
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 never sessions
  • 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

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills