[BUG] PreToolUse and PostToolUse hooks not triggering on WSL2 despite correct configuration
Status Fixed / completed
Maintainer reply ✓ Yes — dicksontsai
Workaround ✓ Mentioned in thread ↓
Activity 8 comments · opened Jul 9, 2025 · closed Jul 28, 2025
💡 Likely answer: A maintainer (dicksontsai, collaborator)
responded on this thread — see the highlighted reply below.
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
- Configure hooks in
.claude/settings.local.jsonwith 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"
}
]
}
]
}
}
- Ensure hook scripts exist and are executable
- Start Claude Code session:
claude - Use any tool (e.g., execute a Bash command)
- 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.jsonfile - Similar to issue #3091 but configuration appears to match recommended format
8 Comments
Do you see them detected when you run
/hooksand navigate toPreToolUseorPostToolUse?@ruslanvasylev check here
https://github.com/jackstine/claude_tools/tree/main/hooks
Confirming the same bug on macOS
I can confirm this exact same issue on macOS with the same symptoms:
Environment:
Symptoms (identical to the original report):
/hookscommand)Testing performed:
/hooksinterface.claude/settings.local.jsonuv run"*"and specific tool matchersKey observation:
The fact that Notification hooks work but PreToolUse/PostToolUse don't suggests this is a specific bug in Claude Code 1.0.44's hook execution system for these particular hook types.
Workaround:
Currently using Notification hooks as a temporary solution since they function correctly.
This confirms the bug affects multiple platforms (WSL2/Linux and macOS), making it likely a core issue in Claude Code 1.0.44 rather than platform-specific.
I'm using 1.0.52 on WSL. The problem still exist.
The first example is copy from the doc here: https://docs.anthropic.com/en/docs/claude-code/hooks-guide#code-formatting-hook
The second one do works.
I give a second try.
The second command works too. The first one still not run.
My third trial.
The first command still not run.
I finally made it. This is the correct PostToolUse setup.
The previous command I tried and copied form Claude Code doc is wrong. The behavior is the Claude Code piping the hook payload to the command. So that I have to read the pipe and complete the whole thing in one statement.
@ericharmeling Can you look at the doc example and see if it needs to be updated?
$(.tool_input.file_path)syntax doesn't seem to work for everyone.Same issue and fix as @doggy8088 here on v1.0.61 in WSL2. Thanks for the fix.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.