Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .claude/hooks/guard.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# Claude Code PreToolUse hook shim.
# Delegates to vrg-hook-guard if available; falls back to a
# jq-based git/gh check that hard-denies when vergil-tooling
# is not installed.
set -euo pipefail

if command -v vrg-hook-guard &>/dev/null; then
exec vrg-hook-guard
fi

input=$(cat)
command=$(printf '%s' "$input" | jq -r '.tool_input.command // empty')
bin=$(printf '%s' "$command" | awk '{print $1}')
base=$(basename "$bin" 2>/dev/null || printf '%s' "$bin")

case "$base" in
git|gh)
jq -n '{
hookSpecificOutput: {
hookEventName: "PreToolUse",
permissionDecision: "deny",
permissionDecisionReason: "vergil-tooling is not available. This repository requires a correctly configured environment — all git/gh operations are blocked until resolved."
}
}'
exit 0
;;
esac

exit 0
18 changes: 18 additions & 0 deletions .claude/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
{
"permissions": {
"allow": [
"Bash(vrg-*)"
]
},
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/guard.sh"
}
]
}
]
},
"extraKnownMarketplaces": {
"vergil-marketplace": {
"source": {
Expand Down
6 changes: 3 additions & 3 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ This is a documentation-only repository. There are no build or test commands.

### Environment Setup

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

VERGIL CLI tools (`vrg-commit`, `vrg-validate`, etc.) are
pre-installed in the dev container images. No local setup required.
Expand Down
2 changes: 1 addition & 1 deletion docs/repository-standards.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
- Before modifying any files, check the current branch with `git status -sb`.
- If on `develop`, create a short-lived `feature/*` branch or ask for explicit approval to proceed on `develop`.
- If approval is granted to work on `develop`, call it out in the response and proceed only for that user-approved scope.
- Enable repository git hooks before committing: `git config core.hooksPath .githooks`.
- The Claude Code hook guard (`.claude/hooks/guard.sh`) blocks raw `git`/`gh` — use `vrg-git`/`vrg-gh`.

## Local validation

Expand Down
10 changes: 4 additions & 6 deletions fragments/development/quality-gates.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ and CI pipelines enforce the same standards (plus additional checks) on
every pull request. Pull requests cannot merge until all required jobs
pass.

## Git hooks
## Claude Code hook guard

Git hooks are stored in `scripts/git-hooks/` and activated with:

```bash
git config core.hooksPath scripts/git-hooks
```
The `.claude/hooks/guard.sh` PreToolUse hook blocks raw `git` and
`gh` commands in AI agent sessions — all operations must go through
the `vrg-git` / `vrg-gh` wrappers.

### pre-commit

Expand Down