PostToolUse hook with matcher 'Write|Edit' only fires for Write, silently ignores Edit

Resolved 💬 3 comments Opened Mar 12, 2026 by ebogdum Closed Mar 12, 2026

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

  1. 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
          }
        ]
      }
    ]
  }
}
  1. In a session, use both Write and Edit tools on files in a git repo
  2. Observe that only Write tool calls produce auto-commits
  3. 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 reflog shows exactly 2 commits: the initial commit and one auto-commit
  • The single auto-commit corresponds to the one Write tool call (full file rewrite of status.go)
  • Multiple Edit calls to branch.go, save.go, branch_test.go in the same session produced zero commits
  • All edited files remain ?? (untracked) in git 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

View original on GitHub ↗

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