[BUG] PostToolUse hook not invoked when editing files outside project CWD (path-join bug in Go binary)

Open 💬 1 comment Opened Jun 19, 2026 by lesleslie

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?

---
Title: PostToolUse hook not invoked when editing files outside project CWD (path-join bug in Go
binary)

Version: 2.1.183 (macOS, native Mach-O x86_64)

Reproduce:

  1. Start Claude Code in project /Users/les/Projects/mahavishnu
  2. Edit any file outside that directory (e.g. /Users/les/Projects/css-mcp/css_mcp/analyzer.py)
  3. See: PostToolUse:Edit hook additional context: open

/Users/les/Projects/mahavishnu/Users/les/Projects/css-mcp/css_mcp/analyzer.py: no such file or
directory

Evidence the hook never runs: Added sys.stderr.write(...) as the first line after the hook reads
file_path — no output ever appeared.

Root cause (observed): Claude Code constructs the path as:
filepath.Join(cwd, strings.TrimPrefix(absoluteFilePath, "/"))
which produces <cwd>/<absolute-path-without-leading-slash> instead of using the absolute path
directly. The os.Open() of this invalid path fails with Go's *os.PathError, the hook spawn is
aborted, and the error is surfaced as "hook additional context."

Impact: PostToolUse hooks never fire for any file outside the active project directory, silently
skipping all hook side-effects (reflection storage, code indexing, etc.).

Workaround: None from user config; binary-level fix required.

---

What Should Happen?

see above

Error Messages/Logs

Steps to Reproduce

see above

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.183

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

_No response_

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗