Skip to content

Commit 99b2d72

Browse files
chore(hooks): add Claude Code hook guard, scrub legacy hooksPath refs (#509)
Add .claude/hooks/guard.sh PreToolUse hook, update settings.json with hook wiring and permissions, update docs.
1 parent 5165680 commit 99b2d72

6 files changed

Lines changed: 55 additions & 7 deletions

File tree

.claude/hooks/guard.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
# Claude Code PreToolUse hook shim.
3+
# Delegates to vrg-hook-guard if available; falls back to a
4+
# jq-based git/gh check that hard-denies when vergil-tooling
5+
# is not installed.
6+
set -euo pipefail
7+
8+
if command -v vrg-hook-guard &>/dev/null; then
9+
exec vrg-hook-guard
10+
fi
11+
12+
input=$(cat)
13+
command=$(printf '%s' "$input" | jq -r '.tool_input.command // empty')
14+
bin=$(printf '%s' "$command" | awk '{print $1}')
15+
base=$(basename "$bin" 2>/dev/null || printf '%s' "$bin")
16+
17+
case "$base" in
18+
git|gh)
19+
jq -n '{
20+
hookSpecificOutput: {
21+
hookEventName: "PreToolUse",
22+
permissionDecision: "deny",
23+
permissionDecisionReason: "vergil-tooling is not available. This repository requires a correctly configured environment — all git/gh operations are blocked until resolved."
24+
}
25+
}'
26+
exit 0
27+
;;
28+
esac
29+
30+
exit 0

.claude/settings.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(vrg-*)"
5+
]
6+
},
7+
"hooks": {
8+
"PreToolUse": [
9+
{
10+
"matcher": "Bash",
11+
"hooks": [
12+
{
13+
"type": "command",
14+
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/guard.sh"
15+
}
16+
]
17+
}
18+
]
19+
},
220
"extraKnownMarketplaces": {
321
"vergil-marketplace": {
422
"source": {

CLAUDE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ All fields are required.
9898

9999
### Standard Tooling
100100

101-
```bash
102-
git config core.hooksPath ../vergil-tooling/scripts/lib/git-hooks # Enable git hooks
103-
```
101+
The Claude Code PreToolUse hook guard (`.claude/hooks/guard.sh`)
102+
blocks raw `git` and `gh` commands — use `vrg-git` / `vrg-gh`
103+
wrappers.
104104

105105
VERGIL CLI tools (`vrg-commit`, `vrg-validate`, etc.) are
106106
pre-installed in the dev container images. No local setup required.

docs/repository-standards.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
- Before modifying any files, check the current branch with `git status -sb`.
1616
- If on `develop`, create a short-lived `feature/*` branch or ask for explicit approval to proceed on `develop`.
1717
- If approval is granted to work on `develop`, call it out in the response and proceed only for that user-approved scope.
18-
- Enable repository git hooks before committing: `git config core.hooksPath .githooks`.
18+
- The Claude Code hook guard (`.claude/hooks/guard.sh`) blocks raw `git`/`gh` — use `vrg-git`/`vrg-gh`.
1919

2020
## Local validation
2121

docs/site/docs/development/developer-setup.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ cd pymqrest
5555
# Install all dependencies including dev group
5656
uv sync --group dev
5757

58-
# Enable repository git hooks
59-
git config core.hooksPath scripts/git-hooks
58+
# The Claude Code hook guard (.claude/hooks/guard.sh) blocks raw
59+
# git/gh commands — use vrg-git / vrg-gh wrappers.
6060
```
6161

6262
## Running validation

docs/standards-compliance-gates.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Blocks commits on protected branches (`develop`, `release`, `main`,
3434
`release/*`) and enforces branch naming prefixes (`feature/*`, `bugfix/*`,
3535
`hotfix/*`).
3636

37-
Enable with: `git config core.hooksPath scripts/git-hooks`
37+
Enforcement is now handled by the Claude Code hook guard (`.claude/hooks/guard.sh`).
3838

3939
### Commit message hook
4040

0 commit comments

Comments
 (0)