Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

fix(plugin): fail worktree hooks before side effects; document path args (#3060)

Maximilian Roos11129d381142
diff --git a/docs/content/remove.md b/docs/content/remove.md
index 0c0fb48f7..2d7e4a30e 100644
--- a/docs/content/remove.md
+++ b/docs/content/remove.md
@@ -97,7 +97,7 @@ Usage: <b><span class=c>wt remove</span></b> <span class=c>[OPTIONS]</span> <spa
<b><span class=g>Arguments:</span></b>
<span class=c>[BRANCHES]...</span>
- Branch name [default: current]
+ Branch name or worktree path [default: current]
<b><span class=g>Options:</span></b>
<b><span class=c>--no-delete-branch</span></b>
diff --git a/plugins/worktrunk/README.md b/plugins/worktrunk/README.md
index 246c45e4a..10750f012 100644
--- a/plugins/worktrunk/README.md
+++ b/plugins/worktrunk/README.md
@@ -2,6 +2,9 @@
Git worktree management CLI integration with activity tracking.
+Requires the `wt` CLI ([worktrunk.dev](https://worktrunk.dev)) and `jq` (used
+by the worktree-lifecycle hooks).
+
## Features
1. **Configuration skill** — Guides LLM-powered commit message setup, project hooks (pre-start, pre-merge), and worktree path customization
diff --git a/plugins/worktrunk/hooks/hooks.json b/plugins/worktrunk/hooks/hooks.json
index d0fbf5acf..80fd5fe29 100644
--- a/plugins/worktrunk/hooks/hooks.json
+++ b/plugins/worktrunk/hooks/hooks.json
@@ -69,7 +69,7 @@
"hooks": [
{
"type": "command",
- "command": "bash -c 'set -o pipefail; jq -r .name | xargs -I{} bash \"$CLAUDE_PLUGIN_ROOT/hooks/wt.sh\" switch --create {} --no-cd --format=json | jq -r .path'"
+ "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'"
}
]
}
@@ -79,7 +79,7 @@
"hooks": [
{
"type": "command",
- "command": "bash -c 'set -o pipefail; jq -r .worktree_path | xargs -I{} bash \"$CLAUDE_PLUGIN_ROOT/hooks/wt.sh\" remove --foreground {}'"
+ "command": "bash -c 'p=$(jq -er .worktree_path) || exit 1; bash \"$CLAUDE_PLUGIN_ROOT/hooks/wt.sh\" remove --foreground \"$p\"'"
}
]
}
diff --git a/skills/worktrunk/reference/remove.md b/skills/worktrunk/reference/remove.md
index 6aad86e8a..82d5200e4 100644
--- a/skills/worktrunk/reference/remove.md
+++ b/skills/worktrunk/reference/remove.md
@@ -95,7 +95,7 @@ Usage: wt remove [OPTIONS] [BRANCHES]...
Arguments:
[BRANCHES]...
- Branch name [default: current]
+ Branch name or worktree path [default: current]
Options:
--no-delete-branch
diff --git a/skills/wt-switch-create/SKILL.md b/skills/wt-switch-create/SKILL.md
index 881c7024f..43212138d 100644
--- a/skills/wt-switch-create/SKILL.md
+++ b/skills/wt-switch-create/SKILL.md
@@ -38,9 +38,10 @@ Steps 1–3 come before any other work.
<!-- Maintainers: the design choices here are backed by tested evidence in
rationale.md (same directory) — read it before re-adding guards or routes. -->
-1. **Pick the branch name** if none was given: short kebab-case from the task
- ("fix the parser bug" → `fix-parser-bug`) or, mid-session, from the work
- being moved; with nothing to derive from, ask.
+1. **Pick the branch name** if none was given: short, from the task ("fix the
+ parser bug" → `fix-parser-bug`) and consistent with existing worktree
+ names, or, mid-session, from the work being moved; with nothing to derive
+ from, ask.
2. **Create the worktree** with a `Bash` call (omit `-C <repo>` when no repo
was given):
diff --git a/src/cli/mod.rs b/src/cli/mod.rs
index 579136799..0abf68371 100644
--- a/src/cli/mod.rs
+++ b/src/cli/mod.rs
@@ -425,7 +425,7 @@ pub(crate) struct ListArgs {
#[derive(Args)]
pub(crate) struct RemoveArgs {
- /// Branch name [default: current]
+ /// Branch name or worktree path [default: current]
#[arg(add = crate::completion::local_branches_completer())]
pub(crate) branches: Vec<String>,
diff --git a/tests/snapshots/integration__integration_tests__help__help_remove_long.snap b/tests/snapshots/integration__integration_tests__help__help_remove_long.snap
index 5e45c5835..70070b8eb 100644
--- a/tests/snapshots/integration__integration_tests__help__help_remove_long.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_remove_long.snap
@@ -44,7 +44,7 @@ Usage: wt remove [OPTIONS] [BRANCHES]...
Arguments:
[BRANCHES]...
- Branch name [default: current]
+ Branch name or worktree path [default: current]
Options:
--no-delete-branch
diff --git a/tests/snapshots/integration__integration_tests__help__help_remove_short.snap b/tests/snapshots/integration__integration_tests__help__help_remove_short.snap
index b5dc70866..5d488a9f8 100644
--- a/tests/snapshots/integration__integration_tests__help__help_remove_short.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_remove_short.snap
@@ -41,7 +41,7 @@ wt remove - Remove worktree; delete branch if merged
Usage: wt remove [OPTIONS] [BRANCHES]...
Arguments:
- [BRANCHES]... Branch name [default: current]
+ [BRANCHES]... Branch name or worktree path [default: current]
Options:
--no-delete-branch Keep branch after removal