Skip to content

agents: scope git hygiene hook to git add commands#25130

Open
stefanobaghino wants to merge 1 commit into
docker:mainfrom
stefanobaghino:scope-git-hygiene-hook
Open

agents: scope git hygiene hook to git add commands#25130
stefanobaghino wants to merge 1 commit into
docker:mainfrom
stefanobaghino:scope-git-hygiene-hook

Conversation

@stefanobaghino
Copy link
Copy Markdown

The PreToolUse:Bash hook in .agents/settings.json invokes .agents/hooks/enforce-git-hygiene.sh on every Bash tool call, but the script's only job is to block git add . / -A / --all. Scope the hook with "if": "Bash(git add *)" so the script only runs when the command contains git add. This removes per-tool-call overhead and noise — especially when an AI agent works across multiple projects in one session (e.g. via Claude Code's /add-dir), where this repo's hook isn't relevant to commands operating on the added directory.

Verified empirically that Bash(git add *) matches git add as a substring (covers compound forms like cd subdir && git add .), so the script's blocking coverage is unchanged.

The `PreToolUse:Bash` hook invoked `enforce-git-hygiene.sh` on every Bash tool call, even though the script only blocks `git add . / -A / --all`. Add `"if": "Bash(git add *)"` so the script only runs when the command actually contains `git add`.
@netlify
Copy link
Copy Markdown

netlify Bot commented May 21, 2026

Deploy Preview for docsdocker ready!

Name Link
🔨 Latest commit b162a7a
🔍 Latest deploy log https://app.netlify.com/projects/docsdocker/deploys/6a0ec29b913ad50007e6de33
😎 Deploy Preview https://deploy-preview-25130--docsdocker.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant