[BUG] PostToolUse hook with tool-specific matcher runs for all tools

Resolved 💬 3 comments Opened Jan 23, 2026 by zeemawn Closed Feb 28, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

A PostToolUse hook configured with "matcher": "Bash" shows PostToolUse:Read hook error after every Read and Glob tool call. The matcher should prevent the hook from being evaluated for non-Bash tools entirely.

Configuration (.claude/settings.json):

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/after-e2e.sh"
          }
        ]
      }
    ]
  }
}

What I see in the CLI:

⏺ Read(package.json)
  ⎿  Read 51 lines
  ⎿  PostToolUse:Read hook error

⏺ Read(src/App.tsx)
  ⎿  Read 37 lines
  ⎿  PostToolUse:Read hook error

⏺ Search(pattern: "src/**/*.tsx")
  ⎿  Found 33 files

The hook script handles non-Bash tools gracefully (exits 0 when no command field in input), verified manually:

$ echo '{"file_path": "/foo/bar"}' | .claude/hooks/after-e2e.sh && echo "exit 0"
exit 0

What Should Happen?

Hooks with a tool-specific matcher (e.g., "Bash") should not be evaluated at all for other tools (Read, Glob, Write, etc.). No output or error should appear for unmatched tools.

Error Messages/Logs

PostToolUse:Read hook error

(Appears after every Read/Glob operation, despite matcher being set to "Bash")

Steps to Reproduce

  1. Create .claude/settings.json with a PostToolUse hook that has "matcher": "Bash"
  2. Create a hook script that exits 0 for non-git-push commands
  3. Ask Claude to read any file
  4. Observe "PostToolUse:Read hook error" in output

Claude Model

Opus

Is this a regression?

Unknown

Claude Code Version

1.0.33

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app

Additional Information

This may be related to #17088 (error label shown for successful hooks), but the core issue here is that the matcher is not filtering tool types - the hook shouldn't run at all for Read tools when matcher is "Bash".

View original on GitHub ↗

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