Skip to content

post-edit hook silently does nothing on Claude Code: tool_input.file_path is not parsed #110

Closed

Description

@JordanCoin

The PostToolUse hook parses the wrong payload shape for Claude Code, so both features it drives have been silently inert: agent-edit provenance records nothing, and the post-edit blast-radius warning never fires.

Evidence

Same file, same hook, two payload shapes:

$ printf '{"session_id":"s1","file_path":"<abs>/cmd/doctor.go"}' | codemap hook post-edit
   Imports 1 hub(s): internal/buildinfo/version.go
  recorded: 1

$ printf '{"session_id":"s1","tool_name":"Edit","tool_input":{"file_path":"<abs>/cmd/doctor.go"}}' | codemap hook post-edit
  recorded: 0

The second is what Claude Code actually sends for Edit/Write. It produces no output and no record.

Corroborating: across a four-day session in this repo where I made a dozen-plus Edit/Write tool calls and shipped four merged PRs, .codemap/agent_edits.jsonl was never created. Every UserPromptSubmit hook that session printed no agent edits recorded this session — accurately reporting its own failure.

Root cause

parseHookFilePathsErr (cmd/hooks.go:1798) handles exactly two structured shapes:

if filePath, ok := data["file_path"].(string); ok { ... }        // top-level
if toolInput, ok := data["tool_input"].(map[string]any); ok {
    if command, ok := toolInput["command"].(string); ok { ... }  // Codex apply_patch
}

tool_input.file_path matches neither. The regex fallback that would have caught it only runs when json.Unmarshal fails — and a well-formed payload parses fine, so it never executes. Valid JSON in the unhandled shape is the one case that silently returns nothing.

Impact

  • Edit provenance (fix: make codemap's model of agent sessions truthful #84) — agent_edits.jsonl is never written on Claude Code. showWorkingSetSummary and showSessionProgress therefore always fall back to disk-churn counts, which is the exact conflation that feature was built to remove.
  • Post-edit blast radius — the "you just edited a file that N others import" warning never fires. This is the behavior CLAUDE.md instructs agents to rely on before editing.

Fix

Accept tool_input.file_path (and, for symmetry, tool_input.notebook_path) alongside the existing shapes. Worth also handling tool_response.filePath, which some tools echo back.

Regression tests should cover each payload shape end-to-end rather than only the parser, since the parser was arguably "working" — it just never saw the shape it needed.

Cross-reference

Same class as #109: a feature reporting success (or in this case, honestly reporting emptiness) while doing nothing. Both are cases where the check and the reality diverged silently.

Activity

  1. added a commit that references this issue on Aug 8, 2026
    4bef107
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions