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 widnyanav1.1.2MITIn 1 marketplace
Stops Claude from staging whole trees, protected files or history-rewriting git commands. A PreToolUse hook on Bash denies matching git add, commit and push calls before they run, and needs jq on PATH.
Trending plugins
7-day copy clicks
Run automatically on Claude Code events. Claude doesn't decide.
1 caution to review before installing
A hook runs when Claude uses the Bash tool
Static checks of hooks, mods, MCP servers and commands. Not a security audit.
1 marketplace, most starred first
git-safety, git-hooks, pretooluse-hook, command-blocking, guardrail, protected-files, hook, safety
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
A Claude Code PreToolUse hook for the Bash tool. It inspects every
git command Claude is about to run and denies any that would stage a
protected path, stage the whole tree, or rewrite history. It is silent
(exit 0, no JSON) on everything else — so non-git commands and safe git
commands are never disturbed.
Enable this plugin (/plugin install block-forbidden-git-add or via
npx skills add widnyana/eyay-toolkits) and the hook registers itself
automatically as a PreToolUse hook — no settings.json editing required.
Requires jq on PATH (used to read the payload and emit the verdict).
The hook reads the JSON payload Claude sends on stdin and emits a JSON verdict
on stdout. deny = block the command and show the reason to the model;
silence = allow.
| Variable | Default | Meaning |
|---|---|---|
FORBIDDEN_FILES | CLAUDE.md AGENTS.md | Protected files, matched by basename anywhere in the path. |
FORBIDDEN_DIRS | docs tmp secrets | Protected directories, matched as any path component. |
WILDCARD_TOKENS | -A --all -u --update . * | Tokens that make git add a whole-tree stage. |
FORBIDDEN_SUBCOMMANDS | revert rebase reset filter-branch filter-repo | History-rewriting / state-rolling subcommands. |
FORBIDDEN_FLAGS | commit --amend, commit -a, commit --all$, push --force, push -f, push + | "<subcommand> <flag>" pairs. Matches the exact flag, the flag plus a suffix (--force-with-lease), a short-flag cluster (-uf, -am), a long-flag abbreviation (--forc), or a +refspec. A trailing $ means exact match only (so --allow-empty is not caught by commit --all$). |
MONITORED | add commit push + the forbidden subcommands and flag subcommands | Subcommands the hook analyzes; others are ignored. |
Do not edit the plugin script. Commit a JSON file inside the project (never
under ~/.claude):
<project>/.claude/block-forbidden-git-add.json<project>/.pi/block-forbidden-git-add.json (read second, wins per key){
"forbidden_dirs": ["tmp", "secrets"],
"forbidden_files": ["CLAUDE.md"],
"forbidden_flags": ["commit --amend", "pull --rebase"]
}
Keys (all optional, all string arrays): forbidden_files, forbidden_dirs,
wildcard_tokens, forbidden_subcommands, forbidden_flags. A key that is
present REPLACES the default list; [] empties it. Absent keys keep defaults.
The guard cannot protect its own config: it only sees Bash, and the file is
a normal committed file, so an agent can edit it with a file write. Review
changes to these files in the diff or PR.
The project root is $CLAUDE_PROJECT_DIR, else the git toplevel of the
working directory. The file is read with jq and never executed. A bad file
(invalid JSON, wrong type, unknown key, symlink) fails closed: every git
call the guard watches is denied with a "bad config" reason until it is fixed.
git addAny git add containing a wildcard token (-A, --all, -u, --update,
., *) is denied, because it could sweep protected paths into the index.
git add . -> DENY
git add -A -> DENY
git add --all -> DENY
git add * -> DENY
Also denied: git add -- ., git add .., git add ./*, git add :/, and
clustered or abbreviated flags (-fA, --al).
This is cwd-blind by design: git add . is denied even from a subdir,
because . from inside docs/ would be exactly the protected case. Safe
over-blocking.
Each path component is matched against the protected names, as a glob and
without regard to case (macOS and Windows file systems ignore case). A path
is blocked if any component matches a protected dir, or the last component
matches a protected file. Quotes, escaped spaces, ./, :/ pathspecs and
trailing / are handled. The same check runs on git commit <paths>. This
catches relative, absolute, parent-relative, quoted and globbed forms alike:
git add docs/plan.md -> DENY (docs/ protected)
git add ./docs/loki/README.md -> DENY
git add /Users/wid/x/docs/README.md -> DENY (absolute path)
git add ../docs/README.md -> DENY (parent-relative)
git add 'docs/README.md' -> DENY (quoted)
git add sub/AGENTS.md -> DENY (AGENTS.md basename)
git add "docs/my file.md" -> DENY (quoted, with a space)
git add Docs/x.md / git add claude.md -> DENY (case-insensitive)
git add d* / git add src/* -> DENY (glob can reach docs/)
git add src/*.ts -> pass
git add charts/app/values.yaml -> pass (safe path)
Globs are matched against protected names, so git add src/* is denied even
if src/docs does not exist. Stage explicit paths instead.
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 widnyana/eyay-toolkits --plugin block-forbidden-git-addPlugins from other owners that cover similar ground