[BUG] Hookify plugin fails with 'Invalid \escape' JSON error on Windows due to unescaped backslashes in file paths

Resolved 💬 3 comments Opened Jan 22, 2026 by xiaobei930 Closed Feb 28, 2026

Bug Description

The hookify plugin's PreToolUse hook fails on Windows with a JSON parse error when processing file paths containing backslashes.

Error message:

PreToolUse:Read says: Hookify error: Invalid \escape: line 1 column 372 (char 371)

Root Cause Analysis

When Claude Code invokes the PreToolUse:Read hook, it passes JSON data containing Windows file paths (e.g., C:\Users\username\file.txt). The issue is:

  1. Windows paths use backslashes (\) as path separators
  2. In JSON, backslashes must be escaped as \
  3. Sequences like \U (from \Users) or \k are interpreted as invalid escape sequences
  4. Python's json.loads() in pretooluse.py:40 fails to parse the JSON

Location of the issue: The JSON data passed to the hook stdin contains unescaped Windows paths.

Steps to Reproduce

  1. Use Claude Code on Windows
  2. Enable the hookify plugin (hookify@claude-plugins-official)
  3. Have any hookify rules configured (e.g., in .claude/hookify.*.local.md)
  4. Trigger a Read tool operation on any file
  5. Observe the error: Hookify error: Invalid \escape: line 1 column 372 (char 371)

Expected Behavior

The JSON data passed to hooks should have properly escaped backslashes in file paths:

  • Wrong: {"file_path": "C:\Users\koala\file.txt"}
  • Correct: {"file_path": "C:\Users\koala\file.txt"}

Environment

| Field | Value |
|-------|-------|
| Claude Code Version | Latest |
| OS | Windows 11 (MSYS_NT-10.0-22631) |
| Platform | win32 |
| Shell | Git Bash / MSYS2 |

Related Issues

  • #15481 - Windows paths with spaces issue
  • #16152 - Hooks fail when user path contains spaces
  • #13612 - hookify import error

Suggested Fix

Ensure that file paths in the JSON data passed to hooks are properly JSON-escaped before being sent to stdin. This likely needs to be fixed in Claude Code's hook invocation code, not in the hookify plugin itself.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗