展示HN:并行代码 – 使用工作树并行运行多个AI代理
我一直遇到一个与AI编码工具相关的结构性问题。
你尝试一个代理,它进行了一些更改。然后你再尝试另一个代理。现在你需要手动比较分支并清理实验性提交。
这些工具很强大,但工作流程并不是为比较而设计的。
因此,我构建了Parallel Code。
它本地运行Claude Code、Codex和Gemini CLI(没有API封装,没有功能抽象),但将每个代理隔离在:
- 自己的终端
- 自己的Git工作树
- 自己的功能分支
工作流程变成了:
- 创建N个工作树
- 每个工作树分配一个AI代理
- 让它们独立实现
- 比较差异
- 合并最佳结果
这样,你就可以进行并行探索,而不是顺序的试错,同时保持安全的隔离。
为什么不直接使用tmux?
可以,但你仍然需要手动管理:
- 分支创建
- 工作树清理
- 会话命名
- 上下文切换
Parallel Code自动化了Git结构,并保持会话的视觉组织。
这主要面向已经大量使用AI命令行工具的人。
我很好奇:是否还有其他人转向多代理并行工作流程,而不是单代理迭代?
GitHub: [https://github.com/johannesjo/parallel-code](https://github.com/johannesjo/parallel-code)
查看原文
I kept running into a structural problem with AI coding tools.
You try one agent. It makes changes. You try another. Now you're manually diffing branches and cleaning up experimental commits.
The tools are powerful, but the workflow isn’t designed for comparison.
So I built Parallel Code.
It runs Claude Code, Codex, and Gemini CLI natively (no API wrapper, no feature abstraction), but isolates each agent in:
its own terminal
its own Git worktree
its own feature branch
The workflow becomes:
Spawn N worktrees
Assign one AI agent per worktree
Let them implement independently
Compare diffs
Merge the best result
Instead of sequential trial-and-error, you get parallel exploration with safe isolation.
Why not just use tmux?
You can — but you still manually manage:
branch creation
worktree cleanup
session naming
context switching
Parallel Code automates the Git structure and keeps the sessions visually organized.
This is aimed at people already using AI CLIs heavily.
I’m curious: Has anyone else moved toward multi-agent parallel workflows instead of single-agent iteration?
GitHub: <a href="https://github.com/johannesjo/parallel-code" rel="nofollow">https://github.com/johannesjo/parallel-code</a>