用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/andrem-sec/psc-comet --skill safety-guard命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | safety-guard |
| description | Three-mode safety guardrail for autonomous operations with action logging |
| version | 0.1.0 |
| level | 2 |
| triggers | ["enable safety guard","careful mode","freeze writes","autonomous safety"] |
| context_files | ["context/learnings.md"] |
| steps | [{"name":"Mode Selection","description":"Choose Careful (warn), Freeze (lock), or Guard (both)"},{"name":"Hook Configuration","description":"Enable PreToolUse hooks for protected operations"},{"name":"Operation Monitoring","description":"Intercept and evaluate destructive commands"},{"name":"Action Logging","description":"Log blocked and warned actions to ~/.claude/safety-guard.log"},{"name":"User Notification","description":"Alert user when guard blocks or warns on operation"}] |
Three-mode safety guardrail system for autonomous agent sessions. Prevents destructive operations and logs all interventions.
Without safety guardrails, autonomous agents:
Safety guard ensures autonomous operations remain safe and auditable.
Behavior: Warns on destructive commands but allows execution after user confirmation.
Use When: Standard development, trusted environments, human oversight available.
Protected Operations: rm -rf, git push --force, git reset --hard, DROP TABLE/DATABASE, docker system prune, kubectl delete, chmod 777, sudo rm, npm/cargo publish, --no-verify flags.
Behavior: Blocks write operations to specific paths. Config: FREEZE_PATHS="/etc/,~/.ssh/". Blocks Write, Edit, and Bash ops to frozen paths.
Behavior: Warns on destructive ops AND locks write paths. Use for: autonomous agents, docker-sandbox, permissionMode: dontAsk sessions.
Safety guard extends existing hooks with additional checks.
PreToolUse Bash Hook Enhancement:
# Add to existing block-destructive.sh or create safety-guard-bash.sh
SAFETY_MODE="${SAFETY_GUARD_MODE:-off}" # off | careful | freeze | guard
LOG_FILE="${HOME}/.claude/safety-guard.log"
if [ "$SAFETY_MODE" = "off" ]; then
exit 0 # Safety guard disabled
fi
COMMAND="$1" # Tool input from stdin
# Careful mode: destructive operation detection
if [[ "$SAFETY_MODE" =~ (careful|guard) ]]; then
if echo "$COMMAND" | grep -qE "rm\s+-rf|git push.*--force|git reset --hard|DROP (TABLE|DATABASE)|docker system prune|kubectl delete|chmod 777|sudo rm|--no-verify"; then
echo "$(date -Iseconds) WARN: $COMMAND" >> "$LOG_FILE"
echo "⚠️ SAFETY GUARD: Destructive operation detected"
echo "Command: $COMMAND"
echo "Continue? (y/N):"
# Exit 1 to prompt user, or exit 0 if user confirms
fi
fi
# Freeze mode: write path locking
if [[ "$SAFETY_MODE" =~ (freeze|guard) ]];
FREEZE_PATHS=
[ -n ];
PreToolUse Write/Edit Hook Enhancement:
# Check if write target matches frozen paths
SAFETY_MODE="${SAFETY_GUARD_MODE:-off}"
TARGET_FILE="$1"
if [[ "$SAFETY_MODE" =~ (freeze|guard) ]]; then
FREEZE_PATHS="${FREEZE_PATHS:-}"
for frozen_path in ${FREEZE_PATHS//,/ }; do
if [[ "$TARGET_FILE" == "$frozen_path"* ]]; then
echo "$(date -Iseconds) BLOCK: Write to $TARGET_FILE (frozen path)" >> ~/.claude/safety-guard.log
echo "❌ SAFETY GUARD: Write blocked"
echo "Path: $TARGET_FILE is frozen"
exit 2 # Block operation
fi
done
fi
All interventions logged to ~/.claude/safety-guard.log with ISO timestamp, action (WARN/BLOCK), command, reason, outcome. Rotate at session start if >10KB.
Via env vars: SAFETY_GUARD_MODE=guard and FREEZE_PATHS="/etc/,~/.ssh/". Or in agent frontmatter. Unset to disable.
Complements:
Does NOT replace:
Always-on Guard mode: Guard mode for routine development slows workflow. Use Careful mode for normal work.
Freezing entire project: Freeze mode for / blocks all writes. Be specific with frozen paths.
Ignoring warnings repeatedly: If you're clicking through 10 safety warnings, the guard is misconfigured for your task.
No log review: Safety log accumulates warnings. Review monthly to identify risky patterns.