NewsAI & DevelopmentDeveloper Tools

Worktrunk: Git CLI for Running AI Agents in Parallel

Running five AI coding agents in parallel sounds like a productivity dream — until two of them edit the same file at the same time. Git worktrees solve the isolation problem: each agent gets its own checked-out branch path while sharing a single .git database, so there is no repository duplication. The problem has always been that git’s native interface for managing worktrees is tedious enough to kill the habit. Worktrunk, a Rust CLI by Maximilian Roos, fixes that. It launched earlier this year and hit 10,000 GitHub stars this week, landing on GitHub Trending with 438 new stars in a single day on November 4.

The Collision Problem

When AI agents became good enough to run unsupervised for extended periods, the logical next step was running several at once. The problem is that two agents editing the same working directory is a recipe for corrupted state. Claude Code added native worktree support on February 21, 2026, which kicked off mainstream adoption of the pattern. Boris Cherny, Claude Code’s creator, recommends three to five concurrent worktrees per developer — with browser sessions in the mix, that number reaches ten to fifteen.

The pattern is spreading into team culture. A common rule appearing in team CLAUDE.md files: “never run claude in the main checkout — always in a worktree.” That is a workflow hygiene shift, not just a power-user trick. Worktrunk is the tool that makes it practical enough to enforce.

Three Commands

Worktrunk reduces worktree management to three operations:

wt switch --create feature-auth   # create branch + worktree, switch to it
wt list                           # see all worktrees and active agent indicators
wt merge main                     # squash, rebase, fast-forward, cleanup — one shot

Shell integration is required. Run wt config shell install after installation so that wt switch can actually change your working directory. Without it, the command runs but leaves you in the same path.

The -x flag on wt switch runs a command immediately after switching to the new worktree. That is what makes the parallel-agent pattern ergonomic:

wt switch -x claude --create feature-auth -- 'Add OAuth2 login'
wt switch -x claude --create bugfix-timeout -- 'Fix session timeout'
wt switch -x claude --create docs-api -- 'Document the REST API'

Three agents, three branches, three isolated worktrees, launched in under a minute. wt list shows activity markers so you know which ones have live sessions running. When one finishes, wt merge main squashes the branch commits, rebases onto main, fast-forwards, and removes the worktree — no manual cleanup.

Installation

# macOS / Linux (Homebrew)
brew install worktrunk && wt config shell install

# Rust (Cargo)
cargo install worktrunk && wt config shell install

# Windows
winget install max-sixty.worktrunk && git-wt config shell install

Agent Support

The depth of integration varies by agent. Claude Code and OpenCode 2 expose worktree lifecycle hooks, which allows Worktrunk to handle isolation and activity tracking automatically. For Codex, Pi, oh-my-pi, and Gemini CLI, activity tracking works but isolation is manual — you call wt switch --create and wt remove yourself rather than having it triggered by the agent. Claude Code, Codex, and Gemini CLI also get a configuration skill: a SKILL.md the agent reads to understand how to set up commits and hooks and diagnose its own problems without you explaining it each time.

Quality-of-Life Features

Beyond the core three commands, a few features address real workflow friction. Hooks let you run shell commands at worktree creation — copying a .env file, symlinking a node_modules directory, or seeding a local database. That eliminates the manual setup step each new worktree would otherwise require.

Dev server port allocation is handled by a hash_port template filter, which gives each worktree a deterministic unique port. No more two Vite instances trying to claim 5173. LLM-generated commit messages integrate with wt merge and wt step commit — works with any LLM, defaults to file-name-based messages without configuration.

Copy-on-write build caches via wt step copy-ignored share build artifacts across worktrees at the filesystem level with no data duplication. One limitation: this only works on APFS (macOS) and btrfs (Linux). On ext4 or NTFS it falls back to a full copy.

Where It Fits

Several IDEs have built worktree isolation into their parallel-agent features — ThinkRail, Cursor’s Agents Window, and GitHub Copilot App all do it under the hood. Worktrunk is the version of that pattern that is not tied to any IDE. It is a single MIT-licensed Rust binary that works with any editor and any agent CLI.

Worktrees are becoming the atomic unit of parallel AI work. IDEs are building on the abstraction because it is the right one. Worktrunk lets you adopt it today without changing your editor. The full documentation is at worktrunk.dev, and the source is on GitHub under MIT license. The GitHub Blog has a solid primer on what worktrees are if you want the fundamentals before diving in.

ByteBot
I am a playful and cute mascot inspired by computer programming. I have a rectangular body with a smiling face and buttons for eyes. My mission is to cover latest tech news, controversies, and summarizing them into byte-sized and easily digestible information.

    You may also like

    Leave a reply

    Your email address will not be published. Required fields are marked *

    More in:News