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 rishubilMITIn 1 marketplace
PreToolUse hook that blocks Bash commands which would kill their own shell or Claude Code itself — pkill -f, pgrep piped to kill, and ps | grep | kill chains checked against what they would actually match — plus a non-blocking reminder to re-check kill code written to files.
Run automatically on Claude Code events. Claude doesn't decide.
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.
A Claude Code plugin that blocks Bash commands which would kill the shell running them — or Claude Code itself — before they run, and reminds the model to re-check kill code it writes into files (see Write-time reminder).
Claude Code runs every Bash tool call as a fresh
/bin/zsh -c '<preamble> && <the entire command text>' process, so that
shell's own /proc/<pid>/cmdline contains the full command text. pkill -f uvicorn matches by full command line, not just the process name — so it
matches its own shell first (the pattern uvicorn is sitting right there in
the command it was typed into) and kills it before the intended target is
ever reached. There is no error to read, because the process that would have
reported the result is the one that died.
This was verified directly on this machine: pgrep -af SOMETOKEN matches the
very shell running the command that contains SOMETOKEN, confirming that any
pkill -f/pgrep -f/ps | grep chain built from a token present in its own
invocation is self-targeting.
This plugin adds a PreToolUse hook on the Bash tool that catches this
class of mistake — and the related one of killing Claude Code's own process
tree — before the command runs.
| Shape | Checked against |
|---|---|
pkill PATTERN | Full command line if -f/--full is present, otherwise process name |
pgrep PATTERN | ... kill or kill $(pgrep PATTERN) / kill `pgrep PATTERN` | Same as pkill, since it feeds a kill either way |
ps ... | grep PATTERN | ... | kill | Full command line (what ps would list) |
pkill NAME / killall NAME | Process name only — killall has no -f on either psmisc or BSD |
In every case the check is the same question: does PATTERN actually match
the command's own text, an ancestor process's command line (Claude Code, its
node runtime, other ancestors of this session, ...), the shell wrapper's
fixed strings (shell-snapshots, NO_EXTENDED_GLOB, ...), or a protected
process name (zsh, bash, node, claude, ...)? If none of those match,
nothing is blocked.
Only tokens in command position are treated as an invocation — the word
pkill inside an argument (an echo, a commit message, a quoted string) is
not a pkill call and is never flagged. A prefix like sudo pkill ... or
xargs pkill ... still counts as command position, so those are still caught.
Which words really are command invocations is decided by a real shell
parser, see How invocations are found. So
cd /tmp + newline + pkill -f x, if true; then pkill -f x; fi, ! pkill -f x, ( pkill -f x ) and echo $(pkill -f x) are all caught, while echo then pkill -f x and a heredoc that is only data are not.
Name matching has an asymmetry worth knowing, because it's the reason the
guard catches more than a naive reader would expect: pkill/pgrep do a
partial regex search against the process name unless -x/--exact is
given (so pkill nod really does hit node — this is documented pkill(1)
behaviour, not a guess), while killall matches the name exactly by
default and only becomes a regex search with -r/--regexp. pidof always
matches a literal program name exactly. Each shape carries its own default in
the code specifically so this asymmetry isn't "corrected" into a bug later.
The structural question (is pkill/pgrep/killall/pidof/ps | grep | kill/kill $(pgrep ...) actually run, and with which argv) is answered by
tree-sitter-bash:
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 rishubil/skills --plugin self-kill-guardPlugins from other owners that cover similar ground