Claude Code hook
claude-hooks
PreToolUse hook that splits compound bash commands and checks each part against allow rules.
Install
git clone https://github.com/liberzon/claude-hooks.gitFrom the README
claude-hooks Smart PreToolUse hook for Claude Code that decomposes compound bash commands (&&, ||, ;, |, $(), newlines) into individual sub-commands and checks each against the allow/deny patterns in your Claude Code settings. Quick start Add this to your ~/.claude/settings.json (merge with existing config): That's it. The hook runs automatically on every Bash tool call and enforces your existing permissions.allow / permissions.deny patterns at the sub-command level. The problem Claude Code's built-in permission system matches commands as a whole string. A compound command like git status && rm -rf / would match an allow pattern for git status — even though it also contains rm -rf /. This hook splits compound commands apart and evaluates each piece individually, so a deny pattern on rm still fires. Without the hook With the hook How it works 1. Receives the tool invocation JSON on stdin (via Claude Code's hook system) 2. Decomposes the bash command into individual sub-commands 3. Loads permission patterns from all settings layers: - ~/.claude/settings.json (global) - $CLAUDE_PROJECT_DIR/.claude/settings.json (project, committed) - $CLAUDE_PROJECT_DIR/.claude/settings.local.json (project, gitignored) 4. Checks each sub-command against deny patterns first, then allow patterns 5. Outputs a JSON permission decision (allow/deny) or exits silently to fall through to normal prompting What the hook handles Command decomposition Compound commands are split on these operators into individual sub-commands, each checked separately: Subshell contents ($() and backticks) are extracted recursively — nested subshells are checked too. Normalization before matching Before a sub-command is checked against your patterns, the hook normalizes it: - Env var prefixes…
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
- liberzon/claude-hooks
- Type
- Hooks
- Language
- Python
- License
- MIT
- Last updated
- 21 March 2026
- Topics
- bashclaude-codeclaude-hooksclisecurity
FAQ
What is claude-hooks?
PreToolUse hook that splits compound bash commands and checks each part against allow rules. It is a hook for Claude Code, from liberzon/claude-hooks on GitHub.
How do I install claude-hooks?
Clone liberzon/claude-hooks from GitHub and follow the setup steps in its README.
Is claude-hooks popular?
liberzon/claude-hooks has 17 GitHub stars and 1 forks, and is included in 2 curated Claude Code lists. It was last updated on 21 March 2026.
More hooks
Codex Claude Bridge
63abhishekgahlot2/codex-claude-bridge
Claude Code and Codex CLI talk to each other through one markdown file in your project. No server, no hooks, no plugin.
Evc
59SaigonXIII/evc
The open-source marketing agent workspace for Claude Code. 42 commands, 12 hooks, 4 industry starters.
Everything Claude Code
62ysyecust/everything-claude-code
Complete collection of Claude Code configs for C++20 HPC development - agents, skills, hooks, commands, and rules
Claude Leverage
68Filip-Podstavec/claude-leverage
Make any repo AI-first - write sustainable code from the start, or refactor a legacy codebase to prepare it for agent-driven development.Building blocks for Claude Code: subagents, slash commands, hooks, and workflow patterns. Copy what you need. A working developer's stack for Claude Code.
Claude Power Tools
70Matt-Hulme/claude-power-tools
Skills that make Claude Code proactively suggest its own power tools - workflows, goals, loops, hooks - at the right moment
c0ntextKeeper
61Capnjbrown/c0ntextKeeper
Automatic context preservation for Claude Code. Never lose work to compaction again. 7 hooks, 187 semantic patterns, 3 MCP tools.
Browse the most popular Claude Code mods, all hooks, or the skills and MCP server directories.