isolate

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Isolate

隔离工作树

Create a worktree branched from the latest
origin/main
so task work never starts on stale code.
Announce: "Setting up an isolated worktree for this task."
从最新的
origin/main
分支创建工作树,确保任务工作不会基于陈旧代码启动。
提示语: "正在为该任务设置隔离工作树。"

Inputs

输入参数

  • Branch name: from
    /orient
    Step 1 (e.g.,
    feat/auth
    ,
    fix/login-crash
    ). Ask if not provided.
  • Base ref:
    origin/main
    (default). Different base only when explicitly stacking on another feature branch.
  • 分支名称: 来自
    /orient
    步骤1(例如:
    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/main
If 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:选择目录

PriorityCheckAction
1
.worktrees/
exists
Use it
2
worktrees/
exists
Use it
3Both exist
.worktrees/
wins
4CLAUDE.md specifiesFollow preference
5None foundAsk user (
.worktrees/
recommended)
优先级检查项操作
1
.worktrees/
目录存在
使用该目录
2
worktrees/
目录存在
使用该目录
3两个目录都存在优先使用
.worktrees/
4CLAUDE.md 文件中有指定遵循文件中的偏好设置
5未找到任何目录询问用户(推荐使用
.worktrees/

Step 2: Verify gitignored

步骤2:验证是否已加入.gitignore

bash
git check-ignore -q .worktrees
If 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
main
means baked-in merge conflicts. Always fetch first, always branch from
origin/main
.
bash
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/main
Claude Code: optionally call
EnterWorktree({path})
to move session CWD into the new worktree.
基于陈旧本地
main
分支创建工作树会导致潜在的合并冲突。请始终先拉取代码,且始终从
origin/main
分支创建工作树。
bash
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/main
Claude Code:可选择调用
EnterWorktree({path})
将会话工作目录切换至新工作树。

Step 4: Install dependencies

步骤4:安装依赖

Auto-detect from manifest files:
FileCommand
pnpm-lock.yaml
pnpm install
yarn.lock
yarn install
package-lock.json
npm install
package.json
(no lockfile)
Ask before installing
Cargo.toml
cargo build
requirements.txt
pip install -r requirements.txt
pyproject.toml
poetry install
go.mod
go mod download
Run from the worktree path:
pnpm --dir "$WORKTREE_DIR" install
根据清单文件自动检测:
文件命令
pnpm-lock.yaml
pnpm install
yarn.lock
yarn install
package-lock.json
npm install
package.json
(无锁文件)
安装前询问用户
Cargo.toml
cargo build
requirements.txt
pip install -r requirements.txt
pyproject.toml
poetry install
go.mod
go mod download
从工作树路径执行:
pnpm --dir "$WORKTREE_DIR" install

Step 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

路径规范

cd
does not persist between Claude Code Bash calls. Use absolute paths for all file operations and
git -C <abs-path>
for git commands.
cd
命令在Claude Code的Bash调用之间不会持久生效。所有文件操作请使用绝对路径,Git命令请使用
git -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(增强版)