PluginBench
Skill
Pass
Audit score 90

safety-guard

affaan-m/everything-claude-code

Prevent destructive operations on production systems and autonomous agents with configurable protection modes.

What is safety-guard?

Safety Guard intercepts dangerous commands and restricts file edits to protect production systems and autonomous agents. Use it when working on critical infrastructure, running agents in full-auto mode, or when you need to limit changes to specific directories.

  • Intercepts destructive commands (rm -rf, git push --force, DROP TABLE, etc.) and requires confirmation before execution
  • Locks file edits to a specific directory tree while allowing reads elsewhere
  • Combines careful mode and freeze mode for maximum protection in autonomous agent scenarios
  • Suggests safer alternatives to dangerous operations
  • Logs all blocked actions for audit trails

How to install safety-guard

npx skills add https://github.com/affaan-m/everything-claude-code --skill safety-guard
Claude Code
Cursor
Windsurf
Cline

How to use safety-guard

  1. 1.Enable Careful Mode to intercept dangerous commands: the skill will warn and ask for confirmation when destructive patterns are detected
  2. 2.Enable Freeze Mode to restrict edits to a directory: run `/safety-guard freeze src/components/` to allow writes only to that tree
  3. 3.Enable Guard Mode for maximum protection: run `/safety-guard guard --dir src/api/ --allow-read-all` to combine both protections
  4. 4.Disable protection when needed: run `/safety-guard off` to unlock all restrictions

Use cases

Good for
  • Protecting production systems from accidental destructive commands while working on them
  • Running autonomous agents in full-auto mode with restricted write access to critical areas
  • Limiting agent edits to a specific component directory (e.g., src/components/) during development
  • Preventing accidental git force pushes, database drops, or npm publishes
  • Securing sensitive operations like migrations or deployments
Who it's for
  • DevOps engineers managing production systems
  • Teams running autonomous agents without constant supervision
  • Developers working on large codebases who want to isolate changes to specific directories
  • Organizations with strict change control requirements

safety-guard FAQ

What commands does Safety Guard block?

It watches for patterns like rm -rf (especially on /, ~, or project root), git push --force, git reset --hard, DROP TABLE/DATABASE, docker system prune, kubectl delete, chmod 777, sudo rm, npm publish, and any command with --no-verify.

Can agents still read files outside the frozen directory?

Yes. Freeze Mode only restricts writes. With --allow-read-all flag in Guard Mode, agents can read anywhere but only write to the specified directory.

What happens when a dangerous command is detected?

Safety Guard shows what the command does, asks for confirmation, and suggests a safer alternative before allowing execution.

Where are blocked actions logged?

All blocked actions are logged to ~/.claude/safety-guard.log for audit and review purposes.

Can I use this with autonomous agents?

Yes. Guard Mode is designed specifically for autonomous agents running in full-auto mode, combining careful command interception with directory-level write restrictions.

Full instructions (SKILL.md)

Source of truth, from affaan-m/everything-claude-code.


name: safety-guard description: Use this skill to prevent destructive operations when working on production systems or running agents autonomously. metadata: origin: ECC

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