Catalog
affaan-m/safety-guard

affaan-m

safety-guard

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.

NewUpdated Sep 27, 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

73/100

Grade

B

Good

Grades are signals, not a certification. Always review a skill yourself before use.

Safety

82

Quality

68

Clarity

76

Completeness

62

Summary

Safety Guard is a protective skill that intercepts and gates destructive operations through three modes: Careful (warns on dangerous commands like rm -rf and git push --force), Freeze (locks writes to a specific directory), and Guard (combines both). It works via PreToolUse hooks to inspect Bash, Write, and Edit tool calls before execution, making it useful for autonomous agents and production environments.

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 Deletion2x in 1 fileMax: B

Recursive deletion pattern (rm -rf)

SKILL.mdrm -rf2x
SEC-002Privilege Escalation

Privilege escalation (sudo)

SKILL.mdsudo r
SEC-003File Permission Modification

File permission modification (chmod)

SKILL.mdchmod 777

Detected Capabilities

tool interception (PreToolUse hooks)command pattern matchingfile write blockingconfirmation promptslogging blocked operations

Trigger Keywords

Phrases that agents use to match this skill to user intent.

prevent accidental deletesautonomous agent safetylock directory editsgate destructive commandsproduction environment guardconfirm git operations

Risk Signals

INFO

Pattern list includes 'rm -rf' as intercepted command

SKILL.md | Mode 1: Careful Mode
INFO

Pattern list includes 'sudo rm' as intercepted command

SKILL.md | Mode 1: Careful Mode
INFO

Pattern list includes 'chmod 777' as intercepted command

SKILL.md | Mode 1: Careful Mode
INFO

Skill documents watching for dangerous commands but does not execute them — it intercepts and gates them

SKILL.md | Mode 1: Careful Mode

Use Cases

  • Restrict autonomous agent edits to a single directory during development
  • Prevent accidental destructive commands (rm -rf, git force push) in production environments
  • Gate dangerous operations during sensitive migrations or deployments
  • Add confirmation workflows for high-risk git and database operations
  • Lock down test environments to prevent unintended cross-project changes

Quality Notes

  • Skill is defensive in nature: it describes *blocking* dangerous patterns, not executing them — this is the correct approach
  • Clear three-mode design with concrete examples of activation syntax (/safety-guard freeze, /safety-guard guard)
  • Well-defined scope: operates via PreToolUse hooks on Bash, Write, Edit, MultiEdit tools only
  • Good practical use cases (production, autonomous agents, directory locking)
  • Missing: no documentation of what 'confirmation' actually looks like or how user provides it
  • Missing: no edge cases documented (e.g., what happens if a tool call matches multiple patterns, or if user ignores confirmation)
  • Missing: no examples of blocked vs. allowed commands for clarity
  • Missing: error handling and fallback behavior if hooks fail or are misconfigured
Model: claude-haiku-4-5-20251001Analyzed: Sep 27, 2026

Reviews

Add this skill to your library to leave a review.

No reviews yet

Be the first to share your experience.

Version History

  1. v2.0

    Contract changed: description

    ✦ AIExpands skill scope to describe three operational modes (Careful, Freeze, Guard) with PreToolUse hooks and broadens use cases.

    triggering2026-09-27

    LATEST
  2. v1.2

    Content updated

    ✦ AINo behavioral changes detected.

    2026-07-14

    View This Version
  3. v1.1

    Content updated

    ✦ AIAdds LICENSE file.

    2026-04-20

    View This Version
  4. v1.0

    2026-04-12

    View This VersionInitial version

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

Command Palette

Search for a command to run...