Loading...
Loading...
Compare original and translation side by side
git worktreegit worktreegit worktree listgit worktree listundefinedundefined
If specified, create worktrees under that directory.
如果有指定配置,在该目录下创建worktree。../worktrees/<project-name>/<branch-name>../worktrees/<项目名称>/<分支名称>| Condition | Action |
|---|---|
| Worktree for this branch already exists | Navigate to existing worktree |
CLAUDE.md has | Use configured path |
| Project has existing worktrees | Use same parent directory pattern |
| No convention found | Ask user, suggest |
| User specifies path inside repo root | Warn — must add to |
| 条件 | 操作 |
|---|---|
| 目标分支对应的worktree已存在 | 直接进入已有worktree |
CLAUDE.md中配置了 | 使用配置的路径 |
| 项目已有现存的worktree | 沿用相同的父目录规则 |
| 未找到使用惯例 | 询问用户,建议路径为 |
| 用户指定的路径在仓库根目录内 | 发出警告 — 必须将该路径添加到 |
.gitignoreundefined.gitignoreundefined
If not ignored, warn the user and suggest adding it to `.gitignore`.
如果未被忽略,向用户发出警告并建议将其添加到`.gitignore`中。git status --porcelaingit status --porcelaingit worktree listgit worktree list| Check | Result | Action |
|---|---|---|
Path inside repo, not in | FAIL | Add to |
| Branch already in another worktree | FAIL | Use existing worktree |
| Working tree dirty | WARN | Inform user, ask preference |
| Path already exists (not worktree) | FAIL | Choose different path |
| All checks pass | PASS | Proceed to Phase 3 |
| 检查项 | 结果 | 操作 |
|---|---|---|
路径在仓库内,且未加入 | 不通过 | 先将路径添加到 |
| 分支已在其他worktree中检出 | 不通过 | 使用已有worktree |
| 工作树状态为脏 | 警告 | 告知用户,询问处理偏好 |
| 路径已存在(非worktree) | 不通过 | 选择其他路径 |
| 所有检查通过 | 通过 | 进入阶段3 |
undefinedundefined
Always tell the user the full path where the worktree was created:
**STOP — Confirm the worktree was created successfully before proceeding to setup.**
必须告知用户worktree创建的完整路径:
**暂停 — 继续后续设置前需先确认worktree创建成功。**| Indicator File | Ecosystem | Setup Command |
|---|---|---|
| Node.js (pnpm) | |
| Node.js (yarn) | |
| Node.js (npm) | |
| Node.js (npm) | |
| Python (poetry) | |
| Python (pip) | |
| Python (pip) | |
| Python (pip) | |
| Go | |
| Rust | |
| Ruby | |
| PHP | |
| 标识文件 | 技术栈 | 初始化命令 |
|---|---|---|
| Node.js (pnpm) | |
| Node.js (yarn) | |
| Node.js (npm) | |
| Node.js (npm) | |
| Python (poetry) | |
| Python (pip) | |
| Python (pip) | |
| Python (pip) | |
| Go | |
| Rust | |
| Ruby | |
| PHP | |
.env.example.env.templateundefined.env.example.env.templateundefinedundefinedundefinedundefinedundefined
Purpose:
- Confirms the worktree is set up correctly
- Establishes that all tests pass before changes are made
- Any test failures after this point are caused by your changes, not pre-existing issues
If baseline tests fail:
- Report the failures to the user
- Do NOT proceed with work until the baseline is understood
- The base branch may have broken tests that need addressing first
目的:
- 确认worktree配置正确
- 确认修改前所有测试均能通过
- 后续出现的测试失败均由你的修改导致,而非预存问题
如果基准测试失败:
- 向用户上报失败情况
- 基准问题确认前不得继续开发
- 可能是基分支本身存在损坏的测试,需要先修复Worktree ready:
Path: /Users/dev/worktrees/myproject/feature-auth
Branch: feature/auth-refactor
Base: main
Setup: npm install (completed)
Tests: 24 passed, 0 failedWorktree已就绪:
路径: /Users/dev/worktrees/myproject/feature-auth
分支: feature/auth-refactor
基分支: main
初始化: npm install (已完成)
测试: 24 passed, 0 failedundefinedundefinedundefinedundefinedgit worktree listgit worktree listundefinedundefinedundefinedundefined| Anti-Pattern | Why It Is Wrong | What to Do Instead |
|---|---|---|
| Creating duplicate worktree for same branch | Git does not allow it; wastes time | Check |
Worktree inside repo without | Worktree files show as untracked | Add path to |
| Skipping dependency install in worktree | Build/test failures from missing deps | Always run project setup |
| Skipping baseline test run | Cannot distinguish pre-existing vs new failures | Run tests before starting work |
| Assuming worktree has same env vars | | Copy and configure |
| Leaving stale worktrees after merge | Disk waste, confusing | Remove worktrees after branch completion |
| Force-removing worktree with uncommitted work | Permanent data loss | Commit or stash first |
| 反模式 | 错误原因 | 正确做法 |
|---|---|---|
| 为同一个分支创建重复的worktree | Git不支持该操作,浪费时间 | 先执行 |
Worktree在仓库内但未加入 | Worktree文件会被识别为未追踪文件 | 将路径添加到 |
| 跳过worktree的依赖安装步骤 | 缺少依赖会引发构建/测试失败 | 始终运行项目初始化命令 |
| 跳过基准测试运行 | 无法区分是预存问题还是新修改导致的失败 | 开始工作前先运行测试 |
| 假设worktree共享相同的环境变量 | | 复制并配置 |
| 合并后残留过时的worktree | 浪费磁盘空间, | 分支处理完成后移除对应worktree |
| 强制移除存在未提交工作的worktree | 永久丢失数据 | 先提交或暂存修改 |
| Skill | Integration |
|---|---|
| After completing work in a worktree, use this to merge or create a PR |
| Run agents in separate worktrees for true isolation |
| Validate work before leaving the worktree |
| Check CLAUDE.md for worktree directory preferences |
| Worktree creation is often the first step of plan execution |
| 技能 | 集成逻辑 |
|---|---|
| 完成worktree内的工作后,使用该技能合并代码或创建PR |
| 在独立的worktree中运行Agent实现真正的隔离 |
| 退出worktree前校验工作成果 |
| 检查CLAUDE.md获取worktree目录偏好配置 |
| 创建worktree通常是计划执行的第一步 |