[BUG] Detailed transcript for "Edit|Write" hook says "2 PostToolUse hooks ran", but only 1 hook actually ran (once)
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?
My PostToolUse hook runs 1 time for each file edit, exactly as intended. However, the Claude detailed transcript (opened with Ctrl-O) says, "2 PostToolUse hooks ran". The bug is the incorrect transcript message.
I confirmed (by adding logging to the formatter) that the hook only runs once. There is no other hook installed; /hooks shows "1 hook configured" at the top (i.e. 1 hook across all types).
The matcher line is "matcher": "Edit|Write",.
I ran the verbose logger as follows:
pwsh -Command { $env:CLAUDE_CODE_DEBUG_LOG_LEVEL = 'verbose'; claude --debug-file 'some_filename.log' --resume 'some_session_name' }
That shows inconsistent information, such as:
- "[VERBOSE] Matched 2 unique hooks for query "Write" (2 before deduplication)"
- "[DEBUG] Hook output does not start with {, treating as plain text" (only once, suggesting it's actually only called once)
- "PostToolUse hook modified C:\[Redacted] after Write — re-synced readFileState" (again, only once)
Background:
I wrote a simple hook very similar to "Auto-format code after edits", but setting "powershell" as the shell and using a custom PowerShell formatter script (not Prettier).
As with the Prettier example, the matcher is "matcher": "Edit|Write",.
The hook does not output anything.
Claude Code is using a Microsoft Foundry-hosted Sonnet model.
What Should Happen?
Should say "1 PostToolUse hook ran"
Error Messages/Logs
Steps to Reproduce
- Create "Auto-format code after edits" hook.
- Tell Claude:
Create a Test.txt file with "Hello, world!" and 10 newlines.
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.284 (Claude Code)
Platform
Other
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
<img width="329" height="145" alt="Image" src="https://github.com/user-attachments/assets/840261cd-4226-4a74-acbd-7de0c2ec141b" />