boxmoe_header_banner_img

Hello! 欢迎来到阿虪的开发世界~

加载中

文章导读

worktrunk:让 Git worktree 像分支一样好用,并行跑多个 AI Agent 不打架


avatar
阿虪 4 11 月, 2026 223
worktrunk

中文版

worktrunk(GitHub:https://github.com/max-sixty/worktrunk ,2025-10-17 创建,今晨抓取时已 10,488★)是为并行 AI Agent 工作流设计的 Git worktree 管理 CLI:让每个 agent 各自拥有一个工作目录,互不踩对方的改动。

按 README 的说法,原生 git worktree 的体验很别扭:新建一个 worktree 要把分支名敲三遍,还要手动 cd 过去;worktrunk 把 worktree 按分支名寻址、路径按模板自动算,三个核心命令就让它像分支一样顺手:wt switch feat 切换、wt switch -c -x claude feat 建分支并直接起一个 Claude、wt remove 清理。进阶能力包括:创建/合并前后的 hooks、按 diff 生成 LLM 提交信息、一键 squash/rebase/合并清理、带 CI 状态与 diff 预览的交互选择器、APFS/btrfs/XFS 上的写时复制共享构建缓存(多个 worktree 共用 target/、node_modules/ 而不用重复构建或复制)、wt list --full 看每分支的 CI 状态与 AI 摘要、直接切到 PR 分支(wt switch pr:123)、每个 worktree 一个开发端口。Rust 编写,macOS 与 Linux 可用 brew install worktrunk 安装。

为什么值得了解

  • 同时跑 5 到 10 个 agent 已是常态,但没有隔离它们就会互相改同一批文件;worktree 是最干净的隔离方式,worktrunk 把它的门槛降到了分支操作的水平
  • 对 Mac 用户尤其友好:Homebrew 一条命令,配合 shell 集成就能切目录、起 agent、看状态一条龙
  • 它的“合并工作流”和“共享构建缓存”值得所有多分支开发者借鉴:并行开发的成本不在开分支,而在合并与重复构建,这两处它都做了减法

English Version

worktrunk (GitHub: https://github.com/max-sixty/worktrunk , created 2025-10-17, 10,488 stars at this morning’s fetch) is a Git worktree management CLI designed for parallel AI agent workflows: each agent gets its own working directory, so they stop stepping on each other’s changes.

Per the README, native git worktrees are clunky: starting one means typing the branch name three times and then changing directory by hand; worktrunk addresses worktrees by branch name and computes paths from a configurable template, so three core commands make them as easy as branches: wt switch feat to switch, wt switch -c -x claude feat to create a branch and start Claude in it, and wt remove to clean up. Advanced features include hooks on create and around merges, LLM-generated commit messages from diffs, a one-command squash/rebase/merge/clean-up workflow, an interactive picker with streaming CI status and diff previews, copy-on-write shared build caches on APFS, btrfs and XFS (several worktrees share target/, node_modules/ and more without rebuilding or copying), wt list --full for per-branch CI status and AI summaries, jumping straight to a PR branch (wt switch pr:123), and a dev server port per worktree. Written in Rust, installable on macOS and Linux with brew install worktrunk.

Why it’s worth knowing

  • Running 5 to 10 agents at once is now normal, but without isolation they edit the same files over each other; worktrees are the cleanest isolation, and worktrunk lowers their cost to the level of branch operations
  • Especially friendly to Mac users: one Homebrew command plus shell integration covers switching directories, starting agents and checking status
  • Its merge workflow and shared build cache are worth borrowing for any multi-branch developer: the cost of parallel development is not opening branches but merging and rebuilding, and both get lighter here


评论(0)

查看评论列表

暂无评论


发表评论

表情 颜文字

插入代码