From 4724ee77b2d843c789a58ab75d2c7b5e777d7df8 Mon Sep 17 00:00:00 2001 From: Jude Wang <1559819+judewang@users.noreply.github.com> Date: Thu, 16 Jul 2026 15:09:15 +0900 Subject: [PATCH] fix(plugin): anchor WorktreeRemove at the project dir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The WorktreeRemove hook inherits the working directory it is fired from. When that is not inside the repo (e.g. the session's worktree was already removed, or the hook fires from a neutral cwd), `wt remove ` dies with `fatal: not a git repository` — repo discovery starts from cwd, not the path argument. Claude Code surfaces this as `WorktreeRemove hook failed` and keeps the session row, so the background session becomes undeletable. `cd "${CLAUDE_PROJECT_DIR:-.}"` pins the hook to the launch repo, mirroring the WorktreeCreate anchor added in #3453. --- 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 51ec98160c..f3ba04e27e 100644 --- a/plugins/worktrunk/hooks/hooks.json +++ b/plugins/worktrunk/hooks/hooks.json @@ -79,7 +79,7 @@ "hooks": [ { "type": "command", - "command": "bash -c 'p=$(jq -er .worktree_path) || exit 1; bash \"$CLAUDE_PLUGIN_ROOT/hooks/wt.sh\" remove --foreground \"$p\"'" + "command": "bash -c 'p=$(jq -er .worktree_path) || exit 1; cd \"${CLAUDE_PROJECT_DIR:-.}\" || exit 1; bash \"$CLAUDE_PLUGIN_ROOT/hooks/wt.sh\" remove --foreground \"$p\"'" } ] }