Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
By pchalasaniv1.15.2MITIn 1 marketplace
Stops Claude from deleting files, discarding uncommitted work, or reading .env secrets by blocking those commands before they run. Git commits need your approval, and the hooks run automatically before shell, edit and read calls.
Trending plugins
7-day copy clicks
Run automatically on Claude Code events. Claude doesn't decide.
Public GitHub repos that commit this plugin as enabled in their Claude Code settings
2 cautions to review before installing
A hook runs when Claude uses the Bash tool
A hook runs when Claude writes or edits files
Static checks of hooks, mods, MCP servers and commands. Not a security audit.
1 marketplace, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Provides safety hooks to block (or require user approval) various commands.
The standalone hooks require Python 3.9 or newer on PATH as python3.
They use only the Python standard library and do not require installing the
main claude-code-tools package (which has its own Python requirement).
To check compatibility, run the hook tests with each supported interpreter, using pytest 8 on Python 3.9 (pytest 9 requires Python 3.10 or newer):
uv run --no-project --python 3.9 --with 'pytest<9' python -m pytest \
plugins/safety-hooks/hooks/test_python_compatibility.py
The hooks in this collection use three decision types:
A unified Bash hook that combines multiple safety checks. It runs all sub-checks and applies priority: block > ask > allow.
Uses hookSpecificOutput format with permissionDecision field to communicate
decisions to Claude Code.
Sub-hooks it imports:
rm command (including /bin/rm, /usr/bin/rm)cat > notes.md <<'EOF' may
mention rm freely. Bodies are only treated as data when the heredoc is
simple: the << line has no substitution, backticks, brackets, braces
or backslashes (plain $VAR is fine) and the delimiter is a plain word,
optionally quoted. With an unquoted delimiter the body's expansions run
($(...), backticks, even ${x@P}), so an unquoted body containing $
or a backtick is scanned in full too. Anything more exotic is scanned in
full, which can over-block but never blanks a line bash would run. Quote
the delimiter when documenting commands. (Commands built at run time, e.g.
eval "$x" or ${x@P}, are outside what any of these guards inspect,
heredoc or not.)Decisions: block, ask, or allow depending on context
Hard blocks (blanket commands that add files indiscriminately, without explicit selection):
git add -A, git add -a, git add --all - stages everything including
untracked files across the entire repogit add . - stages entire current directory blindlygit add .: git add ./, the repository-root magic
git add :/ and git add :(top), an empty pathspec, and any absolute
path containing the working directorygit add ../ (parent directory patterns) - stages outside current scopegit add * (wildcard patterns) - shell expansion can match unexpected filesgit commit -a without -m flag - would open an editor (not interactive)Ask (user approval required):
--pathspec-from-file - stages a list of paths the hook cannot readAllow without prompting: every other git add, whether the paths are
new, modified, or a named directory. Explicit selection is the point: if the
paths are spelled out, the command is not blanket staging.
Purpose: Prevent blanket staging, without gating ordinary work
Decision: block
Hard blocks (these commands discard uncommitted work permanently with no recovery option):
git checkout -f / --force - forces checkout, discarding all local
changes without warninggit checkout . - reverts ALL files in current directory to last commitgit checkout <branch> -- . - overwrites all files with version from
another branchgit checkout <branch> -- <file> - overwrites specific file from another
branchConditional blocks: If there are uncommitted changes, blocks and shows list of modified files with safer alternatives (stash, commit, restore, switch)
Allows: git checkout -b (new branch), --help, -h
Purpose: Protect uncommitted work from being discarded
git commit commandhookSpecificOutput with permissionDecision: "ask" to
trigger UI promptCCTOOLS_ALLOW_GIT=1 in the environment (e.g. the
env block of ~/.claude/settings.json) to allow commits in every session,
which is what unattended workflows need. Per session, >allow-git allows
commits and >allow-git off restores the prompt; off wins over the
environment variable.Built from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.
npx claudepluginhub pchalasani/claude-code-tools --plugin safety-hooksPlugins from other owners that cover similar ground