Worktrunk is a command-line tool for managing git worktrees, built for running several AI coding agents in parallel. Git worktrees give each agent its own working directory so their changes stay apart, and Worktrunk addresses each worktree by branch name, computing the path from a configurable template, so creating, switching, listing, and removing a worktree takes one short command instead of repeated branch names and directory changes. Commands that take a branch also accept the path of the worktree it is checked out in.
Three core commands cover switching to a worktree (creating the branch and worktree when asked), listing worktrees with status (staged changes, commits ahead of main, unpushed commits, CI status), and removing a worktree together with its branch. A switch can run a command afterward, so one line creates a worktree and starts Claude Code or Codex in it with a task prompt. A merge command squashes, rebases onto main, fast-forwards, and cleans up the worktree in one step, and a step command commits with an LLM-generated message from the diff. Shell integration lets the commands change the current directory.
Beyond the core, hooks run commands on create, pre-merge, and post-merge to automate setup such as installing dependencies or starting a dev server. Build caches such as target or node_modules directories are shared across worktrees by copy-on-write on APFS, btrfs, and XFS. An interactive picker browses worktrees with streaming CI status and diff, log, PR, and comment previews, a PR checkout jumps straight to a pull request's branch, a template filter gives each worktree a unique port for its own dev server, and aliases and per-branch variables add custom commands and branch-scoped state for hook templates.
Features
- Branch-addressed worktrees: switch, create, list, and remove worktrees by branch name, with paths computed from a configurable template
- Agent launch on switch: run a command after switching, so one line creates a worktree and starts Claude Code or Codex in it with a task prompt
- Status listing: staged changes, commits ahead of main, unpushed commits, and in full mode CI status and AI-generated summaries per branch
- Merge workflow: squash, rebase onto main, fast-forward merge, and clean up the worktree and branch in one command
- LLM commit messages: generate commit messages from diffs
- Hooks: run commands on create, pre-merge, post-merge, and other events to automate local setup
- Shared build caches: worktrees share target, node_modules, and similar directories by copy-on-write on APFS, btrfs, and XFS
- Interactive picker: browse worktrees with streaming CI status and diff, log, PR, and comment previews
- PR checkout: switch straight to a pull request or merge request branch
- Dev server per worktree: a hash_port template filter gives each worktree a unique port
- Aliases and per-branch variables: custom wt subcommands and branch-scoped state for hook templates
