feat(claude): proactively advise agents on protected branches before they act#622
Merged
NagyVikt merged 1 commit intoJun 3, 2026
Conversation
…they act Every gitguardex guard is reactive: skill_guard.py (PreToolUse) and the pre-commit hook only fire once an agent ATTEMPTS a blocked action, so an agent on main stages -> commit -> blocked -> tries to branch -> blocked, bouncing wall to wall. There was no proactive signal of branch state. Add .claude/hooks/agent_branch_advisor.py, wired into SessionStart and UserPromptSubmit. On a protected branch (dev/main/master + configured extras) it injects, via hookSpecificOutput.additionalContext at exit 0, an advisory naming the branch and the sanctioned `gx branch start` command -- so the agent's first move is to open an isolated worktree. - Silent on agent/* branches and non-protected branches (zero noise). - Fail-open: bad stdin, missing/old skill_guard, git error, or GUARDEX_ON=0 -> no output, exit 0. Always exit 0 (UserPromptSubmit exit 2 rejects the prompt -- advise, never block). - Imports branch/protection predicates from the sibling skill_guard.py so the advisory can never disagree with what the guards enforce. - Added to MANAGED_HOOK_FILES so `gx claude install` distributes it (the pre-existing scripts/agent-stalled-report.sh is NOT distributed; the advisor deliberately avoids that gap). Verify: node --test test/claude-install.test.js -> 14/14 (2 new); advisor runtime silent on agent branch, correct per-event advisory JSON on main, fail-open on malformed stdin and GUARDEX_ON=0; full suite failing set unchanged vs main (33 == 33, byte-identical).
NagyVikt
added a commit
that referenced
this pull request
Jun 3, 2026
…k hook executable (#623) PR #622 added agent_branch_advisor.py to the install template but left this repo's own tracked .claude/settings.json stale -- it shipped the advisory to other repos via `gx claude install` yet never wired gitguardex's own sessions. Regenerate settings.json so this repo's agent sessions also get the SessionStart + UserPromptSubmit advisory. Also chmod the advisor 0644->0755 to match every sibling managed hook and clear the `gx claude check` hook-not-executable warning. Co-authored-by: NagyVikt <nagy.viktordp@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Automated by gx branch finish (PR flow).