Agent skill

Git Worktree Isolation

by jnMetaCode in jnMetaCode/superpowers-zh

Sets up an isolated workspace before feature work or plan execution, preferring native worktree tools and falling back to git worktree, with instructions in Chinese.

MITAuto-check passedDevelopment

SKILL.md written in Chinese; this summary is our English description.

Install Git Worktree Isolation

skills CLI
$ npx skills add jnMetaCode/superpowers-zh --skill using-git-worktrees -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install jnMetaCode/superpowers-zh using-git-worktrees --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/jnMetaCode/superpowers-zh.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/using-git-worktrees .claude/skills/using-git-worktrees && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
using-git-worktrees
GitHub stars
8.3k
Used in
1 other repo
Token cost
~982 tokens
SKILL.md length
245 words
Files
1
Skills in repo
21
Repo updated
First seen
Licence
MIT

At a glance

Sets up an isolated workspace before feature work or plan execution, preferring native worktree tools and falling back to git worktree, with instructions in Chinese.

  • Works in 3 steps: 检查你的 instructions 里是否声明过 worktree 目录偏好。… → 检查是否存在项目本地的 worktree 目录 → 如果没有其他可参考的信息,默认用项目根目录下的 .worktrees/。
  • Starting feature work that should stay isolated from the current branch
  • SKILL.md covers 概述, 步骤 0:检测现有隔离, 步骤 1:创建隔离工作区 and 步骤 2:项目设置, plus 3 more sections
  • Calls git and npm

What it does

A Chinese translation of a worktree setup workflow. It first detects whether you are already in a linked worktree by comparing the git dir and the common git dir, with a guard so that submodules are not mistaken for worktrees, and it does not create another worktree if you are. In a normal checkout it asks for consent unless you have already stated a preference.

Creation tries the platform's native worktree tool first, such as EnterWorktree, WorktreeCreate, a /worktree command or a --worktree flag, and only then falls back to git worktree add, to avoid phantom state the harness cannot manage. The fallback chooses .worktrees or worktrees, defaulting to .worktrees, and verifies that the directory is ignored by git before creating anything, adding it to .gitignore if not. If a sandbox refuses creation, the agent works in place. After that it runs project setup such as npm install and checks that the baseline tests pass.

When your agent uses it

  • Starting feature work that should stay isolated from the current branch
  • Before executing an implementation plan
  • Checking whether you are already inside a worktree

Example prompts

  • “Set up an isolated worktree for this feature before we start.”
  • “Am I already in a git worktree or a submodule?”
  • “Create the worktree in .worktrees and make sure it's gitignored.”

Requirements

  • Git

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

  1. 检查你的 instructions 里是否声明过 worktree 目录偏好。 如果用户已指定,不再询问直接用。
  2. 检查是否存在项目本地的 worktree 目录
  3. 如果没有其他可参考的信息,默认用项目根目录下的 .worktrees/。

What it can do on your machine

Read from SKILL.md and the folder at commit fe34019. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • git
    • npm

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git and npm, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Git Worktree Isolation loads about 982 tokens when it runs. Until then it costs about 22 tokens; SKILL.md has 245 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~22
When it runs · the whole SKILL.md, loaded when a task matches
~982

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from jnMetaCode/superpowers-zh at commit fe34019, republished under its MIT licence (© jnMetaCode). 245 words, ~982 tokens.

Download SKILL.mdSave it as .claude/skills/using-git-worktrees/SKILL.md (or your agent's skills folder).
name
using-git-worktrees
description
当需要开始与当前工作区隔离的功能开发,或在执行实现计划之前使用——通过原生工具或 git worktree 回退机制确保隔离工作区存在
version
1.0.0
license
MIT

使用 Git 工作树

概述

确保工作发生在隔离的工作区中。优先使用你的平台的原生 worktree 工具。仅在没有原生工具可用时,再回退到手动 git worktree。

核心原则: 先检测现有隔离。然后用原生工具。再回退到 git。绝不与 harness 对抗。

开始时宣布: "我正在使用 using-git-worktrees 技能来建立一个隔离的工作区。"

步骤 0:检测现有隔离

创建任何东西之前,先检查你是否已经在一个隔离的工作区里。

bash
GIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P)
GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P)
BRANCH=$(git branch --show-current)

Submodule 守卫: 在 git submodule 内 GIT_DIR != GIT_COMMON 也为真。在判定"已经在 worktree 内"之前,先确认你不在 submodule 里:

bash
# 如果这条命令返回路径,说明你在 submodule 里,不是 worktree —— 按普通仓库处理
git rev-parse --show-superproject-working-tree 2>/dev/null

如果 GIT_DIR != GIT_COMMON(且不是 submodule): 你已经在一个 linked worktree 内。跳到步骤 2(项目设置)。不要再创建一个 worktree。

按分支状态报告:

  • 在某个分支上:"已经在隔离工作区 <path>,分支 <name>。"
  • 分离 HEAD:"已经在隔离工作区 <path>(分离 HEAD,由外部管理)。完成时需要创建分支。"

如果 GIT_DIR == GIT_COMMON(或在 submodule 内): 你在一个普通的仓库检出里。

用户是否已经在你的 instructions 里表明过 worktree 偏好?如果没有,创建 worktree 之前先征求同意:

"你希望我搭一个隔离的 worktree 吗?它能保护你当前分支不被改动。"

如果用户已声明过偏好,直接遵循,不再询问。如果用户拒绝同意,原地工作并跳到步骤 2。

步骤 1:创建隔离工作区

你有两种机制。按这个顺序尝试。

1a. 原生 Worktree 工具(首选)

用户已经请求隔离工作区(步骤 0 已获同意)。你是否已经有创建 worktree 的方法?可能是名为 EnterWorktree、WorktreeCreate 的工具、/worktree 命令,或 --worktree 标志。如果有,用它,然后跳到步骤 2。

原生工具自动处理目录放置、分支创建和清理。在你已经有原生工具的情况下使用 git worktree add,会创建你的 harness 看不到也无法管理的"幻影状态"。

只有在没有原生 worktree 工具可用时,才进入步骤 1b。

1b. Git Worktree 回退

只在步骤 1a 不适用时使用 —— 你没有可用的原生 worktree 工具。手动用 git 创建 worktree。

目录选择

按以下优先级。明确的用户偏好始终优先于观察到的文件系统状态。

  1. 检查你的 instructions 里是否声明过 worktree 目录偏好。 如果用户已指定,不再询问直接用。

  2. 检查是否存在项目本地的 worktree 目录:

    bash
    ls -d .worktrees 2>/dev/null     # 首选(隐藏目录)
    ls -d worktrees 2>/dev/null      # 备选

    找到就用。如果两者都存在,.worktrees 优先。

  3. 如果没有其他可参考的信息,默认用项目根目录下的 .worktrees/。

安全验证(仅项目本地目录)

创建 worktree 前必须验证目录已被忽略:

bash
git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null

如果未被忽略: 添加到 .gitignore,提交该改动,然后继续。

为什么关键: 防止 worktree 内容被意外提交到仓库。

创建工作树
bash
# 根据选定位置确定路径
path="$LOCATION/$BRANCH_NAME"

git worktree add "$path" -b "$BRANCH_NAME"
cd "$path"

沙盒回退: 如果 git worktree add 因权限错误(沙盒拒绝)失败,告诉用户沙盒阻止了 worktree 创建,你将在当前目录原地工作。然后原地运行 setup 和基线测试。

步骤 2:项目设置

自动检测并运行相应的设置命令:

bash
# Node.js
if [ -f package.json ]; then npm install; fi

# Rust
if [ -f Cargo.toml ]; then cargo build; fi

# Python
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f pyproject.toml ]; then poetry install; fi

# Go
if [ -f go.mod ]; then go mod download; fi

步骤 3:验证基线干净

运行测试确保工作区初始状态干净:

bash
# 使用项目对应的命令
npm test / cargo test / pytest / go test ./...

如果测试失败: 报告失败,询问是继续还是排查。

如果测试通过: 报告就绪。

报告
工作树已就绪:<full-path>
测试通过(<N> 个测试,0 个失败)
准备实现 <feature-name>

快速参考

情况操作
已在 linked worktree 内跳过创建(步骤 0)
在 submodule 内按普通仓库处理(步骤 0 守卫)
有原生 worktree 工具用它(步骤 1a)
没有原生工具git worktree 回退(步骤 1b)
.worktrees/ 存在用它(验证已忽略)
worktrees/ 存在用它(验证已忽略)
两者都存在用 .worktrees/
都不存在检查 instructions 文件,再默认 .worktrees/
目录未被忽略添加到 .gitignore + 提交
创建时权限错误沙盒回退,原地工作
基线测试失败报告失败 + 询问
无 package.json/Cargo.toml跳过依赖安装

常见的合理化借口

借口现实
"我显然不在 worktree 里,不用检查"跑步骤 0。宿主环境创建的隔离和 submodule 都能骗过肉眼;只有检测命令能定论。
"git worktree add 比去找原生工具快"原生工具(如 EnterWorktree)掌管位置、分支和清理。绕过它是第一大错误 —— 会造出你的宿主环境看不见也管不了的幽灵状态。
"这个 worktree 目录肯定已经被忽略了"跑 git check-ignore。一个没被忽略的 worktree 目录会把整棵树提交进仓库。
"目录名随便取都行"明确指示 > 已存在的项目内目录 > .worktrees/ 默认值。
"工作区是全新的,基线测试可以先放放"基线不干净会让之后每一次失败都含义不明。现在就跑测试;越过失败继续是你人类伙伴的决定。

© jnMetaCode, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/using-git-worktrees of jnMetaCode/superpowers-zh.

Open the folder on GitHubat commit fe34019

Used in 1 other repository

We found 1 copy of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in jnMetaCode/superpowers-zh, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Git Worktree Isolation next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Git Worktree Isolation compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Git Worktree Isolation this skilljnMetaCode/superpowers-zh8.3k1 repos~982Automated safety check: PassMIT
Project Session ManagerYeachan-Heo/oh-my-claudecode40k—~4kAutomated safety check: PassMIT
Multi Agent Orchestrationcat-xierluo/legal-skills713—~6.6kAutomated safety check: PassMIT
Polyphonyalinaqi/maggy707—~980Automated safety check: PassMIT
Finishing a Development Branchobra/superpowers296k5 repos~1.9kAutomated safety check: PassMIT
Git Worktree Cleanuplobehub/lobehub83k—~2.8kAutomated safety check: PassCustom licence

Similar skills

  • Project Session Manager

    Yeachan-Heo/oh-my-claudecode

    Creates isolated git worktrees, with optional tmux sessions, for PR reviews, issue fixes and feature work across projects and repositories.

    40k GitHub stars~4k tokensUpdated today
    DevelopmentAuto-check passed
  • Multi Agent Orchestration

    cat-xierluo/legal-skills

    编排两个以上边界独立的本地 worker,使用 Orca Run/Task/Dispatch、独立 worktree/session 或 tmux 回退,由 PM 负责拆解、派发、巡检、429 停滞恢复、独立验收、PR 收口与临时资源清理;也用于用户明确要求“并行推进”“多个 worker”“PM 总控”“Wave Autopilot”或防止 PM…

    713 GitHub stars~6.6k tokensUpdated today
    DevelopmentAuto-check passed
  • Polyphony

    alinaqi/maggy

    Multi-agent orchestration with container-isolated workspaces — each agent session runs in its own Docker container with independent git branches

    707 GitHub stars~980 tokensUpdated 13 days ago
    DevelopmentAuto-check passed
  • Walks the last step of a branch: confirm tests pass, detect the git environment, ask how to integrate, carry out your choice and clean up the worktree.

    296k GitHub starsUsed in 5 repos~1.9k tokens
    DevelopmentAuto-check passed
  • Git Worktree Cleanup

    lobehub/lobehub

    Audits stale Git worktrees and branches with a bundled script, classifies each one, and deletes only after you approve the exact candidates.

    83k GitHub stars~2.8k tokensUpdated today
    DevelopmentAuto-check passed
  • Ccmanager Config

    kbwo/ccmanager

    Set up, review, or repair a CCManager config — .ccmanager.json at a git repository root, or the global ~/.config/ccmanager/config.json.

    1.3k GitHub stars~1.5k tokensUpdated 10 days ago
    DevelopmentAuto-check passed

More from jnMetaCode/superpowers-zh

All 21 skills in this repo
  • Brainstorming Before Building

    jnMetaCode/superpowers-zh

    Turns a rough idea into an approved design before any code is written, sorting the request into spike, bounded or architectural and enforcing an approval gate.

    8.3k GitHub stars~1.8k tokensUpdated 2 days ago
    Auto-check passed
  • Inline Plan Execution

    jnMetaCode/superpowers-zh

    Executes a written implementation plan task by task in the current session, with a progress ledger, test-first gates and one fresh-context review at the end.

    8.3k GitHub stars~2.5k tokensUpdated 2 days ago
    Auto-check passed
  • Agency Orchestrator Workflow Runner

    jnMetaCode/superpowers-zh

    Runs agency-orchestrator YAML workflows inside the current agent session, with the session's own model playing each role in turn and no API key needed.

    8.3k GitHub starsUsed in 1 repo~885 tokens
    Auto-check passed
  • Chinese Code Review Etiquette

    jnMetaCode/superpowers-zh

    Gives Chinese-language templates and priority labels for code review feedback, plus guidance on bilingual comments, commit messages and common team anti-patterns.

    8.3k GitHub stars~1.2k tokensUpdated 2 days ago
    Auto-check passed
  • Chinese Commit Conventions

    jnMetaCode/superpowers-zh

    Reference for Chinese-language git commits and changelogs: Conventional Commits adapted for Chinese teams, with templates, breaking-change notes and issue links for several platforms.

    8.3k GitHub stars~1.6k tokensUpdated 2 days ago
    Auto-check passed
  • Chinese Documentation Style Guide

    jnMetaCode/superpowers-zh

    Reference rules for typesetting Chinese technical documents: spacing around English and digits, punctuation, term handling, bilingual API docs and README layout.

    8.3k GitHub stars~1.6k tokensUpdated 2 days ago
    Auto-check passed

Works with

Questions about Git Worktree Isolation

What does Git Worktree Isolation do?

Sets up an isolated workspace before feature work or plan execution, preferring native worktree tools and falling back to git worktree, with instructions in Chinese. A Chinese translation of a worktree setup workflow. It first detects whether you are already in a linked worktree by comparing the git dir and the common git dir, with a guard so that submodules are not mistaken for worktrees, and it does not create another worktree if you are.

When should I use Git Worktree Isolation?

Git Worktree Isolation fits situations like: starting feature work that should stay isolated from the current branch; before executing an implementation plan; checking whether you are already inside a worktree.

How do I install Git Worktree Isolation in Claude Code?

Run `npx skills add jnMetaCode/superpowers-zh --skill using-git-worktrees -a claude-code`. Or copy the skill folder (skills/using-git-worktrees in jnMetaCode/superpowers-zh) into .claude/skills/using-git-worktrees in your project. Claude Code loads it when a task matches its description.

How do I install Git Worktree Isolation in Codex?

Run `npx skills add jnMetaCode/superpowers-zh --skill using-git-worktrees -a codex`. Or copy the skill folder (skills/using-git-worktrees in jnMetaCode/superpowers-zh) into .agents/skills/using-git-worktrees in your project. Codex loads it when a task matches its description.

Can I use Git Worktree Isolation in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add jnMetaCode/superpowers-zh --skill using-git-worktrees -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/using-git-worktrees, .gemini/skills/using-git-worktrees, .github/skills/using-git-worktrees and .opencode/skills/using-git-worktrees in your project.

What does Git Worktree Isolation need to run?

Going by SKILL.md and its folder, Git Worktree Isolation needs the command-line tools its instructions call (git and npm). Our summary lists: Git.

Does Git Worktree Isolation access the network?

SKILL.md contains no URLs. Its commands use git and npm, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Git Worktree Isolation safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Git Worktree Isolation use?

Git Worktree Isolation is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Git Worktree Isolation use?

About 982 tokens (SKILL.md is roughly 3.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Git Worktree Isolation?

Skills that share tags, products or a category with Git Worktree Isolation: Project Session Manager (Yeachan-Heo/oh-my-claudecode, 40k stars), Multi Agent Orchestration (cat-xierluo/legal-skills, 713 stars), Polyphony (alinaqi/maggy, 707 stars) and Finishing a Development Branch (obra/superpowers, 296k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Git Worktree Isolation?

jnMetaCode (a GitHub user) maintains it in jnMetaCode/superpowers-zh, which has 8,265 GitHub stars. The repository holds 21 skills in this directory. The repository was last updated on October 4, 2026.

Source: jnMetaCode/superpowers-zh on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.