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
Hook does not rewrite go -C DIR <subcommand> (global chdir flag before the subcommand) #4970
$ rtk rewrite "go -C ./sub test ./..."
# prints nothing: not rewritten
$ rtk rewrite "go test ./..."
rtk go test ./...
$ rtk rewrite "cd ./sub && go test ./..."
cd ./sub && rtk go test ./...
rtk 1.1.0, macOS, Claude Code hook (rtk hook claude).
Why it matters
Agents working across several clones/worktrees use go -C DIR test|vet|build to avoid changing the shell's working directory. In my last 30 days rtk discover lists go among the top unhandled commands (4,155 calls; the example it shows is go -C <clone> ...), so the full go test output of those calls reaches the agent, while the same tests run as cd DIR && go test are compressed.
Expected
go -C DIR test ARGS → rtk go -C DIR test ARGS (and the same for the other subcommands rtk already handles), with rtk keeping -C DIR as the first flag when it injects -json. Go accepts -C DIR, -C=DIR, --C DIR and --C=DIR, only as the first flag (handleChdirFlag in cmd/go/main.go).
Related: #4362 / #3520 fix the same ordering problem for go test -C DIR (chdir after the subcommand). This report is about the form with -C before the subcommand, which the hook does not match at all.
rtk's command rewrite doesn't match go -C DIR <subcommand> (global chdir flag before subcommand), so full go output bypasses compression — extend the go rewrite matcher alongside the existing -C-after-subcommand fix.
This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.
📁 Relevant files
cmd/go/main.go
internal/rewrite/go.go
Suggested Actions
Extend the go rewrite matcher to recognize -C/--C (and =DIR form) before the subcommand, not just after
Activity
rtk-wshm-sync-bot commentedon Nov 3, 2026
🔍 Automated Triage
bugmediumSummary
rtk's command rewrite doesn't match
go -C DIR <subcommand>(global chdir flag before subcommand), so full go output bypasses compression — extend the go rewrite matcher alongside the existing -C-after-subcommand fix.📁 Relevant files
cmd/go/main.gointernal/rewrite/go.goSuggested Actions
go test -C DIRordering-C DIRas the first flag when injecting-json, per Go's handleChdirFlag requirement-C DIR,-C=DIR,--C DIR,--C=DIRacross the go subcommands rtk already handlesTriaged automatically by wshm · This is an automated analysis, not a human review.