Skip to content

date: 2026-06-11 tags: [hooks, pretooluse, paths, gate] status: active graduated_to:

PreToolUse file_path is absolute — relative prefix-matching never matches

Symptom — the brainstorm gate hook denied edits to the brainstorm's own record (docs/brainstorms/.../brainstorm.md), the one path its ALLOW_PREFIX explicitly permits.

Root cause — Claude Code passes tool_input.file_path as an absolute path (/home/user/Tempo/docs/...); the hook compared it against the relative ALLOW_PREFIX=docs/brainstorms/ with [[ "$target" != "$allow_prefix"* ]], so the prefix never matched and every allowed write was denied.

Fix — strip the project root before matching: rel="${target#"$PWD"/}" (.claude/hooks/gate.sh:124, fixed on main with gate.test.sh).

Guardgate.test.sh case 1 ("absolute path under ALLOW_PREFIX is allowed"). For every future hook: normalise tool_input paths against $CLAUDE_PROJECT_DIR/$PWD before any prefix/equality comparison — assume absolute, never relative.