worktree-parallel

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Worktree Parallel

并行Worktree使用

Workflow

工作流程

  1. Confirm the repo root (use current working directory unless the user specifies another repo).
  2. Determine a feature slug and branch name.
    • Default branch pattern:
      feature/<slug>
      .
    • If the user already has a branch name, use it.
  3. Choose a base directory for linked worktrees.
    • Default for this repo:
      ../<project_name>-wt
      (create it if missing).
  4. Create the worktree.
    • New branch:
      git worktree add -b feature/<slug> <base>/<slug>
    • Existing branch:
      git worktree add <base>/<slug> <branch>
  5. Bootstrap the new worktree dependencies.
    • cd <path> && pnpm run setup-worktree
    • If setup fails, resolve bootstrap issues before opening the parallel session.
  6. Open the worktree in the editor.
    • Use
      code -n <path>
      (Cursor supports the
      code
      CLI).
    • If
      code
      is unavailable, ask for the preferred editor command (e.g.,
      cursor -n
      ,
      code
      , or another).
  7. Suggest a parallel Codex session in the new worktree.
    • cd <path> && codex
  8. Confirm with
    git worktree list
    if needed.
  9. If the new session will run tests, start and use a dev server from that same worktree only, then stop it after tests.
  1. 确认仓库根目录(除非用户指定其他仓库,否则使用当前工作目录)。
  2. 确定功能标识(slug)和分支名称。
    • 默认分支格式:
      feature/<slug>
    • 如果用户已有分支名称,则使用该名称。
  3. 选择链接式worktree的基础目录。
    • 本仓库的默认路径:
      ../<project_name>-wt
      (如果不存在则创建)。
  4. 创建worktree。
    • 新分支:
      git worktree add -b feature/<slug> <base>/<slug>
    • 已有分支:
      git worktree add <base>/<slug> <branch>
  5. 引导新worktree的依赖安装。
    • cd <path> && pnpm run setup-worktree
    • 如果引导失败,先解决依赖安装问题再开启并行会话。
  6. 在编辑器中打开worktree。
    • 使用
      code -n <path>
      (Cursor支持
      code
      命令行工具)。
    • 如果
      code
      不可用,询问用户偏好的编辑器命令(例如
      cursor -n
      code
      或其他)。
  7. 建议在新worktree中开启并行Codex会话。
    • cd <path> && codex
  8. 如有需要,使用
    git worktree list
    确认。
  9. 如果新会话需要运行测试,仅在该worktree中启动并使用开发服务器,测试完成后停止服务器。

Safety

注意事项

  • Do not use
    --force
    unless the user explicitly asks.
  • Do not remove existing worktrees unless the user requests cleanup.
  • Do not stop dev servers you did not start.
  • 除非用户明确要求,否则不要使用
    --force
    参数。
  • 除非用户请求清理,否则不要删除已有的worktree。
  • 不要停止你未启动的开发服务器。

Optional Cleanup (only if asked)

可选清理操作(仅当用户要求时执行)

  • git worktree remove <path>
  • git branch -d <branch>
  • git worktree remove <path>
  • git branch -d <branch>