Skip to content

PreToolUse and PostToolUse hooks loaded but never fire on Windows #25981

@Dany-Axhor

Description

@Dany-Axhor

Bug description

PreToolUse and PostToolUse hooks are correctly loaded (visible in /hooks) but never fire on Windows. The exact same configuration works perfectly on Linux.

UserPromptSubmit hooks work fine on both platforms.

Environment

  • OS: Windows 11 Pro 10.0.22631
  • Shell: Git Bash (bundled with Git for Windows)
  • Claude Code version: 2.1.42
  • Also tested on: Linux (Debian, same version 2.1.42) — works correctly

Configuration (~/.claude/settings.json)

{
  "hooks": {
    "UserPromptSubmit": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "bash ~/.claude/hooks/memory-inject.sh",
            "timeout": 5
          }
        ]
      }
    ],
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "echo \"$(date +%H:%M:%S) PreToolUse fired\" >> /tmp/hook-pre-debug.log",
            "timeout": 3
          }
        ]
      }
    ],
    "PostToolUse": [
      {
        "matcher": "Edit|Write|Bash",
        "hooks": [
          {
            "type": "command",
            "command": "echo \"$(date +%H:%M:%S) PostToolUse fired\" >> /tmp/hook-post-debug.log",
            "timeout": 3
          }
        ]
      }
    ]
  }
}

Steps to reproduce

  1. Configure PreToolUse and PostToolUse hooks in ~/.claude/settings.json (see config above)
  2. Start Claude Code on Windows (claude)
  3. Run /hooks — hooks are listed correctly as [User] Bash (PreToolUse) and [User] Edit|Write|Bash (PostToolUse)
  4. Ask Claude to run a Bash command (e.g., echo hello)
  5. Check log files — they are never created

Expected behavior

/tmp/hook-pre-debug.log and /tmp/hook-post-debug.log should be created with timestamps, as they are on Linux.

Actual behavior

  • Windows: Neither file is created. No error shown. Hooks silently don't fire.
  • Linux: Both files are created correctly (23:20:30 PreToolUse fired, 23:20:30 PostToolUse fired).

Investigation done

Check Result
/hooks shows hooks loaded Yes — [User] Bash and [User] Edit|Write|Bash displayed
JSON structure valid Yes — jq validates, same structure as working Linux config
UserPromptSubmit hook Works on Windows
PreToolUse hook Loaded but never fires on Windows, works on Linux
PostToolUse hook Loaded but never fires on Windows, works on Linux
Minimal debug hook (no matcher) Also doesn't fire on Windows
Manual command execution echo "test" >> /tmp/hook-pre-debug.log works fine in Git Bash
Settings override No project-level settings.json, no settings.local.json

Additional context

The hooks are loaded into Claude Code's internal registry (confirmed by /hooks UI), but the dispatch mechanism for tool-level events (PreToolUse, PostToolUse) appears to not trigger on Windows. Event-level hooks (UserPromptSubmit) work correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingplatform:windowsIssue specifically occurs on Windows

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions