PostToolUse hook with matcher 'Write|Edit' only fires for Write, silently ignores Edit
Bug Description
PostToolUse hooks with matcher "Write|Edit" only trigger for Write tool calls. Edit tool calls are silently ignored — the hook never fires.
Reproduction Steps
- Configure a PostToolUse hook in
~/.claude/settings.json:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "INPUT=\$(cat); FILE_PATH=\$(echo \"\$INPUT\" | jq -r '.tool_input.file_path // empty' 2>/dev/null); if [ -n \"\$FILE_PATH\" ] && [ -e \"\$FILE_PATH\" ]; then git add -- \"\$FILE_PATH\" 2>/dev/null && git diff --cached --quiet 2>/dev/null || git commit -m \"auto: \$(date '+%Y-%m-%d %H:%M:%S') \${FILE_PATH##*/}\" --no-verify 2>/dev/null; fi; true",
"timeout": 5000
}
]
}
]
}
}
- In a session, use both Write and Edit tools on files in a git repo
- Observe that only Write tool calls produce auto-commits
- Edit tool calls complete successfully but the PostToolUse hook never fires
Evidence
In a multi-hour session with dozens of Edit calls and one Write call:
git reflogshows exactly 2 commits: the initial commit and one auto-commit- The single auto-commit corresponds to the one
Writetool call (full file rewrite ofstatus.go) - Multiple
Editcalls tobranch.go,save.go,branch_test.goin the same session produced zero commits - All edited files remain
??(untracked) ingit status
Expected Behavior
The matcher "Write|Edit" should match both tool names. PostToolUse hook should fire after every successful Edit call, same as it does for Write.
Actual Behavior
Hook only fires for Write. Edit is silently ignored. No error, no warning, no indication that the hook didn't match.
Impact
Data loss risk. Users relying on PostToolUse hooks for auto-commit (a common pattern for safety) will lose all work done via Edit if their session crashes, runs out of context, or gets compacted. In our case, multiple sessions worth of work across 80+ files had zero commits.
Environment
- Claude Code CLI
- macOS (Darwin 24.6.0)
- Model: claude-opus-4-6
- Settings location:
~/.claude/settings.json
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗