/goal stop hook: 'JSON validation failed' when condition contains @file reference
Resolved 💬 1 comment Opened May 13, 2026 by avineshwar Closed May 13, 2026
Summary
Using /goal with an @filename reference in the condition string causes the session-scoped stop hook to fail with Stop hook error: JSON validation failed on every session stop attempt.
Environment
- Claude Code version: 2.1.140
- Platform: macOS (darwin arm64)
- Shell: zsh
Steps to Reproduce
- Run
/goal <some condition text that includes @FILENAME> - Attempt to stop the session
- Observe the error in the stop hook output
Example goal condition used:
using /ck: prefix commands as appropriate, ensure the @FEATURES.md tier 1 and tier 2 are fully built. A bunch of work has been done, and we must not redo work, but it must be tested.
Observed Behavior
Four stop hooks fire. Three complete successfully. The /goal condition hook fails:
Stop hook error: JSON validation failed
The session cannot stop cleanly. The goal never clears even after the condition is met.
Expected Behavior
The /goal stop hook should either:
- Resolve
@FEATURES.mdto its file contents when evaluating the condition, or - Treat unresolvable
@filereferences as plain text and evaluate the condition on available context
Either way, it should return valid JSON {"decision": "allow"|"block", "reason": "..."} rather than producing output that fails JSON schema validation.
Additional Context
- The error appears to be in the goal hook's own LLM evaluation output, not caused by other stop hooks interfering
- Other stop hooks (cavemem, cavekit loop driver, Warp notification) all exit cleanly with no stdout pollution
- The issue is specific to
@filesyntax in the goal condition — plain text conditions may work correctly (not verified) - The session-scoped stop hook appears to be a native Claude Code built-in, not a plugin
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗