Catalog
affaan-m/safety-guard

affaan-m

safety-guard

Use this skill to prevent destructive operations when working on production systems or running agents autonomously.

global
origin:ECC
New~470
v1.2Saved Jul 14, 2026

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
Files1
1 files · 1.0 KB

Select a file to preview

Overall Score

72/100

Grade

B

Good

Safety

78

Quality

68

Clarity

80

Completeness

58

Summary

This skill teaches agents how to prevent destructive operations through three protection modes: Careful Mode (intercepts and warns on risky commands), Freeze Mode (restricts writes to a specific directory), and Guard Mode (combines both). It uses PreToolUse hooks to intercept Bash, Write, Edit, and MultiEdit calls and enforces safety guardrails before execution.

Static Analysis Findings

3 findings

Patterns detected by deterministic static analysis before AI scoring. Hover over any finding code for detailed information and remediation guidance.

Destructive Operation
SEC-001Recursive DeletionMax: B

Recursive deletion pattern (rm -rf)

SKILL.mdrm -rf
SEC-002Privilege Escalation

Privilege escalation (sudo)

SKILL.mdsudo r
SEC-003File Permission Modification

File permission modification (chmod)

SKILL.mdchmod 777

Detected Capabilities

command interceptiontool call filteringfile write restrictionbash execution blockinglogginguser confirmation prompts

Trigger Keywords

Phrases that MCP clients use to match this skill to user intent.

prevent destructive operationsproduction safety guardautonomous agent restrictionsdirectory write freezeblock dangerous commands

Risk Signals

INFO

SEC-001: Recursive deletion pattern (rm -rf) documented as watchlist item

SKILL.md | Mode 1 Watched patterns section
INFO

SEC-002: Privilege escalation (sudo) documented as watchlist item

SKILL.md | Mode 1 Watched patterns section
INFO

SEC-003: File permission modification (chmod 777) documented as watchlist item

SKILL.md | Mode 1 Watched patterns section

Use Cases

  • Prevent accidental data loss in production environments
  • Restrict autonomous agent operations to safe directories
  • Block destructive git operations during sensitive migrations
  • Enforce write-only access to specific project directories
  • Audit and log blocked dangerous commands for compliance

Quality Notes

  • Strength: Clear, well-structured skill that explains protection modes with concrete examples
  • Strength: Practical use cases with real-world scenarios (production systems, autonomous agents, migrations)
  • Strength: Detailed watchlist of dangerous patterns gives agents concrete detection targets
  • Strength: Three escalating protection levels offer flexibility for different risk profiles
  • Weakness: Missing implementation details — how PreToolUse hooks are configured, what the hook signature looks like, or how to enable/register them
  • Weakness: No error handling or fallback behavior documented — what happens if an interception fails?
  • Weakness: No examples of actual command-line output when a dangerous command is blocked
  • Weakness: Integration section references 'ECC 2.0' and 'codex' without explanation — external context required
  • Weakness: Freeze Mode directory syntax is shown but no glob patterns or wildcard support documented
  • Weakness: No discussion of bypass risks — how can an agent be prevented from simply using `--allow-bypass` or similar flags?
Model: claude-haiku-4-5-20251001Analyzed: Jul 14, 2026

Reviews

Add this skill to your library to leave a review.

No reviews yet

Be the first to share your experience.

Version History

v1.2

Content updated

2026-07-14

Latest
v1.1

Content updated

2026-04-20

v1.0

No changelog

2026-04-12

Use affaan-m/safety-guard in your dev environment

Command Palette

Search for a command to run...