Skip to content

Commit 1eadb90

Browse files
Haikaneclaude
andcommitted
Fix Stop hook example prompt to prevent JSON parsing failures
The anti-rationalization Stop hook example uses a prompt hook evaluated by Haiku. Without an explicit formatting constraint, Haiku wraps the JSON response in markdown code fences or adds explanatory text, which fails JSON parsing and silently breaks the hook. Fix the example prompt to prepend a JSON-only output instruction and add a timeout. Document the pitfall so others don't hit it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent df8374d commit 1eadb90

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ On Linux, replace the command with `notify-send 'Claude Code' 'Claude needs your
307307
"hooks": [
308308
{
309309
"type": "prompt",
310-
"prompt": "Review the assistant's final response. Reject it if the assistant is rationalizing incomplete work. Common patterns: claiming issues are 'pre-existing' or 'out of scope' to avoid fixing them, saying there are 'too many issues' to address all of them, deferring work to a 'follow-up' that was not requested, listing problems without fixing them and calling that done, or skipping test/lint failures with excuses. If the response shows any of these patterns, respond {\"ok\": false, \"reason\": \"You are rationalizing incomplete work. [specific issue]. Go back and finish.\"}. If the work is genuinely complete, respond {\"ok\": true}."
310+
"prompt": "You are a JSON-only evaluator. You MUST respond with a single JSON object and NOTHING else. No markdown, no code fences, no explanation, no preamble. Just the raw JSON object.\n\nReview the assistant's final response. Reject if the assistant is rationalizing incomplete work: claiming issues are 'pre-existing' or 'out of scope', saying 'too many issues' to fix, deferring to unrequested 'follow-ups', listing problems without fixing them, or skipping test/lint failures with excuses.\n\nIf any of those patterns apply, respond:\n{\"ok\": false, \"reason\": \"You are rationalizing incomplete work. [specific issue]. Go back and finish.\"}\n\nOtherwise respond:\n{\"ok\": true}",
311+
"timeout": 30
311312
}
312313
]
313314
}
@@ -317,6 +318,8 @@ On Linux, replace the command with `notify-send 'Claude Code' 'Claude needs your
317318

318319
This uses `type: "prompt"` instead of `type: "command"` -- Claude Code sends the hook's prompt plus the assistant's response to a fast model (Haiku), which returns a yes/no judgment. If rejected, the `reason` is fed back to Claude as its next instruction, forcing it to continue.
319320

321+
**Important:** The prompt must explicitly instruct the evaluator to respond with raw JSON only. Without this, Haiku wraps the JSON in markdown code fences or adds explanatory text, which fails JSON parsing and silently breaks the hook.
322+
320323
### Plugins and Skills
321324

322325
Claude Code's capabilities come from plugins, which provide skills (reusable workflows), agents (specialized subagents), and commands (slash commands). Plugins are distributed through marketplaces.

0 commit comments

Comments
 (0)