# Hooks Gotchas ## PreCompact hook no longer receives `transcript_path` in JSON input **Symptom:** `pre-compact-backup.sh` silently skipped every run — no backup file produced, no error. **Cause:** Claude Code's PreCompact hook JSON input no longer includes `transcript_path` (changed from older versions). The hook was reading an empty value and short-circuiting. **Fix:** Derive the transcript path from `session_id` and `cwd` instead: `~/.claude/projects/$(echo "$cwd" | tr '/' '-')/.jsonl`. Both fields are still present in the hook input JSON. ## Hooks fail silently under `set -e` when an input field is missing **Symptom:** Hook appears to run (exit 0) but produces no output or side effects. **Cause:** A missing jq-extracted field returns empty, then subsequent commands operate on the empty string and either no-op or skip conditional branches without error. **Fix:** Always validate required inputs early in the hook: `if [ -z "$session_id" ] || [ -z "$cwd" ]; then echo "missing input" >&2; exit 1; fi`. Log failures to stderr so they surface in Claude Code hook diagnostics.