Files
claude-foundations/memory/gotchas-hooks.md
Paul O'Reilly f41c22d0ac Add question-reframing guidance to CLAUDE.md; commit accumulated project files
- CLAUDE.md: add "Question the question" and "One clarifying question" rules
  to Tone and Interaction — XY problem detection, false premise checks, and
  explicit reframe pattern before answering
- Add claude/ detail-file directory (topic docs referenced from CLAUDE.md)
- Add ABOUT.md, FUTURE.md
- Update memory/, scripts/, settings.yaml with accumulated session changes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-25 09:37:28 +12:00

1.1 KiB

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 '/' '-')/<session_id>.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.