max-sixty / worktrunk
本文为原文前 6,000 字符的节选翻译,完整内容请查看原文。
Worktrunk November 2026: Worktrunk was released at the start of the year, and has quickly become the most popular git worktree manager. It’s built with love (there’s no slop!). Please let me know any frictions at all; I’m intensely focused on continuing to make Worktrunk excellent, and the biggest help is folks posting problems they perceive.
Worktrunk 2026 年 11 月:Worktrunk 于年初发布,并迅速成为最受欢迎的 git worktree 管理器。它是用心打造的(绝无敷衍!)。如有任何使用上的不便,请务必告知;我正专注于持续优化 Worktrunk,而用户反馈所遇到的问题是对我最大的帮助。
Worktrunk is a CLI for git worktree management, designed for running AI agents in parallel. Worktrunk’s three core commands make worktrees as easy as branches. Plus, Worktrunk has a bunch of quality-of-life features to simplify working with many parallel changes, including hooks to automate local workflows & copy-on-write build caches.
Worktrunk 是一个用于 git worktree 管理的命令行工具,专为并行运行 AI 代理而设计。Worktrunk 的三个核心命令让 worktree 的使用像分支一样简单。此外,Worktrunk 还具备一系列提升体验的功能,以简化多项并行更改的工作,包括用于自动化本地工作流的钩子(hooks)以及写时复制(copy-on-write)构建缓存。
A quick demo: 📚 Full documentation at worktrunk.dev 📚 Context: git worktrees AI agents like Claude Code and Codex can handle longer tasks without supervision, such that it’s possible to manage 5-10+ in parallel. Git’s native worktree feature gives each agent its own working directory, so they don’t step on each other’s changes. But the git worktree UX is clunky. Even a task as small as starting a new worktree requires typing the branch name three times: git worktree add -b feat ../repo.feat, then cd ../repo.feat.
快速演示:📚 完整文档请访问 worktrunk.dev 📚 背景:git worktrees。像 Claude Code 和 Codex 这样的 AI 代理可以在无人监督的情况下处理较长的任务,因此可以同时管理 5-10 个以上的任务。Git 原生的 worktree 功能为每个代理提供独立的目录,从而避免它们相互干扰。但 git worktree 的用户体验较为繁琐。即使是创建一个新的 worktree 这样的小任务,也需要输入三次分支名称:git worktree add -b feat ../repo.feat,然后执行 cd ../repo.feat。
Worktrunk makes git worktrees as easy as branches. Worktrees are addressed by branch name; paths are computed from a configurable template. Commands that take a branch also accept the path of the worktree it is checked out in.
Worktrunk 让 git worktree 的使用像分支一样简单。Worktree 通过分支名称进行寻址;路径则根据可配置的模板自动计算。接受分支名称的命令同样支持接受该分支所在 worktree 的路径。
Start with the core commands. Core commands:
| Task | Worktrunk | Plain git |
|---|---|---|
| Switch worktrees | wt switch feat | cd ../repo.feat |
| Create + start Claude | wt switch -c -x claude feat | git worktree add -b feat ../repo.feat && cd ../repo.feat && claude |
| Clean up | wt remove | cd ../repo && git worktree remove ../repo.feat && git branch -d feat |
| List with status | wt list | git worktree list (paths only) |
从核心命令开始。核心命令:
| 任务 | Worktrunk | 原生 git |
|---|---|---|
| 切换 worktree | wt switch feat | cd ../repo.feat |
| 创建并启动 Claude | wt switch -c -x claude feat | git worktree add -b feat ../repo.feat && cd ../repo.feat && claude |
| 清理 | wt remove | cd ../repo && git worktree remove ../repo.feat && git branch -d feat |
| 列出状态 | wt list | git worktree list (仅路径) |
Expand into the more advanced commands as needed. Workflow automation: Hooks — run commands on create, pre-merge, post-merge, etc. LLM commit messages — generate commit messages from diffs. Merge workflow — squash, rebase, merge, clean up in one command. Interactive picker — browse worktrees with streaming CI status and diff, log, PR and comment previews. Share build caches — ten worktrees get target/, node_modules/, etc without building or copying them (on APFS, btrfs, and XFS). wt list —full — CI status and AI-generated summaries per branch. PR checkout — wt switch pr:123 to jump straight to a PR’s branch. Dev server per worktree — hash_port template filter gives each worktree a unique port. Aliases & per-branch variables — custom wt
根据需要使用更高级的命令。工作流自动化:钩子(Hooks)—— 在创建、合并前、合并后等阶段运行命令。LLM 提交信息 —— 根据差异生成提交信息。合并工作流 —— 一条命令完成压缩、变基、合并和清理。交互式选择器 —— 浏览 worktrees,并实时查看 CI 状态、差异、日志、PR 和评论预览。共享构建缓存 —— 十个 worktree 可以共享 target/、node_modules/ 等目录,无需重复构建或复制(支持 APFS、btrfs 和 XFS)。wt list —full —— 查看每个分支的 CI 状态和 AI 生成的摘要。PR 检出 —— 使用 wt switch pr:123 直接跳转到 PR 的分支。每个 worktree 的开发服务器 —— hash_port 模板过滤器为每个 worktree 分配唯一端口。别名与分支变量 —— 自定义 wt <name> 命令以及用于钩子模板的分支作用域状态……以及更多功能。
Multiple parallel agents, same simple commands: Install Homebrew (macOS & Linux): brew install worktrunk && wt config shell install. Shell integration allows commands to change directories. Cargo: cargo install worktrunk && wt config shell install. Windows & other: Windows. wt defaults to Windows Terminal’s command, so Winget additionally installs Worktrunk as git-wt to avoid the conflict: winget install max-sixty.worktrunk git-wt config shell install. Alternatively, disable Windows Terminal’s alias (Settings → Apps → Advanced app settings → App execution aliases → “Terminal”/“Terminal Preview”) to use wt directly. Free code signing provided by SignPath.io, certificate by SignPath Foundation — policy. Arch Linux: sudo pacman -S worktrunk && wt config shell install. Conda / Pixi (community-maintained feedstock): conda install -c conda-forge worktrunk && wt config shell install. Or with Pixi: pixi global install worktrunk && wt config shell install.
多个并行代理,同样的简单命令:安装 Homebrew (macOS & Linux):brew install worktrunk && wt config shell install。Shell 集成允许命令更改目录。Cargo:cargo install worktrunk && wt config shell install。Windows 及其他:Windows 系统中,wt 默认为 Windows Terminal 的命令,因此 Winget 会将 Worktrunk 安装为 git-wt 以避免冲突:winget install max-sixty.worktrunk,然后执行 git-wt config shell install。或者,禁用 Windows Terminal 的别名(设置 → 应用 → 高级应用设置 → 应用执行别名 → “Terminal”/“Terminal Preview”)以直接使用 wt。免费代码签名由 SignPath.io 提供,证书由 SignPath Foundation 提供 — 政策。Arch Linux:sudo pacman -S worktrunk && wt config shell install。Conda / Pixi(社区维护的源):conda install -c conda-forge worktrunk && wt config shell install。或者使用 Pixi:pixi global install worktrunk && wt config shell install。
Quick start: Create a worktree for a new feature: $ wt switch —create feature-auth ✓ Created branch feature-auth from main and worktree @ ~/repo.feature-auth. This creates a new branch and worktree, then switches to it. Do your work, then check all worktrees with wt list: $ wt list.
快速入门:为新功能创建 worktree:$ wt switch --create feature-auth ✓ 从 main 创建了分支 feature-auth 和 worktree @ ~/repo.feature-auth。这会创建一个新分支和 worktree,然后切换到该目录。完成工作后,使用 wt list 检查所有 worktree:$ wt list。
When done, either: PR workflow — commit, push, open a PR, merge via GitHub/GitLab, then clean up: wt step commit # commit staged changes, gh pr create # or glab mr create, wt remove # after PR is merged. Local merge — squash, rebase onto main, fast-forward merge, clean up: $ wt merge main.
完成后,可以选择:PR 工作流 —— 提交、推送、开启 PR、通过 GitHub/GitLab 合并,然后清理:wt step commit(提交暂存更改)、gh pr create(或 glab mr create)、wt remove(PR 合并后)。本地合并 —— 压缩、变基到 main、快进合并、清理:$ wt merge main。
For parallel agents, create multiple worktrees and launch an agent in each: 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 a command after switching; arguments after — are passed to it. Configure post-start hooks to automate setup (install deps, start dev servers).
对于并行代理,创建多个 worktree 并在每个中启动一个代理: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'。-x 标志在切换后运行命令;-- 之后的参数会传递给该命令。配置启动后钩子以自动化设置(安装依赖、启动开发服务器)。
Next steps: Learn the core commands: wt switch, wt list, wt merge, wt remove. Set up hooks for automated setup. Explore LLM commit messages, interactive picker, Claude Code integration, CI status & PR links. Browse tips & patterns for recipes: aliases, dev servers, databases, agent handoffs, and more. Extending Worktrunk — customize workflows with hooks & aliases. Watch @DevOpsToolbox’s video on Worktrunk. Run wt —help or wt
后续步骤:学习核心命令:wt switch、wt list、wt merge、wt remove。设置钩子以实现自动化配置。探索 LLM 提交信息、交互式选择器、Claude Code 集成、CI 状态和 PR 链接。浏览技巧和模式:别名、开发服务器、数据库、代理移交等。扩展 Worktrunk —— 通过钩子和别名自定义工作流。观看 @DevOpsToolbox 关于 Worktrunk 的视频。运行 wt --help 或 wt <command> --help 获取快速 CLI 参考。贡献:⭐ 给仓库加星,向朋友推荐 Worktrunk,提交 Issue —— 反馈、功能请求等。