claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Post/PreToolUse Hooks Not Executing in Claude Code

Open fwends opened this issue 4 months ago • 17 comments

Bug Report for Anthropic - Claude Code Hook System

Issue: PreToolUse and PostToolUse Hooks Not Executing

Environment:

  • Claude Code Version: claude-sonnet-4-20250514
  • Platform: macOS Darwin 24.6.0
  • Configuration: .claude/settings.local.json

Problem: PreToolUse and PostToolUse hooks are configured correctly but never execute, while other hook types work perfectly.

Evidence:

✅ WORKING HOOKS:

  • Stop hooks execute consistently (proven by debug logs showing 50+ executions)
  • SubagentStop hooks work (sound notifications trigger)
  • UserPromptSubmit hooks work (manual /aw command functions)

❌ BROKEN HOOKS:

  • PreToolUse hooks never execute despite proper configuration
  • PostToolUse hooks never execute despite proper configuration

Configuration Tested: { "hooks": { "PreToolUse": [ { "matcher": "Bash", "hooks": [ { "type": "command", "command": "echo 'PreToolUse triggered' >> /tmp/pretool-test.log" } ] } ], "PostToolUse": [ { "matcher": "Bash", "hooks": [ { "type": "command", "command": "cat /Users/greg/codebase/stayinpattaya/.claude/commands/aw.md" } ] } ] } }

Testing Performed:

  1. Verified hook scripts execute correctly when run manually
  2. Tested multiple matchers: "*", "Bash", "Task", "Write", "Edit"
  3. Tested both simple commands and complex scripts
  4. Confirmed proper JSON input handling with jq parsing
  5. Verified file permissions and absolute paths
  6. Cleared logs and performed fresh tests
  7. Compared working Stop hook configuration (identical format)

Expected Behavior: PreToolUse and PostToolUse hooks should execute before/after tool usage and show output or create logs.

Actual Behavior: Tool-related hooks never execute. No output displayed, no log files created, no evidence of execution.

Conclusion: PreToolUse and PostToolUse hook events are not being fired by Claude Code, despite proper configuration following official documentation. Other hook types (Stop, SubagentStop, UserPromptSubmit) function correctly using identical configuration patterns.

This appears to be a selective hook system failure affecting only tool-related events.

fwends avatar Aug 22 '25 04:08 fwends