Created
June 23, 2026 12:56
-
-
Save zircote/efd9ef94c303de3137562218c8ed74f8 to your computer and use it in GitHub Desktop.
Claude Hook Config to suggest /code-review before opening a PR
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
| { | |
| "hooks": { | |
| "PreToolUse": [ | |
| { | |
| "matcher": "Bash|mcp__github__create_pull_request", | |
| "hooks": [ | |
| { | |
| "type": "command", | |
| "command": "input=$(cat); tool=$(printf \"%s\" \"$input\" | jq -r \".tool_name // \\\"\\\"\"); bash_cmd=$(printf \"%s\" \"$input\" | jq -r \".tool_input.command // \\\"\\\"\"); sid=$(printf \"%s\" \"$input\" | jq -r \".session_id // \\\"default\\\"\"); is_pr=0; [ \"$tool\" = \"mcp__github__create_pull_request\" ] && is_pr=1; { [ \"$tool\" = \"Bash\" ] && printf \"%s\" \"$bash_cmd\" | grep -Eq \"gh[[:space:]]+pr[[:space:]]+create\"; } && is_pr=1; if [ \"$is_pr\" = \"1\" ]; then marker=\"${TMPDIR:-/tmp}/claude-pr-review-suggested-${sid}\"; if [ ! -f \"$marker\" ]; then : > \"$marker\"; printf \"%s\" \"{\\\"hookSpecificOutput\\\":{\\\"hookEventName\\\":\\\"PreToolUse\\\",\\\"permissionDecision\\\":\\\"deny\\\",\\\"permissionDecisionReason\\\":\\\"Suggestion (not a hard gate): consider running /code-review on this branch before opening the PR, then re-issue the PR. You decide \u2014 if the change is trivial, already reviewed, or the user asked to skip review, just re-run the PR creation to proceed. This advisory fires only once per session.\\\"}}\"; fi; fi", | |
| "statusMessage": "Suggesting /code-review before PR\u2026" | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment