PromptHub
Back to Blog
Developer Tools Open Source

max-sixty/worktrunk: Parallel Git Worktree Management for AI Agents

B

Bright Coding

Author

8 min read 60 views
max-sixty/worktrunk: Parallel Git Worktree Management for AI Agents

max-sixty/worktrunk: Parallel Git Worktree Management for AI Agents

Managing multiple AI coding agents in parallel creates a Git logistics problem. Each agent needs its own working directory to avoid stepping on changes, but Git's native worktree commands are verbose and repetitive. max-sixty/worktrunk solves this with a Rust CLI that makes worktrees as easy as branches.

What is max-sixty/worktrunk?

max-sixty/worktrunk is a command-line tool for Git worktree management, written in Rust and released in early 2026. With 5,850 stars and 204 forks as of July 2026, it has become the most popular dedicated worktree manager according to its maintainer Maximilian Roos. The project is dual-licensed under MIT OR Apache-2.0.

The tool addresses a specific workflow shift: AI agents like Claude Code and Codex now handle longer tasks unsupervised, making it practical to run 5-10+ agents simultaneously. Git worktrees provide the isolation mechanism, but native commands require typing branch names multiple times, manually managing paths, and tracking which worktree contains what changes.

Worktrunk abstracts this complexity by addressing worktrees through branch names and computing paths from configurable templates. It includes shell integration for directory changes, hooks for workflow automation, and features specifically designed for agent-driven development like LLM-generated commit messages and CI status integration.

Key Features

Branch-centric addressing. Worktrunk identifies worktrees by branch name rather than path. The wt switch feat command replaces cd ../repo.feat, eliminating the mental overhead of path tracking.

Single-command creation and agent launch. The -c flag creates a branch and worktree; -x executes a command after switching. Combined, wt switch -c -x claude feat replaces three separate Git, shell, and agent invocations.

Automated cleanup. wt remove handles both worktree removal and branch deletion, checking whether commits have been merged or pushed before destructive operations.

Workflow hooks. Post-create, pre-merge, post-merge, and other hook types automate repetitive setup: dependency installation, dev server startup, build cache copying between worktrees.

LLM commit generation. The tool can generate commit messages from diffs, reducing context-switching when reviewing agent output.

Rich listing with context. wt list --full shows branch status, commit counts relative to main, CI status, and AI-generated summaries per branch—information scattered across multiple Git commands and browser tabs.

Template-based configuration. Path templates support filters like hash_port for assigning unique dev server ports per worktree, preventing collisions when running multiple services.

Use Cases

Parallel agent orchestration. The primary use case: launch Claude Code or similar agents in separate worktrees with distinct tasks. Each agent operates in isolation, changes are branch-scoped, and the human developer switches between contexts with single commands.

Feature branch isolation. Traditional development benefits from worktrees when builds are slow or stateful. A Rust project with long compile times can maintain a worktree per feature without rebuilding from cold—Worktrunk's wt step copy-ignored shares target/ directories between worktrees.

Review and merge automation. The wt merge command squashes, rebases onto main, fast-forwards, and cleans up in one operation. For teams using PR workflows, hooks can trigger CI checks or notifications at defined lifecycle points.

Multi-service development. The hash_port template filter assigns deterministic ports per worktree, enabling multiple full-stack environments without manual port management.

PR-driven workflows. wt switch pr:123 checks out the branch for a specific pull request, streamlining review of contributor changes or CI failures.

Installation & Setup

Homebrew (macOS & Linux):

brew install worktrunk && wt config shell install

The wt config shell install step enables shell integration, allowing Worktrunk commands to change the working directory—essential for the wt switch workflow.

Cargo:

cargo install worktrunk && wt config shell install

Windows (Winget):

winget install max-sixty.worktrunk
git-wt config shell install

Note: wt conflicts with Windows Terminal's default alias. The Winget package installs git-wt as an alternative. To use wt directly, disable Windows Terminal's app execution alias in Settings → Apps → Advanced app settings.

Arch Linux:

sudo pacman -S worktrunk && wt config shell install

Conda / Pixi (community-maintained):

conda install -c conda-forge worktrunk && wt config shell install

Or with Pixi: pixi global install worktrunk && wt config shell install.

After installation, verify with wt --help. The shell integration is not optional for core functionality—without it, wt switch cannot change directories.

Real Code Examples

Creating and switching to a new worktree:

$ wt switch --create feature-auth
✓ Created branch feature-auth from main and worktree @ ~/repo.feature-auth

This single command creates the branch, adds the worktree at a path computed from the template (default: ~/repo.<branch-name>), and switches to it. The shell integration handles the directory change.

Listing worktrees with status:

$ wt list
  Branch        Status        HEAD±    main↕     main…±  Remote⇅  Commit    Age   Message
@ feature-auth  +   ↑      +27   -8   ↑1       +31                4bc72dc9  2h    Add authenticat…
^ main              ^⇡                                    ⇡1      0e631add  1d    Initial commit

○ Showing 2 worktrees, 1 with changes, 1 ahead, 1 column hidden

The @ marks current worktree; + indicates staged changes; ↑1 means one commit ahead of main; signals unpushed commits. This replaces git worktree list (paths only) with actionable context.

Launching 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'

The -x flag runs the specified command after switching; arguments after -- pass through. Post-start hooks can automate dependency installation and dev server startup per worktree.

Local merge with cleanup:

$ wt merge main
◎ Generating commit message and committing changes... (2 files, +53, no squashing needed)
  Add authentication module
✓ Committed changes @ a1b2c3d
◎ Merging 1 commit to main @ a1b2c3d (no rebase needed)
  * a1b2c3d Add authentication module
   auth.rs | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
   lib.rs  |  2 ++
   2 files changed, 53 insertions(+)
✓ Merged to main (1 commit, 2 files, +53)
◎ Removing feature-auth worktree & branch in background (same commit as main, _)
○ Switched to worktree for main @ ~/repo

This demonstrates the full lifecycle: commit generation, merge to main, and automatic cleanup. The background removal avoids blocking the shell.

Advanced Usage & Best Practices

Configure hooks for agent handoffs. The [INTERNAL_LINK: CI/CD automation] pattern applies here: define post-create hooks that install dependencies, copy build caches, and start dev servers. This ensures each agent starts from a warm state.

Use wt list --full for dashboard-like visibility. Enable CI status and LLM summaries to assess which branches need attention without switching contexts. This is particularly valuable when managing 5+ parallel agents.

Template customization for team conventions. The default path template may not suit monorepos or specific directory structures. Review wt config options to align with existing conventions.

Aliases for repeated patterns. Define custom wt <name> commands for frequently used flags or hook sequences. Per-branch variables allow template customization scoped to specific feature types.

Build cache strategy. The wt step copy-ignored command shares target/, node_modules/, and similar directories. Use this to avoid cold-start compilation in Rust, Node.js, or similar ecosystems. Verify cache validity across worktrees—stale artifacts can cause subtle build failures.

Comparison with Alternatives

Tool Approach Best For
max-sixty/worktrunk Branch-centric CLI with agent workflow features Parallel AI agents, automated hooks, team standardization
Plain git worktree Native Git, manual path/branch management Occasional use, minimal dependencies, full control
stgit Patch stack management on single branch Incremental patch workflows, not parallel isolation
git-worktree-plus (shell scripts) Community shell wrappers Simple automation, no Rust toolchain requirement

Worktrunk's differentiation is explicit agent integration: the -x flag for command execution, LLM commit messages, and CI status in listings. For developers running one or two occasional worktrees, native Git may suffice. For teams standardizing parallel agent workflows, Worktrunk's conventions reduce friction and cognitive load.

FAQ

Does Worktrunk replace Git entirely? No—it wraps git worktree and related commands. Git knowledge remains necessary.

Is the shell integration safe? It modifies shell configuration to enable directory changes. Review what wt config shell install adds before running.

Can I use Worktrunk without AI agents? Yes. The worktree simplification benefits any parallel branch workflow.

What license applies? MIT OR Apache-2.0, dual-licensed. Choose either.

Does it work with large repositories? Performance depends on Git worktree performance; Worktrunk itself is Rust-native and lightweight.

Can I customize the path template? Yes, through configuration. See wt config and documentation at worktrunk.dev.

Is Windows fully supported? Yes, with the git-wt alias workaround for the wt naming conflict.

Conclusion

max-sixty/worktrunk addresses a genuine workflow evolution: AI agents capable of extended unsupervised work make parallel development practical, but Git's native worktree interface creates friction at scale. The Rust CLI reduces this to branch-level simplicity while adding automation hooks, status visibility, and agent-specific conveniences.

It suits developers and teams already using Claude Code, Codex, or similar tools who want structured isolation without path-management overhead. The 5,850-star adoption suggests broad resonance with this need.

For installation, documentation, and issue tracking, visit https://github.com/max-sixty/worktrunk. Report friction points—the maintainer explicitly requests them as primary input for improvements.

Comments (0)

Comments are moderated before appearing.

No comments yet. Be the first to share your thoughts!

Recommended Prompts

View All