The original hook syntax `blue guard --path="$TOOL_INPUT:file_path"` didn't work - Claude Code doesn't support that variable interpolation. Created guard-write.sh that: - Reads JSON from stdin using jq (Claude Code's recommended pattern) - Extracts file_path from tool_input - Calls blue guard with full path to target/release binary - Closes stdin with </dev/null to prevent hanging The full binary path is a workaround for an issue where PATH-based command lookup hangs in Claude Code's hook subprocess environment. A proper fix (making guard synchronous before tokio::main) is tracked in RFC 0049. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
15 lines
244 B
JSON
15 lines
244 B
JSON
{
|
|
"hooks": {
|
|
"PreToolUse": [
|
|
{
|
|
"matcher": "Write|Edit|MultiEdit",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": ".claude/hooks/guard-write.sh"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|