/ecc-security:safety-guardfrom ecc-security
Use this skill to prevent destructive operations when working on production systems or running agents autonomously.
Ships in ecc-security. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Three modes of protection:
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.
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.
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.
/safety-guard off
Uses PreToolUse hooks to intercept Bash, Write, Edit, and MultiEdit tool calls. Checks the command/path against the active rules before allowing execution.
Add the following to .claude/settings.json to install the guard hook:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash|Write|Edit|MultiEdit",
"hooks": [
{
"type": "command",
"command": "node ~/.claude/hooks/safety-guard.js"
}
]
}
]
}
}
~/.claude/hooks/safety-guard.js)// PreToolUse hook — blocks destructive commands in careful/guard mode.
// Reads SAFETY_GUARD_MODE from env: "careful", "freeze:<dir>", or "guard:<dir>".
// CommonJS so `node ~/.claude/hooks/safety-guard.js` runs as-is (no "type":"module" needed).
const { readFileSync } = require('node:fs');
const input = JSON.parse(readFileSync('/dev/stdin', 'utf8'));
const mode = process.env.SAFETY_GUARD_MODE || '';
const tool = input.tool_name || '';
const cmd = input.tool_input?.command || input.tool_input?.file_path || '';
const DESTRUCTIVE = /rm\s+-rf|git\s+push\s+--force|git\s+reset\s+--hard|DROP\s+(TABLE|DATABASE)|docker\s+system\s+prune|kubectl\s+delete|--no-verify/i;
if ((mode === 'careful' || mode.startsWith('guard')) && tool === 'Bash' && DESTRUCTIVE.test(cmd)) {
console.error(`[safety-guard] Blocked destructive command: ${cmd}`);
process.exit(1);
}
if (mode.startsWith('freeze') || mode.startsWith('guard')) {
const allowedDir = mode.split(':')[1] || '';
if ((tool === 'Write' || tool === 'Edit' || tool === 'MultiEdit') && allowedDir && !cmd.startsWith(allowedDir)) {
console.error(`[safety-guard] Blocked write outside allowed dir (${allowedDir}): ${cmd}`);
process.exit(1);
}
}
process.exit(0);
Set the mode before your session:
export SAFETY_GUARD_MODE=careful # intercept destructive commands
export SAFETY_GUARD_MODE=freeze:src/api/ # lock writes to src/api/
export SAFETY_GUARD_MODE=guard:src/api/ # both
codex -a never sessions~/.Codex/safety-guard.logWhat SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
14 skills in this plugin
/defi-amm-securitySecurity checklist for Solidity AMM contracts, liquidity pools, and swap flows. Covers reentrancy, CEI ordering, donation or inflation attacks, oracle manipulation, slippage, admin controls, and integer math./django-securityDjango security best practices, authentication, authorization, CSRF protection, SQL injection prevention, XSS prevention, and secure deployment configurations./gateguardFact-forcing gate that blocks Edit/Write/Bash (including MultiEdit) and demands concrete investigation (importers, data schemas, user instruction) before allowing the action. Measurably improves output quality by +2.25 points vs ungated agents.npx claudepluginhub hretheum/skillforge --plugin ecc-security