claude-code - 💡(How to fix) Fix /goal stop hook: 'JSON validation failed' when condition contains @file reference [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#58712Fetched 2026-05-14 03:41:25
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
0
Participants
Timeline (top)
labeled ×4closed ×1mentioned ×1

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.

Error Message

Stop hook error: JSON validation failed

Root Cause

  • 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 @file syntax 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

Code Example

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.

---

Stop hook error: JSON validation failed
RAW_BUFFERClick to expand / collapse

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

  1. Run /goal <some condition text that includes @FILENAME>
  2. Attempt to stop the session
  3. 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.md to its file contents when evaluating the condition, or
  • Treat unresolvable @file references 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 @file syntax 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

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING