Claude Code Safety Hooks — Development skill for Claude Code
Production-tested safety primitives for Claude Code agents: dangerous command guard + untrusted content defense.
How to install Claude Code Safety Hooks
This entry records only its repository, not the path inside it, so there is no
exact command to give. Open alexknowshtml/claude-code-safety-hooks and copy the folder into
~/.claude/skills/, or the file into ~/.claude/agents/.
What Claude Code Safety Hooks does
Production-tested safety primitives for Claude Code agents: dangerous command guard + untrusted content defense.
Alternatives in Development
- Claude Hooks Mastery — 3,300+ Complete mastery guide for Claude Code hooks with production-ready scripts 3.4k ★
- Axiom — Battle-tested Claude Code skills for modern xOS (iOS, iPadOS, watchOS, tvOS) development with 13 production-re 2.6k ★
- Agent Skills Platform — Build tested agent skills and govern their lifecycle through a user-defined marketplace: evidence, discovery 2.4k ★
README
Claude Code Safety Hooks
Production-tested safety primitives for [Claude Code](https://docs.anthropic.com/en/docs/claude-code) agents. Extracted from [JFDIBot](https://jfdi.bot), an AI executive assistant that manages email, membership platforms, DNS, and shell access for a real business.
Read the full write-up: [Every Unlocked Door Needs a Security System](https://jfdi.bot/blog/every-unlocked-door-needs-a-security-system)
Three layers of defense
These components implement a layered defense model. Each layer is independent - none of them trust the others.
Layer 1: Instruction-source separation (behavioral)
**File:** [`includes/untrusted-content-defense.md`](includes/untrusted-content-defense.md)
A set of rules loaded into your agent's context that establish a foundational principle: the user's messages are instructions, everything fetched from outside is data. Covers authority claims, override language, exfiltration requests, and encoded payloads.
This is the weakest layer because it depends on the AI following instructions correctly. A sufficiently clever injection could slip through.
Layer 2: Architectural isolation (structural)
When your agent processes external content, route it through a sandboxed sub-agent that extracts what's useful and returns a summary. The main agent that has access to tools and systems never sees the raw external content. An injection has to survive two hops - influencing the sandboxed processor, then re-injecting through the summary into the main agent's decision-making.
This repo doesn't include a turnkey implementation of Layer 2 (it depends on your agent architecture), but the [blog post](https://jfdi.bot/blog/how-jfdibot-protects-against-content-injection-and-destructive-actions) describes the pattern in detail.
Layer 3: Deterministic command guard (code, no AI)
**File:** [`hooks/dangerous-command-guard.sh`](hooks/dangerous-command-guard.sh)
A bash script that runs as a [PreToolUse hook](https://docs.an
Related Skills
Cc Agents Kit
Claude Code plugin marketplace. guard-hooks: five defensive hooks that block dangerous shell commands and secr
Claude-code-safety-net Rules Reference
Custom rules reference for defining safe/dangerous command patterns.
Guard And Guide
🛡️ Guard coding agents from dangerous operations, and 🧭 Guide them to safer alternatives.
Effect Claudecode
Effect v4 bindings for Claude Code's plugin primitives — hooks, skills, settings, MCP servers, frontmatter
Guard
Safety guardrails — blocks destructive commands (rm -rf, DROP TABLE, force-push) and optionally restricts edit
Kuma:Guard
🛡️ Kuma Guard — Pre-flight safety check against anti-patterns, drift, and circular deps
Related Agents
Claude Code MCP Behavior Analysis
Results from 15 tests against a minimal Cord MCP server. Tested: Claude Code 2.1.37, 2026-02-18. Note: These t
Project Automation Auditor
Audits a project's automation and verification posture: test runner, formatter/linter PostToolUse hooks, PreTo
AI Ethics Reviewer
AI / ML ethics + responsible-AI specialist — bias, fairness, model selection, dataset provenance, automated-de