PreToolUse hooks not executing at all in Claude Code

Resolved 💬 2 comments Opened Jul 17, 2025 by cobach Closed Jul 17, 2025

PreToolUse hooks not executing at all in Claude Code

Environment

  • Claude Code Version: 1.0.53 (npm-local)
  • Operating System: macOS Darwin 24.5.0
  • Node.js Version: v22.17.0

Bug Description

PreToolUse hooks are not executing at all, despite following various configuration formats suggested by error messages. Additionally, claude doctor reports configuration errors regardless of the format used.

Reproduction Steps

  1. Create /Users/cesar/.claude/settings.json with the following configuration:
{
  "hooks": {
    "preToolUse": [
      {
        "matcher": {},
        "hooks": [
          {
            "type": "command",
            "command": "~/.claude/wing-coding/check-log-time.sh"
          }
        ]
      }
    ]
  }
}
  1. Create a test script at ~/.claude/wing-coding/check-log-time.sh:
#!/bin/bash
echo "Hook executed at $(date)" >> /tmp/claude-hook-test.log
  1. Make the script executable:
chmod +x ~/.claude/wing-coding/check-log-time.sh
  1. Run claude doctor and observe the error:
Invalid Settings
/Users/cesar/.claude/settings.json
└ hooks
  └ preToolUse: Expected array, but received object
  1. Use any Claude tool (e.g., ls, grep, read)
  1. Check if the hook executed:
cat /tmp/claude-hook-test.log
# File does not exist - hook never executed

Expected Behavior

  • The hook script should execute before each tool use
  • claude doctor should accept valid hook configurations
  • A log entry should be created in /tmp/claude-hook-test.log

Actual Behavior

  • Hook never executes under any configuration
  • claude doctor rejects all configuration formats tried
  • No log file is created, indicating the hook is never called

Additional Context

  • This appears related to issue #3514 which reported similar problems in v1.0.51
  • The bug persists in v1.0.53, indicating it hasn't been fixed
  • Tried multiple configuration formats based on error message suggestions:
  • With hooks wrapper object
  • With capitalized PreToolUse key
  • With and without matchers
  • The hook script works correctly when executed manually

Impact

This prevents users from implementing critical workflow automation and monitoring features via hooks, which is essential for production use cases.

Full File Contents

Current settings.json

{
  "PreToolUse": [
    {
      "matcher": {},
      "hooks": [
        {
          "type": "command",
          "command": "~/.claude/wing-coding/check-log-time.sh"
        }
      ]
    }
  ]
}

Hook script (check-log-time.sh)

#!/bin/bash
echo "Hook executed at $(date)" >> /tmp/claude-hook-test.log

Claude doctor output

Claude CLI Diagnostic
 Currently running: npm-local (1.0.53)
 Path: /Users/cesar/.nvm/versions/node/v22.17.0/bin/node
 Invoked: /Users/cesar/.claude/local/node_modules/.bin/claude
 Config install method: local
 Auto-updates enabled: true

 Invalid Settings
 /Users/cesar/.claude/settings.json
  └ hooks
    └ preToolUse: Expected array, but received object

 Hooks use a new format with matchers. Example: {"PostToolUse": [{"matcher": {"tools": ["BashTool"]}, "hooks": [{"type": 
 "command", "command": "echo Done"}]}]}
 Learn more: https://docs.anthropic.com/en/docs/claude-code/hooks

---

This issue report was generated collaboratively using Wing Coding methodology - a human-AI pair programming approach where César (human pilot) directs Claude (AI wingman) in real-time development sessions. Wing Coding combines human architectural vision with AI implementation capabilities to achieve 3-5x development velocity. Learn more: Wing Coding on LinkedIn

View original on GitHub ↗

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