From 8a812528039551851c24d98e3f9b5587f028239d Mon Sep 17 00:00:00 2001 From: silvanshade Date: Mon, 13 Jul 2026 01:53:53 -0600 Subject: [PATCH 1/2] fix(plugin): anchor WorktreeCreate at the project dir and base agent worktrees on HEAD Two failure modes observed driving Claude Code agent isolation through the plugin's WorktreeCreate hook: 1. The hook inherits the session shell's working directory. When the shell has cd'd outside the repository (e.g. into a reference-papers directory), wt switch dies with 'not a git repository' and every isolated-agent spawn in the session fails. Anchoring at CLAUDE_PROJECT_DIR (falling back to . when unset) pins the hook to the repo the session was launched in. 2. Without --base, agent worktrees are created from the default branch, so a sub-agent spawned mid-session on a feature branch is born at main and cannot see the session's committed work; its output then needs manual base correction before integration. --base=@ bases the worktree on the session's current HEAD, matching the isolated-copy-of-current-work expectation of sub-agent isolation. Co-Authored-By: Claude Fable 5 --- plugins/worktrunk/hooks/hooks.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/worktrunk/hooks/hooks.json b/plugins/worktrunk/hooks/hooks.json index 80fd5fe29e..1bcbc018bf 100644 --- a/plugins/worktrunk/hooks/hooks.json +++ b/plugins/worktrunk/hooks/hooks.json @@ -69,7 +69,7 @@ "hooks": [ { "type": "command", - "command": "bash -c 'name=$(jq -er .name) || exit 1; bash \"$CLAUDE_PLUGIN_ROOT/hooks/wt.sh\" switch --create \"$name\" --no-cd --format=json | jq -er .path'" + "command": "bash -c 'name=$(jq -er .name) || exit 1; cd \"${CLAUDE_PROJECT_DIR:-.}\" || exit 1; bash \"$CLAUDE_PLUGIN_ROOT/hooks/wt.sh\" switch --create \"$name\" --base=@ --no-cd --format=json | jq -er .path'" } ] } From a20d1c0f8eb95809c716dfbdccfc1ad6fbdac85e Mon Sep 17 00:00:00 2001 From: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> Date: Tue, 14 Jul 2026 17:12:21 +0000 Subject: [PATCH 2/2] fix(plugin): drop --base=@ from WorktreeCreate hook Keep the CLAUDE_PROJECT_DIR anchor but remove --base=@ so the hook no longer hardcodes head-based worktrees. Base selection stays as wt's default (the default branch), matching Claude Code's native 'fresh' default, rather than overriding the worktree.baseRef setting for everyone. --- plugins/worktrunk/hooks/hooks.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/worktrunk/hooks/hooks.json b/plugins/worktrunk/hooks/hooks.json index 1bcbc018bf..51ec98160c 100644 --- a/plugins/worktrunk/hooks/hooks.json +++ b/plugins/worktrunk/hooks/hooks.json @@ -69,7 +69,7 @@ "hooks": [ { "type": "command", - "command": "bash -c 'name=$(jq -er .name) || exit 1; cd \"${CLAUDE_PROJECT_DIR:-.}\" || exit 1; bash \"$CLAUDE_PLUGIN_ROOT/hooks/wt.sh\" switch --create \"$name\" --base=@ --no-cd --format=json | jq -er .path'" + "command": "bash -c 'name=$(jq -er .name) || exit 1; cd \"${CLAUDE_PROJECT_DIR:-.}\" || exit 1; bash \"$CLAUDE_PLUGIN_ROOT/hooks/wt.sh\" switch --create \"$name\" --no-cd --format=json | jq -er .path'" } ] }