Skip to content

v1.2.0 — critical hook fix

Choose a tag to compare

@summerliuuu summerliuuu released this 16 Apr 15:02
· 2 commits to main since this release

Critical fix — please upgrade

Earlier releases shipped a settings.json template that referenced environment variables ($CLAUDE_TOOL_NAME / $CLAUDE_USER_PROMPT) that do not exist in Claude Code's hook contract. Hook context is delivered as a JSON payload on stdin. Every previous install has been silently writing empty TOOL_FAIL | failed lines to error_log.md, and the user-correction detector never matched anything.

If you installed v1.0 or v1.1, upgrade now. See CHANGELOG.md for the full migration path.

What's new

Fixed

  • settings.json hook template rewritten to parse stdin JSON correctly
  • UserPromptSubmit no longer false-triggers on past-work memory injected as <system-reminder> context (closed-loop pollution)
  • UserPromptSubmit no longer false-triggers on code blocks / quoted strings that contain a correction phrase
  • Python regex \b word-boundary bug on mixed CJK/ASCII text fixed (replaced with ASCII-only lookarounds)
  • macOS smart-quote auto-correct (that'sthat's) now matched correctly

Added

  • hooks/user_prompt_filter.py — standalone Python stdin parser with XML / code-block stripping, smart-quote normalisation, tight second-person pattern list
  • hooks/post_tool_failure.sh — standalone bash stdin parser using jq, with graceful degradation if jq is missing
  • Two new tracked dimensions (18 total):
    • Real-env Verification — did you validate with the real production command, or just a sandbox harness?
    • Cross-agent Trust — did you independently re-verify another agent's "pass" report?
  • Gate 2 strengthened: shell/hook changes must be verified with the exact command string from settings.json, not a locally-equivalent variant
  • Gate 3 strengthened: for changes reviewed by a second agent, re-run verification in your own environment — a sandbox pass is not a real-environment pass

Changed

  • Mechanism 6 documentation rewritten with stdin JSON contract up-front
  • Gate 2 post-edit verification reminder clarified as agent-enforced (it lives in the AI's instructions, not a stateless shell hook)

Migration from v1.1.0

mkdir -p ~/.claude/hooks
cp hooks/user_prompt_filter.py ~/.claude/hooks/
cp hooks/post_tool_failure.sh ~/.claude/hooks/
chmod +x ~/.claude/hooks/post_tool_failure.sh

Then replace the PostToolUseFailure and UserPromptSubmit blocks in ~/.claude/settings.json with the new versions from SKILL.md → Mechanism 6 → Settings.json format.

Optionally clean old noise from ~/.claude/memory/error_log.md — entries like TOOL_FAIL | failed with empty fields came from the broken template and can be safely deleted.

Prerequisites

  • python3 (UserPromptSubmit filter) — ships by default on recent macOS + most Linux
  • jq (PostToolUseFailure parser) — brew install jq on macOS

Both hooks degrade gracefully if the binary is missing.