Skip to content

Instantly share code, notes, and snippets.

@obormot
Last active May 31, 2026 07:25
Show Gist options
  • Select an option

  • Save obormot/9a241032c72c4d19a259f8bce6fa8ed3 to your computer and use it in GitHub Desktop.

Select an option

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
#!/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."
}'
"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