A bare repository has no working tree, so all branches — including the default — are linked worktrees at equal paths. No branch gets special treatment.
Cloning a bare repo into <project>/.git puts all worktrees under one directory:
On first wt switch in a bare repo at a hidden path (.git, .bare), worktrunk detects that the default template would produce broken paths like myproject/.git.main and offers a fix:
▲ Bare repo at myproject/.git — worktrees will be at myproject/.git.main
◎ Configure worktree-path to place worktrees at myproject/main? [y/N/?]
Accepting writes a project-scoped entry to user config:
Run wt config show from inside any worktree to find the project identifier (Identifier: … in the PROJECT CONFIG section). Set it globally with worktree-path = "..." at the top level if this layout is preferred for all bare repos.
For a freshly cloned bare repo the default branch already exists, so wt switch main (without --create) is enough. Use wt switch --create <branch> for new branches.
Now wt switch --create feature creates myproject/feature/.
The project config (.config/wt.toml) must live inside a worktree — the bare .git directory has no tracked files. Once the first worktree exists, create it from there:
wtswitchmain
wtconfigcreate--project
Commit the file and it will appear in every worktree automatically.
Branch on {{ target }} to vary behavior per merge destination — for example, deploying to production from main and staging from a release branch:
.config/wt.toml
post-merge = """
if [ {{ target }} = main ]; then
npm run deploy:production
elif [ {{ target }} = staging ]; then
npm run deploy:staging
fi
"""
{{ target }} is the branch being merged into. post-merge runs in the target’s worktree (or the primary worktree if target has none), so deploy commands see the merged code.
Each worktree runs its own dev server on a deterministic port. The hash_port filter generates a stable port (10000-19999) from the branch name:
.config/wt.toml
[post-start]
server = "wt step tether -- npm run dev -- --port {{ branch | hash_port }}"
[list]
url = "http://localhost:{{ branch | hash_port }}"
wt step tether runs the server in its own process group and tears the whole group down when the worktree is removed, so no pre-remove hook is needed. See the wt step tether docs for the full rationale and platform behavior.
The URL column in wt list shows each worktree’s dev server:
The first pipeline step derives values from the branch and stores them as vars. The second step references {{ vars.container }} and {{ vars.port }} — templates render when each step runs, so the vars are already set. pre-remove reads the same vars to stop the container.
The ('db-' ~ branch) concatenation hashes differently than plain branch, so database and dev server ports don’t collide. The sanitize_db filter produces database-safe identifiers (lowercase, underscores, no leading digits, with a short hash suffix).
The connection string is accessible anywhere — not just in hooks:
To scope environment variables to a worktree — a tool’s package path, a profile, an API endpoint — use a directory environment manager like direnv or mise. Both hook the shell prompt, so they activate on the cd that wt switch already performs — no worktrunk configuration needed. Commit the config at the repo root and every worktree gets its own copy, with paths resolving relative to that worktree.
direnv — commit .envrc at the repo root:
.envrc
exportMY_PACKAGES_PATH="$(expand_path.packages)"
Run direnv allow once per worktree to trust the file (getting started). After that, switching into a worktree loads the env; switching out unloads it.
mise — commit mise.toml at the repo root:
mise.toml
[env]
MY_PACKAGES_PATH = "{{ config_root }}/.packages"
{{ config_root }} is the project root mise resolves relative paths against (env directives) — the worktree root, not the primary worktree. mise also covers Windows / PowerShell, which direnv doesn’t natively.
Both set real environment variables in the shell session, so every child process inherits them — hooks, build tools, subshells. Each new worktree is a new path, so it needs its own one-time trust step (direnv allow / mise trust).
Use wt step copy-ignored to copy gitignored files (caches, dependencies, .env) between worktrees:
.config/wt.toml
[post-start]
copy = "wt step copy-ignored"
When another hook depends on the copy — for example, copying node_modules/ before pnpm install so the install reuses cached packages — sequence them with a [[post-start]] pipeline:
.config/wt.toml
[[post-start]]
copy = "wt step copy-ignored"
[[post-start]]
install = "pnpm install"
Use pre-start instead when an --execute command needs the copied files immediately.
All gitignored files are copied by default. To limit what gets copied, create .worktreeinclude with patterns — files must be both gitignored and listed. See wt step copy-ignored for details.
Each worktree gets its own cmux workspace. Switching worktrees switches workspaces; removing a worktree closes its workspace. Configuration contributed by @endigma (#2796).
Why pre-* instead of post-*? cmux restricts socket access to processes spawned inside a cmux terminal. post-* hooks run as detached background processes, breaking the process ancestry chain. pre-* hooks run in the foreground and inherit the terminal’s process lineage.
Clean up Xcode’s DerivedData when removing a worktree. Each DerivedData directory contains an info.plist recording its project path — grep for the worktree path to find and remove the matching build cache:
The agent plugins mark each worktree 🤖 (working) or 💬 (waiting) in wt list, and wt config state marker set sets a marker by hand for any other workflow. See Activity tracking.
Spawn a worktree with an agent CLI running in the background. -x names the program to run and everything after -- is passed to it, so OpenCode’s subcommand goes after the --: -x opencode -- run '<task>'.
tmux (new detached session):
tmuxnew-session-d-sfix-auth-bug"wt switch --create fix-auth-bug -x claude -- \
'The login session expires after 5 minutes. Find the session timeout config and extend it to 24 hours.'"
'The login session expires after 5 minutes. Find the session timeout config and extend it to 24 hours.'
This lets one agent session hand off work to another that runs in the background. Hooks run inside the multiplexer session/pane.
The worktrunk skill includes guidance for Claude Code (and other agent CLIs that load it) to execute this pattern. To enable it, request it explicitly (“spawn a parallel worktree for…”) or add to your project instructions (CLAUDE.md or AGENTS.md):
AGENTS.md
When I ask you to spawn parallel worktrees, use the agent handoff pattern
With summary = true and commit.generation configured, wt list --full shows an LLM-generated one-line summary for each branch. The same summaries appear in the wt switch picker’s summary tab.
The commit.generation.command receives the rendered prompt on stdin and returns the commit message on stdout. To write commit messages by hand instead of using an LLM, point it at $EDITOR:
This comments out the rendered prompt (diff, branch name, stats) with # prefixes, opens your editor, and strips comment lines on save. A couple of blank lines at the top give you space to type; the prompt context is visible below for reference.
To keep the LLM as default but use the editor for a specific merge, add a worktrunk alias:
Each hook_output entry carries branch, source (user, project, or internal), hook_type, name, and path — adjust the select to pick a different hook or branch. Run wt config state logs to list all available logs.
Create a shell function for frequent use (wtlog server):
You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.