Security·terminal·MIT
anchorwatch-mod
Blocks rm -rf, force pushes, DROP TABLE, curl | sh and cat .env before they run.

anchorwatch-mod is the Bash guard of Anchorwatch, a guardrails plugin for Claude Code, rewritten as a Claude Mod. It reads every command Claude is about to run through the Bash tool and refuses the ones the classic plugin denies: recursive deletes of critical paths, force pushes to protected branches, history-rewriting git commands, DROP and TRUNCATE, curl | sh, disk formatting, chmod 777, printing a .env file, and shell writes to secret files. The refusal reaches the model as the tool’s error, with the same reason text the classic plugin uses, so Claude can explain the block and propose something safer.
It is an experiment by the Anchorwatch team, at version 0.0.4, and the author calls it a prototype against a pre-release API. The shell-script plugin anchorwatch stays the supported one.
What it does
Nine rules, the ones the classic plugin runs at block level:
- rm-recursive-dangerous:
rm -raimed at/,~,.,..,*,.git, a system directory, your home or the project root. - git-force-push-protected:
git push --force,-f,--force-with-leaseor--force-if-includesto main, master, production, prod or release. - git-destructive:
reset --hard,clean -f,checkout -- .,stash drop,branch -D,filter-branchand similar. - sql-destructive:
DROP TABLE,DROP DATABASE,TRUNCATE, andDELETE FROMwithout aWHERE. - pipe-to-shell:
curlorwgetpiped into a shell. - disk-destroy:
mkfs,fdisk,shred,dd if=, redirections into/dev/sd*and the like. - perm-broad:
chmod 777,chmod a+rwx, recursivechownof/. - env-read:
cat,head,less,base64and other whole-file readers on a.envfile..env.exampleand its siblings are exempt. - secret-write: a redirection,
tee,cp,mv,sed -iordd of=whose destination is a.env, a key file, an SSH or cloud credentials file.
A chained command is split into segments on &&, ||, ;, | and newlines, and $(…), backticks, subshells, brace groups and sh -c "…" payloads are unwrapped first, so X=$(rm -rf /) is checked as the command it is.
Install
Needs Claude Code with function hooks enabled and git. The README declares no minimum Claude Code version; the author validated the module scan on 2.1.268. The plugin is not in the anchorwatch marketplace, which only publishes the classic plugin, so you load it from a clone:
git clone https://github.com/anchorwatch-dev/anchorwatch
claude --plugin-dir ./anchorwatch/plugins/anchorwatch-mod
Run the second command from your project directory, with the path pointing at the clone. There is nothing to configure and no command to type: the guard is active from the first Bash call. Without the function hooks flag the module is ignored and the plugin does nothing.
How it works
Two hooks. session.start records the working directory. tool.call, filtered to the Bash tool, reads the command, runs it through the rules in order and either returns a deny with the reason or calls next(e) so the tool runs as normal.
One thing leaves the hook: when a force push names no refspec, it runs git rev-parse --abbrev-ref HEAD through $.process.run, capped at two seconds with $.clock.sleep, to learn which branch is being pushed. That is the only process it spawns. It makes no network calls, writes nothing to disk and keeps only the working directory in memory. The only token cost is the deny reason, which the model reads when a command is blocked.
Failure mode matters for a guard. Claude Code skips a hook that throws or runs past ten seconds and lets the tool run. This mod chains a .catch on its registration that denies the command when the guard never got to answer, so a broken guard says no instead of nothing. If the hook had already dispatched, the .catch replays the tool result instead.
If you run both plugins, this hook runs before the classic Bash guard, because tool.call wraps the classic PreToolUse hooks. The author reports that the two agree on every test fixture.
Limitations
- Not tested in a live session by the author. What is verified: the synthetic-event test suite, 182 cases including parity against the classic
guard-bash.sh, andclaude plugin validate --stricton 2.1.268. Whether the hook fires in a real session is still to be measured. - Bash only. The Edit, Write and Read guards stay in the classic plugin, as do the warn-level rules, because the author found no additive-context channel on
tool.callto carry a warning. - No configuration.
.anchorwatch.jsonoverrides (rule levels, allow patterns, protected branches) and theANCHORWATCH_DISABLEkill switch are not ported. The deny text still points to.anchorwatch.json; that only changes the classic plugin. - Home directory unknown. The hook receives
cwdbut nothome, so~/.ssh/id_rsais caught by its file name while directory-only cases such as~/.aws/configare not. A literal$HOMEpath is not expanded either. - It blocks the command, not the output. A secret that reaches the transcript another way is not hidden; secret-redactor covers that side.
- The API is pre-release. The author expects breakage between Claude Code versions.
More mods
The whole directory →honmoon-redact
Redacts secrets and PII from tool output and prompts, blocks reads of key files.
claude --plugin-dir ./honmoon/packages/claude-pluginsecret-redactor
Swaps secrets, emails and IPs for placeholders before the model sees them.
claude plugin install secret-redactor@awesome-claude-code-function-hooksagent-flow
Every subagent of the session in a live tree beside the transcript. Zero tokens.
claude plugin install agent-flow@claude-agent-flowautodev-core
Autonomous sprint loop: brainstorm, auto, iterate, audit, review, ship. Redacts secrets.
claude plugin install autodev-core@autodev