You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(agents): prefer-github-mcp hook can be bypassed by global flags or separators #138
.claude/hooks/prefer-github-mcp.sh matches (^|\s)gh\s+(pr|issue|search)(\s|$). That pattern misses several equivalent invocations:
a global flag before the subcommand, such as gh -R owner/repo pr view 1 or gh --repo x issue list;
a separator with no space before gh, such as true;gh pr view 1, x&&gh issue list or (gh pr checks);
an absolute path or wrapper, such as /opt/homebrew/bin/gh pr view or env gh pr view.
So the repo's "prefer GitHub MCP" policy is advisory, not enforced. The #137 review surfaced this. #137's hook test only certifies the hook as written.
Proposed fix
Tokenise the command, splitting on ;, &&, ||, |, ( and newlines. For each segment, find a gh executable (bare name or a path ending in /gh), skip global flags (-R/--repo <x> and --hostname <x>), and check the subcommand.
Extend scripts/test-agent-hooks.sh with negative cases for each bypass above.
Acceptance
Each listed form is denied, and gh run … and gh api … are still allowed.
Activity