isolate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseIsolate
隔离工作树
Create a worktree branched from the latest so task work never starts on stale code.
origin/mainAnnounce: "Setting up an isolated worktree for this task."
从最新的分支创建工作树,确保任务工作不会基于陈旧代码启动。
origin/main提示语: "正在为该任务设置隔离工作树。"
Inputs
输入参数
- Branch name: from Step 1 (e.g.,
/orient,feat/auth). Ask if not provided.fix/login-crash - Base ref: (default). Different base only when explicitly stacking on another feature branch.
origin/main
- 分支名称: 来自步骤1(例如:
/orient、feat/auth)。若未提供则询问用户。fix/login-crash - 基准分支: (默认值)。仅当明确需要基于其他功能分支堆叠开发时才使用不同基准。
origin/main
Already in a Worktree?
已处于工作树中?
If the session CWD is already inside a linked worktree (not the primary), freshen the branch instead of creating a new one:
bash
WORKTREE="<absolute-path-to-current-worktree>"
git -C "$WORKTREE" fetch origin main
git -C "$WORKTREE" merge origin/mainIf conflicts arise, stop and present them to the user. Do not auto-resolve.
After freshening, skip ahead to Baseline test.
如果当前会话的工作目录已位于关联工作树中(非主工作树),则更新分支而非创建新工作树:
bash
WORKTREE="<absolute-path-to-current-worktree>"
git -C "$WORKTREE" fetch origin main
git -C "$WORKTREE" merge origin/main若出现冲突,立即停止并将冲突展示给用户,请勿自动解决。
更新完成后,直接跳至基准测试环节。
Step 1: Select directory
步骤1:选择目录
| Priority | Check | Action |
|---|---|---|
| 1 | | Use it |
| 2 | | Use it |
| 3 | Both exist | |
| 4 | CLAUDE.md specifies | Follow preference |
| 5 | None found | Ask user ( |
| 优先级 | 检查项 | 操作 |
|---|---|---|
| 1 | | 使用该目录 |
| 2 | | 使用该目录 |
| 3 | 两个目录都存在 | 优先使用 |
| 4 | CLAUDE.md 文件中有指定 | 遵循文件中的偏好设置 |
| 5 | 未找到任何目录 | 询问用户(推荐使用 |
Step 2: Verify gitignored
步骤2:验证是否已加入.gitignore
bash
git check-ignore -q .worktreesIf NOT ignored, fix before proceeding:
bash
echo ".worktrees" >> .gitignore
git add .gitignore
git commit -m "chore: gitignore worktree directory"bash
git check-ignore -q .worktrees若未被忽略,则在继续操作前修复:
bash
echo ".worktrees" >> .gitignore
git add .gitignore
git commit -m "chore: gitignore worktree directory"Step 3: Fetch and create
步骤3:拉取代码并创建工作树
A worktree branched from a stale local means baked-in merge conflicts. Always fetch first, always branch from .
mainorigin/mainbash
REPO_ROOT="$(git rev-parse --show-toplevel)"
WORKTREE_DIR="$REPO_ROOT/.worktrees/<name>"
git fetch origin main
git worktree add "$WORKTREE_DIR" -b <prefix>/<name> origin/mainClaude Code: optionally call to move session CWD into the new worktree.
EnterWorktree({path})基于陈旧本地分支创建工作树会导致潜在的合并冲突。请始终先拉取代码,且始终从分支创建工作树。
mainorigin/mainbash
REPO_ROOT="$(git rev-parse --show-toplevel)"
WORKTREE_DIR="$REPO_ROOT/.worktrees/<name>"
git fetch origin main
git worktree add "$WORKTREE_DIR" -b <prefix>/<name> origin/mainClaude Code:可选择调用将会话工作目录切换至新工作树。
EnterWorktree({path})Step 4: Install dependencies
步骤4:安装依赖
Auto-detect from manifest files:
| File | Command |
|---|---|
| |
| |
| |
| Ask before installing |
| |
| |
| |
| |
Run from the worktree path:
pnpm --dir "$WORKTREE_DIR" install根据清单文件自动检测:
| 文件 | 命令 |
|---|---|
| |
| |
| |
| 安装前询问用户 |
| |
| |
| |
| |
从工作树路径执行:
pnpm --dir "$WORKTREE_DIR" installStep 5: Baseline test
步骤5:基准测试
Run the project's test suite. If tests fail, report failures and ask whether to proceed. Do not silently continue.
运行项目的测试套件。若测试失败,报告失败情况并询问用户是否继续,请勿静默执行后续操作。
Report
报告
Worktree ready at <absolute-path>
Branch: <prefix>/<name> (from origin/main @ <short-sha>)
Tests: <N> passing工作树已准备就绪,路径:<绝对路径>
分支:<prefix>/<name>(基于origin/main @ <短哈希值>)
测试结果:<N> 项通过Path Discipline
路径规范
cdgit -C <abs-path>cdgit -C <绝对路径>Integration
集成关系
Called by: /task (Step 2), /brainstorming, /executing-plans, /subagent-driven-development
Pairs with: /ship (cleans up worktree after work is done)
Replaces: using-git-worktrees (superpowers)
被调用方: /task(步骤2)、/brainstorming、/executing-plans、/subagent-driven-development
配套使用: /ship(工作完成后清理工作树)
替代方案: using-git-worktrees(增强版)