You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Claude Code gofmt and go vet hooks never run: $CLAUDE_FILE_PATHS is not set #34
Both PostToolUse hooks in .claude/settings.json check $CLAUDE_FILE_PATHS for a .go path. Claude Code doesn't set that variable; it sends the tool call as JSON on stdin, with the path at tool_input.file_path (hooks reference: https://code.claude.com/docs/en/hooks). So the grep never matches, and neither gofmt nor go vet runs after an edit. The second hook also does cd d:/projects/sap-devs-cli, which exists on one machine only.
One hook covers both (needs jq):
"command": "f=$(jq -r '.tool_input.file_path // empty'); case \"$f\" in *.go) gofmt -w \"$f\" && cd \"$CLAUDE_PROJECT_DIR\" && go vet ./... 2>&1 | head -20 ;; esac"
Tested with the JSON Claude Code sends for an Edit to a .go file: before, nothing runs; after, gofmt runs on that file and go vet runs from the project root, and a .md edit runs nothing. One note: on exit 0 the vet output goes to the debug log only, so if you want Claude to act on vet findings, send them to stderr and exit 2.
Found this while testing Claude Code hooks for Paveo; uvx paveo doctor flags both hooks in one command. Happy to open a PR with the fix.
Activity