关于 parallel-worktrees
Parallel Worktrees 是一种在同一仓库中使用独立 Git worktree 运行多个 Claude Code 会话的协作模式。它介绍环境设置、编写与审查角色分工,以及保持并行任务隔离的清理方法。
主要功能
- 01为并行任务创建独立 worktree
- 02编写者与审查者会话模式
- 03列出和清理 worktree 的命令
适用场景
- 01一个会话实现功能,另一个会话审查代码
- 02隔离仓库中的并行任务
- 03移除已完成或过期的 worktree
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ thebeardedbearsas/ claude-craft --skill parallel-worktrees安装后在 Claude Code 中输入/parallel-worktrees确认已加载。
详细介绍
并行工作树
提高效率的模式,可在同一仓库中运行多个 Claude Code 会话。
详细文档请参阅 ../../rules/12-context-management.md。
快速参考
设置
# Create worktree for a feature branch
git worktree add ../feature-name feature/branch-name
# Launch Claude in the worktree
cd ../feature-name && claude
编写者/审阅者模式
| 终端 | 角色 | 命令 |
|---|---|---|
| 终端 1 | 编写者 | cd ../feature-auth && claude "Implement feature" |
| 终端 2 | 审阅者 | cd ../review-auth && claude "Review the code" |
最佳实践
- 最多使用 3-5 个工作树
- 一个工作树对应一个任务
- 移除已完成的工作树:
git worktree remove ../feature-name - 切勿在多个工作树之间共享会话
清理
# List all worktrees
git worktree list
# Remove a worktree
git worktree remove ../feature-name
# Prune stale worktree entries
git worktree prune
评论
支持 Markdown