Arguments:
. The
first whitespace-delimited token is the branch
name for the new worktree; everything after it (if any) is the task to perform
once inside the worktree.
-
First action — before reading any files or running any commands — call
EnterWorktree({name: "<branch-name>"})
with the first token of the
arguments as the name. This re-roots the session into the new worktree.
- It works because this plugin maps →
wt switch --create <name> --no-cd --format=json
, so the new worktree
lands in worktrunk's normal sibling layout (), not under
.
- is idempotent: if the branch already exists, this
just re-enters its worktree.
- If you are already inside an -created worktree (e.g. the
background harness already isolated this session), skip this step —
refuses to nest. Note that you're reusing the existing
worktree and continue.
- If fails (not a git repo, invalid branch name, etc.),
report the error and stop — do not fall back to working in the original
directory, since that defeats the purpose.
-
After the cwd switch succeeds, proceed with the task portion of the
arguments (the text after the branch name) in the new worktree. If there was
no task text, just confirm the worktree is ready and wait for the next
instruction.
Don't remove the worktree yourself.
ExitWorktree({action: "remove"})
(if the
user asks to leave) or the session-exit prompt routes through this plugin's
hook →
wt remove -D --foreground
. A worktree with uncommitted
changes won't be auto-removed without confirmation — that's intended.
This command authorizes creating/entering ONE worktree and doing the requested
task. Commits, pushes, and merges still each require explicit user permission.