safety-guard — Claude Code skill: what it does and how to install
Intercepts destructive commands for confirmation and can limit writes to one directory. Use it when an agent runs autonomously or changes need tighter boundaries.
npx skills add affaan-m/ECC --skill safety-guard -a claude-codeWhat safety-guard does
The skill has three modes. Careful asks for confirmation before commands such as git push --force or DROP TABLE and suggests a safer alternative. Freeze blocks writes outside a chosen directory. Guard combines both: the agent can read the project but only write to the selected folder.
It uses PreToolUse hooks to check Bash, Write, Edit, and MultiEdit calls. Start a mode with /safety-guard freeze src/components/ or /safety-guard guard --dir src/api/ --allow-read-all; use /safety-guard off to remove the restrictions. Blocked actions are logged to ~/.claude/safety-guard.log.
Install it when an agent runs autonomously or you need to constrain its edits. For routine work without directory boundaries, the write restrictions can get in the way.
What it helps with
- ask for confirmation before
git push --force - block writes outside
src/components/ - allow project-wide reads but restrict edits to
src/api/ - intercept destructive commands during a migration
Example prompts for the agent
- Enable Careful and ask me before running destructive commands.
- Freeze edits outside `src/components/` with `/safety-guard freeze src/components/`.
- Enable Guard for `src/api/`, allow reads everywhere, and block destructive commands.
How to install safety-guard
1Skills CLI (Vercel)
npx skills add affaan-m/ECC --skill safety-guard -a claude-code2Manually: put the files in place
~/.claude/skills/safety-guard/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/safety-guard/
1Skills CLI (Vercel)
npx skills add affaan-m/ECC --skill safety-guard -a codex2Manually: put the files in place
.agents/skills/safety-guard/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add affaan-m/ECC --skill safety-guard -a cursor2Manually: put the files in place
.cursor/skills/safety-guard/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install affaan-m/ECC safety-guard2Manually: put the files in place
.github/skills/safety-guard/SKILL.md1Skills CLI (Vercel)
npx skills add affaan-m/ECC --skill safety-guard -a gemini-cli2Platform CLI
gemini skills install https://github.com/affaan-m/ECC --path skills/safety-guardManually: put the files in place
.devin/skills/safety-guard/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add affaan-m/ECC --skill safety-guard -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
From the same set146
The whole set →Similar
Questions about safety-guard
How do I install safety-guard in Claude Code?
Run npx skills add affaan-m/ECC --skill safety-guard -a claude-code.
What does safety-guard do?
It asks for confirmation before destructive commands and can restrict writes to a directory. Guard combines both protections.
Which commands does safety-guard check?
Checks include rm -rf, git push --force, git reset --hard, DROP TABLE, kubectl delete, and commands with --no-verify.
Source text
SKILL.md · MIT
--- name: safety-guard description: "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." 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`
© affaan-m · MIT · affaan-m/ECC