PostToolUse hook's stdin payload occasionally leaks to a bare-numeric-named file in the project root instead of reaching the hook
Configured a PostToolUse hook (matcher Bash|Edit|MultiEdit|Write|Task|TodoWrite) via .claude/settings.json that reads a JSON payload from stdin. On Windows, with the Bash tool running through Git Bash, I've now seen 5 separate occurrences (over ~3 weeks) of a stray file appearing in the project root, named with a bare small integer (e.g. 1127, 779, 1363), containing what looks like either a corrupted log fragment or — in the most recent, fully-readable case — the complete raw JSON envelope normally sent as the hook's stdin (session_id, transcript_path, hook_event_name: "PostToolUse", tool_name, tool_input, tool_response).
I audited my own hook script line by line and confirmed it never writes any file — it only reads stdin and calls internal logging functions. Replaying the captured payload through the script by hand produces zero file writes and no output. So the write is happening before the payload reaches my script, somewhere in the hook-invocation plumbing itself.
Hypothesis: a shell redirect using a bare file-descriptor number without the & (> N instead of >& N) somewhere in how the hook subprocess's stdin/stdout is wired up on Windows/Git Bash — this would exactly explain a small-integer filename appearing in the CWD holding what should have gone to a pipe/fd.
Every occurrence coincided with a Bash tool call specifically (never Edit/Write alone), consistent with Bash being the one matcher with a live pipe/fd setup at the time.
Happy to share a sanitized copy of one of the captured files if useful.