Last active
May 31, 2026 07:25
-
-
Save obormot/9a241032c72c4d19a259f8bce6fa8ed3 to your computer and use it in GitHub Desktop.
Claude Code hook that warns the user about /security-review being affected by model anchoring bias
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
| #!/usr/bin/env bash | |
| # Warns when /security-review is run in a long-running session (model anchoring bias risk). | |
| # the solution counts the number of conversation turns in the LLM session transcript and | |
| # blocks the `security-review` invocation if the count exceeds 8, using that as a heuristic | |
| # signal that this is a long-running session rather than a fresh review | |
| input=$(cat) | |
| echo "$input" | jq -r '.prompt // ""' | grep -qi "security-review" || exit 0 | |
| transcript=$(echo "$input" | jq -r '.transcript_path // ""') | |
| turns=$(jq -s '[.[] | select(.type == "user" and .userType == "external")] | length' "$transcript" 2>/dev/null || echo 0) | |
| [ "${turns:-0}" -gt 8 ] || exit 0 | |
| echo '{ | |
| "decision":"block", | |
| "reason":"⚠️ Model anchoring bias: this session has history. For an unbiased security review, open a fresh session and run /security-review there." | |
| }' |
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": { | |
| "UserPromptSubmit": [{ | |
| "hooks": [{ "type": "command", "command": "/path/to/security-review-warn.sh", "timeout": 5 }] | |
| }] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment