| name | worktrunk |
| description | Manage git worktrees via wt — create, switch, list, merge, and remove worktrees; check out MR/PR branches in isolation. Load when working on multiple branches simultaneously, checking out a PR/MR branch for review, or managing worktree lifecycle. |
| updated | "2026-05-07T00:00:00.000Z" |
| related | ["scm","codebases"] |
wt (worktrunk) authority for all git worktree operations.
> USE `wt` for all worktree operations, NOT raw `git worktree`. `wt switch --create` makes branch + worktree in one step. `wt merge` merges current → target (opposite of `git merge`). For PR/MR checkout workflows, also load `scm` skill. For multi-worktree patterns in specific codebases, load `codebases` skill.
Commands
wt switch — switch/create worktree
wt switch <branch>
wt switch --create <branch>
wt switch --create <branch> --base <base>
wt switch -
wt switch ^
wt switch mr:<N>
wt switch pr:<N>
| Flag | Effect |
|---|
--create / -c | Create new branch |
--base <branch> / -b | Base for --create (default: default branch) |
--execute <cmd> / -x | Run command after switching (replaces wt process) |
--branches | Include branches without worktrees in picker |
--clobber | Remove stale path at target |
-y | Skip approval prompts |
Args after -- forwarded to --execute:
wt switch -x claude -c feature-a -- 'Add user authentication'
Picker: wt switch no args opens interactive picker. Preview tabs (1–5): HEAD diff, log, diff vs main, remote diff, LLM summary. Alt-c creates new from query.
wt list — worktree status
wt list
wt list --full
wt list --branches
wt list --format=json
| Symbol | Meaning |
|---|
+ | Staged files |
! | Modified (unstaged) |
? | Untracked |
⊂ | Content integrated into default branch (safe remove) |
_ | Same commit as default branch (safe remove) |
↑ | Ahead of default |
↓ | Behind default |
Rows dimmed when safe to delete (_ or ⊂).
wt merge — merge current → target
wt merge
wt merge develop
wt merge --no-squash
wt merge --no-ff
wt merge --no-remove
Pipeline: squash → rebase → pre-merge hooks → FF merge → pre-remove hooks → cleanup → post-merge hooks.
Cleanup removes worktree + branch. Branch deletion only when merging adds nothing (checks: same commit, ancestor, no added changes, trees match).
wt remove
wt remove
wt remove <branch>
wt remove --no-delete-branch
wt remove -D
wt remove -f
Background by default. Logs at .git/wt/logs/<branch>-remove.log.
wt step — individual operations
wt step commit
wt step commit --stage=tracked
wt step squash
wt step rebase
wt step push
wt step diff
wt step diff -- --stat
wt step copy-ignored
wt step prune
wt step prune --dry-run
wt step for-each -- git status --short
--stage | Behavior |
|---|
all (default) | Stage all including untracked |
tracked | Only modified tracked |
none | Only what's already staged |
wt hook — lifecycle hooks
wt hook pre-merge
wt hook pre-start --yes
wt hook show
| Event | pre- (blocking) | post- (background) |
|---|
| switch | pre-switch | post-switch |
| start (create) | pre-start | post-start |
| commit | pre-commit | post-commit |
| merge | pre-merge | post-merge |
| remove | pre-remove | post-remove |
Config (.config/wt.toml in project root, committed):
[pre-start]
install = "npm ci"
[post-start]
copy = "wt step copy-ignored"
server = "npm run dev -- --port {{ branch | hash_port }}"
[pre-merge]
test = "npm test"
[post-remove]
kill-server = "lsof -ti :{{ branch | hash_port }} -sTCP:LISTEN | xargs kill 2>/dev/null || true"
| Variable | Value |
|---|
{{ branch }} | Active branch |
{{ worktree_path }} | Active worktree path |
{{ primary_worktree_path }} | Primary worktree path |
{{ repo }} | Repo directory name |
{{ branch | hash_port }} | Deterministic port 10000–19999 |
{{ branch | sanitize }} | / replaced by - |
{{ branch | sanitize_db }} | DB-safe identifier with hash suffix |
wt config
wt config shell install
wt config create
wt config create --project
wt config show
| File | Location | Purpose |
|---|
| User | ~/.config/worktrunk/config.toml | Personal preferences, LLM commit setup |
| Project | .config/wt.toml | Hooks, dev URL — committed |
Common Workflows
Feature branch
wt switch --create feature-xyz
wt merge
Review GitLab MR / GitHub PR
wt switch mr:101
wt remove
Parallel agents
wt switch -x claude -c feature-a -- 'Add user authentication'
wt switch -x claude -c feature-b -- 'Fix the pagination bug'
wt switch -x claude -c feature-c -- 'Write tests for the API'
wt list --full
See in-flight
wt list --full
Clean up merged
wt step prune --dry-run
wt step prune
- USE `wt` for worktree operations, NOT raw `git worktree`.
- `wt switch --create` makes branch + worktree in one step.
- `wt merge` merges current → target (opposite of `git merge`).
- `mr:` / `pr:` require `glab` / `gh` authenticated.
- `-x` / `--execute` runs command after switching. Args after `--` forwarded.
- `wt step commit` LLM messages require commit-gen command in `~/.config/worktrunk/config.toml`.
- Shell integration (`wt config shell install`) required for `wt switch` to change directories.
<output_rules>Output in English. Preserve verbatim CLI commands, flags, and config TOML.</output_rules>