[BUG] PreToolUse and PostToolUse hooks not triggering on WSL2 despite correct configuration

Resolved 💬 8 comments Opened Jul 9, 2025 by ruslanvasylev Closed Jul 28, 2025

Environment

  • Platform (select one):
  • [X] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other:
  • Claude CLI version: 1.0.44 (Claude Code)
  • Operating System: Linux 5.15.167.4-microsoft-standard-WSL2
  • Terminal: Windows Terminal with WSL2

Bug Description

PreToolUse and PostToolUse hooks are not being triggered during tool use, despite following the documentation and having what appears to be correct configuration. The hooks are properly configured in .claude/settings.local.json with appropriate matchers, but they never execute when tools are used.

Steps to Reproduce

  1. Configure hooks in .claude/settings.local.json with the following structure:
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash|Task|Read|Write|Edit|MultiEdit|Grep|Glob|LS|WebFetch|TodoRead|TodoWrite|NotebookRead|NotebookEdit|WebSearch",
        "hooks": [
          {
            "type": "command",
            "command": "/home/ruslan/.local/bin/uv run .claude/hooks/pre_tool_use.py"
          }
        ]
      }
    ],
    "PostToolUse": [
      {
        "matcher": "Bash|Task|Read|Write|Edit|MultiEdit|Grep|Glob|LS|WebFetch|TodoRead|TodoWrite|NotebookRead|NotebookEdit|WebSearch",
        "hooks": [
          {
            "type": "command",
            "command": "/home/ruslan/.local/bin/uv run .claude/hooks/post_tool_use.py"
          }
        ]
      }
    ]
  }
}
  1. Ensure hook scripts exist and are executable
  2. Start Claude Code session: claude
  3. Use any tool (e.g., execute a Bash command)
  4. Check hook logs - no new entries are created

Expected Behavior

  • PreToolUse hook should execute before each tool invocation
  • PostToolUse hook should execute after each tool invocation
  • Hook scripts should log tool usage to JSON files
  • Hook processes should be visible in process list during execution

Actual Behavior

  • Hook scripts are never executed
  • Log files remain unchanged (last modified timestamp doesn't update despite active tool use)
  • No hook processes appear in process list during tool execution
  • Hook configuration appears to be ignored completely

Additional Context

  • Initially tried with empty matchers ("matcher": "") based on examples, which didn't work
  • Updated to explicit tool names based on issue #3091, still doesn't work
  • Tested in multiple modes: debug mode, normal mode, isolated session - same result
  • Hook scripts execute successfully when run manually from command line
  • Notification hooks appear to work (TTS processes visible), but PreToolUse/PostToolUse do not
  • Settings precedence was verified by consolidating to single .claude/settings.local.json file
  • Similar to issue #3091 but configuration appears to match recommended format

View original on GitHub ↗

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