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 plugin WorktreeCreate hook: missing pipefail swallows wt failures ("hook succeeded but returned no worktree path") #3545
When wt switch --create fails partway (in my case a repo .config/wt.toml hook step, after the branch/worktree had already been created), Claude Code's EnterWorktree(name: ...) reports:
WorktreeCreate hook failed: hook succeeded but returned no worktree path
(command: echo the path to stdout; http/callback: return hookSpecificOutput.worktreePath)
The real wt error is swallowed, and the half-created branch/worktree is left behind — a follow-up wt switch --create <same-name> then fails with "Branch already exists", which is confusing to recover from (the fix is wt switch <name>without--create, but nothing tells you that).
Cause
The shipped hook command in the plugin's hooks.json (observed in marketplace cache versions 17add1f6dda3 and 4121dc979c2c):
So when wt dies with empty stdout, the hook "succeeds" while printing nothing, producing the misleading no-path error above instead of wt's actual stderr.
Suggested fix
Prefix the pipeline with set -o pipefail; (the pattern the repo's own skills/wt-switch-create/rationale.md describes) — or capture wt's output and check its exit status before piping to jq. Possibly related shell-portability ground touched in #2962.
Environment: worktrunk Claude plugin via marketplace, Linux devcontainer, bash.
Thanks for the excellent, precise report — the diagnosis is exactly right.
I reproduced it and confirmed the root cause: the WorktreeCreate command in plugins/worktrunk/hooks/hooks.json never carried set -o pipefail, even though skills/wt-switch-create/rationale.md documents that wrapper as the intended design ("The hooks.json pipefail wrapper"). So the code had drifted from its own rationale — the pipeline's exit status was jq's, and on jq 1.6 jq -er .path exits 0 on empty stdin, swallowing wt's real failure.
I've opened #3546, which prefixes the existing bash -c command with set -o pipefail; — the safe home for it (dash rejects the option fatally, which is why the bash -c wrapper exists), and it makes the pipeline surface wt's nonzero exit regardless of jq version. It also adds a test asserting the hook keeps set -o pipefail, so this can't silently regress again.
Reproduction and jq-version note
The behavior you saw is jq-version-dependent, which the fix sidesteps entirely:
# jq 1.6 (your environment) — bug fires:
$ printf''| jq -er .path;echo$?0
# jq 1.7+ — empty input exits 4, so the bug happens to be masked there:
$ printf''| jq -er .path;echo$?4
With set -o pipefail, a failed wt (nonzero exit, empty stdout) propagates regardless:
Your point about the leftover half-created branch/worktree (the confusing "Branch already exists" on retry, recovered with wt switch <name>without--create) is a separate rough edge from the swallowed error — worth its own look, but out of scope for this one-line fix.
Activity
worktrunk-bot commentedon Jul 22, 2026
Thanks for the excellent, precise report — the diagnosis is exactly right.
I reproduced it and confirmed the root cause: the
WorktreeCreatecommand inplugins/worktrunk/hooks/hooks.jsonnever carriedset -o pipefail, even thoughskills/wt-switch-create/rationale.mddocuments that wrapper as the intended design ("The hooks.json pipefail wrapper"). So the code had drifted from its own rationale — the pipeline's exit status wasjq's, and on jq 1.6jq -er .pathexits 0 on empty stdin, swallowingwt's real failure.I've opened #3546, which prefixes the existing
bash -ccommand withset -o pipefail;— the safe home for it (dash rejects the option fatally, which is why thebash -cwrapper exists), and it makes the pipeline surfacewt's nonzero exit regardless of jq version. It also adds a test asserting the hook keepsset -o pipefail, so this can't silently regress again.Reproduction and jq-version note
The behavior you saw is jq-version-dependent, which the fix sidesteps entirely:
With
set -o pipefail, a failedwt(nonzero exit, empty stdout) propagates regardless:Your point about the leftover half-created branch/worktree (the confusing "Branch already exists" on retry, recovered with
wt switch <name>without--create) is a separate rough edge from the swallowed error — worth its own look, but out of scope for this one-line fix.A maintainer will review #3546.
fix(plugin): add pipefail to WorktreeCreate hook so wt failures surfa…
max-sixty commentedon Jul 22, 2026
thanks @avdi !
feat(plugin): add `wt config plugins claude hook` for the Claude hooks (