Claude Code hook
claude-guardrails
Hardened security setup combining permission deny rules, shell hooks and prompt-injection defenses.
Install
npx claude-guardrails installgit clone https://github.com/dwarvesf/claude-guardrails.gitFrom the README
claude-guardrails Hardened security configuration for Claude Code — deny rules, hooks, and prompt injection defense out of the box. Why This Exists Claude Code can read your filesystem, run shell commands, and fetch URLs autonomously. A poisoned file in a cloned repo can hijack its behavior via prompt injection. A careless tool call can leak your SSH keys or .env secrets. These configs add defense-in-depth so you don't have to think about it on every session. Full vs Lite Quick Start The script merges into your existing ~/.claude/settings.json (backing it up first) and is safe to run repeatedly. Install from source (git clone) Manual installation If you prefer to install manually, see full/SETUP.md for step-by-step instructions. The key steps are: 1. Copy the variant's settings.json to ~/.claude/settings.json (or merge permissions.deny and hooks.PreToolUse arrays into your existing config) 2. Append the variant's CLAUDE-security-section.md to ~/.claude/CLAUDE.md 3. Copy patterns/secrets.json to ~/.claude/hooks/patterns/secrets.json (shared pattern list for the two scanners below) 4. Copy scan-secrets.sh to ~/.claude/hooks/scan-secrets/ and add the UserPromptSubmit hook entry to settings 5. Copy scan-commit.sh to ~/.claude/hooks/scan-commit/ (its PreToolUse hook entry is already in the variant's settings.json) 6. (Full only) Copy prompt-injection-defender.sh to ~/.claude/hooks/prompt-injection-defender/ and add the PostToolUse hook entry to settings Uninstall Uninstall from source The uninstall uses a surgical remove approach — it reads the variant's config to identify exactly which deny rules and hooks were added, then subtracts only those entries from your ~/.claude/settings.json. Your own custom rules, hooks, and other settings are left untouched. It…
How hooks work
- Hooks are shell commands Claude Code runs at fixed points: before or after a tool call, when you submit a prompt, when Claude stops, on notifications and at session start.
- They are set in the hooks section of ~/.claude/settings.json (or .claude/settings.json for a project), or come bundled in a plugin.
- A hook can block a tool call, add context, or run a formatter or test. Read the scripts before you install them: they run on your machine with your permissions.
Details
- Repository
- dwarvesf/claude-guardrails
- Type
- Hooks
- Language
- Shell
- License
- MIT
- Last updated
- 31 October 2026
- Topics
- ai-safetyclaude-codedeveloper-toolsprompt-injectionsecurity
- Listed in
- awesome-claude-code-hooks
FAQ
What is claude-guardrails?
Hardened security setup combining permission deny rules, shell hooks and prompt-injection defenses. It is a hook for Claude Code, from dwarvesf/claude-guardrails on GitHub.
How do I install claude-guardrails?
Run npx claude-guardrails install, then follow the setup in the README.
Is claude-guardrails popular?
dwarvesf/claude-guardrails has 40 GitHub stars and 6 forks, and is included in 1 curated Claude Code list. It was last updated on 31 October 2026.
More hooks
Claude Organizer
72ramakay/claude-organizer
AI-powered file organization and context engineering that understands content, not patterns. Automatically sorts temporary scripts from permanent docs while preserving your workflow. Works seamlessly with Claude Code hooks. Protects README, LICENSE, configs.
Claude Interactive Documentation Workflow
105tobieapb/claude-interactive-documentation-workflow
I used to whiteboard, then code. Now I markdown, then code. This is how I vibe-code: I can direct, guardrail, and understand the LLM-built code, come back to it 6 months later and actually understand it, and more importantly, craft user-facing documentation artifacts trivially.
Viral Hooks Skill
118rediumvex/viral-hooks-skill
Claude Code skill: 100 viral hook formulas for short-form video scripts (Reels, TikTok, YouTube, LinkedIn, X) across 10 psychology triggers
Claude Brain
92toroleapinc/claude-brain
Sync your Claude Code brain across machines — memory, skills, agents, rules, and settings with intelligent semantic merge. Git-based, auto-sync hooks.
HookPrompt
102KimYx0207/HookPrompt
Claude Code自动提示词优化Hook:谷歌提示词圣经 + 5任务元提示词 | Auto prompt optimization Hook for Claude Code
Sage
105usetig/sage
An LLM council that reviews your coding agent's every move
Browse the most popular Claude Code mods, all hooks, or the skills and MCP server directories.