using-git-worktrees

using-git-worktrees is a skill for Claude Code from Leodorareluctant259/superpowers-zh. It costs 39 tokens per session (1,590 once invoked), scanned A, a copy of using-git-worktrees, MIT.

Instructions for creating an isolated Git worktree, which is a separate working directory sharing the same repository history.

In plain words
What is it for?
Use it before isolated feature work to choose a safe directory, verify Git ignore settings, and create the worktree.
Why use it?
It lets you work on a feature or implementation plan without changing the files or branch in your main workspace.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: mentions CLAUDE.md; mentions subagents.

Part of the superpowers-zh plugin — 20 skills, 3 commands, 1 agent, 1 hook shipped together

Good fit Use it before isolated feature work to choose a safe directory, verify Git ignore settings, and create the worktree.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/leodorareluctant259/superpowers-zh/using-git-worktrees
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add Leodorareluctant259/superpowers-zh --skill using-git-worktrees
Clone the repo
git clone --depth 1 https://github.com/Leodorareluctant259/superpowers-zh

Made for: Claude Code.

Or install superpowers-zh, the plugin that ships this one along with the rest of its 20 skills, 3 commands, 1 agent, 1 hook.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for using-git-worktrees

README.md
[![agentmods](https://agentmods.dev/badge/skills/leodorareluctant259/superpowers-zh/using-git-worktrees/github.svg)](https://agentmods.dev/skills/leodorareluctant259/superpowers-zh/using-git-worktrees)
Your own site
<a href="https://agentmods.dev/skills/leodorareluctant259/superpowers-zh/using-git-worktrees"><img src="https://agentmods.dev/badge/skills/leodorareluctant259/superpowers-zh/using-git-worktrees/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for using-git-worktrees

Your own site · 80×15
<a href="https://agentmods.dev/skills/leodorareluctant259/superpowers-zh/using-git-worktrees"><img src="https://agentmods.dev/badge/skills/leodorareluctant259/superpowers-zh/using-git-worktrees.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 39 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,590 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 100% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00039 $0.01590
Opus 5.5 $0.00016 $0.00636
Sonnet 5.5 $0.00008 $0.00318
Haiku 4.5 $0.00004 $0.00159

Measured 1mo ago against content hash 505f81d180b8, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

using-git-worktrees scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

100% identical to using-git-worktrees — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

skills/using-git-worktrees/SKILL.md · 219 lines

How it starts

The opening of the file, as written. The whole thing — 219 lines — stays where its author put it; the contents beside it link to each section on GitHub.

使用 Git 工作树

概述

Git 工作树创建共享同一仓库的隔离工作区,允许同时在多个分支上工作而无需切换。

核心原则: 系统化的目录选择 + 安全验证 = 可靠的隔离。

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

目录选择流程

按以下优先顺序执行:

1. 检查现有目录

# 按优先顺序检查
ls -d .worktrees 2>/dev/null     # 首选(隐藏目录)
ls -d worktrees 2>/dev/null      # 备选

如果找到: 使用该目录。如果两者都存在,.worktrees 优先。

2. 检查 CLAUDE.md

grep -i "worktree.*director" CLAUDE.md 2>/dev/null

如果指定了偏好: 直接使用,无需询问。

3. 询问用户

如果没有现有目录且 CLAUDE.md 中无偏好设置:

未找到工作树目录。我应该在哪里创建工作树?

1. .worktrees/(项目本地,隐藏目录)
2. ~/.config/superpowers/worktrees/<project-name>/(全局位置)

你倾向哪个?

安全验证

项目本地目录(.worktrees 或 worktrees)

创建工作树前必须验证目录已被忽略:

# 检查目录是否被忽略(遵循本地、全局和系统 gitignore)
git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null

如果未被忽略:

根据 Jesse 的规则"立即修复坏掉的东西":

  1. 在 .gitignore 中添加相应条目
  2. 提交更改
  3. 继续创建工作树

为什么这很关键: 防止意外将工作树内容提交到仓库。

全局目录(~/.config/superpowers/worktrees)

无需 .gitignore 验证——完全在项目之外。

创建步骤

1. 检测项目名称

project=$(basename "$(git rev-parse --show-toplevel)")

2. 创建工作树

# 确定完整路径
case $LOCATION in
  .worktrees|worktrees)
    path="$LOCATION/$BRANCH_NAME"
    ;;
  ~/.config/superpowers/worktrees/*)
    path="~/.config/superpowers/worktrees/$project/$BRANCH_NAME"
    ;;
esac

# 创建带有新分支的工作树
git worktree add "$path" -b "$BRANCH_NAME"
cd "$path"

3. 运行项目设置

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

# 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

4. 验证基线正常

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

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

如果测试失败: 报告失败情况,询问是否继续或排查。

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

5. 报告位置

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

快速参考

情况 操作
.worktrees/ 存在 使用它(验证已忽略)
worktrees/ 存在 使用它(验证已忽略)
两者都存在 使用 .worktrees/
都不存在 检查 CLAUDE.md → 询问用户
目录未被忽略 添加到 .gitignore + 提交
基线测试失败 报告失败 + 询问
无 package.json/Cargo.toml 跳过依赖安装

Read the full file on GitHub · 219 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 219 lines · 39 tokens per session scan A 505f81d180b8

Subscribe to this mod's changes

using-git-worktrees is a skill published in the GitHub repository Leodorareluctant259/superpowers-zh (5 stars, last pushed 12d ago), licensed MIT. It adds 39 tokens to every session and 1,590 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. It is 100% identical to using-git-worktrees, differing in 0 lines, and is treated as a copy.

Related

Other skills, from other repositories

ainb-fleet:ainb-spawn

Spawn a coding-agent session correctly with ainb run: always into a git worktree, never bare into a plain checkout. Use whenever you are about to start a Claude/Codex/Gemini/Copilot session in a terminal. Guards the invocations that silently produce a (broken) workspace row, two agents sharing one working tree, a…

stevengonsalvez/agents-in-a-box · 107 tokens

create-pr

This skill should be used when user asks to "create a PR", "make a pull request", "open PR for this branch", "submit changes as PR", "push and create PR", or explicitly invokes "create-pr".

fcakyon/claude-codex-settings · 49 tokens

commit-staged

This skill should be used when user asks to "commit these changes", "write commit message", "stage and commit", "create a commit", "commit staged files", or explicitly invokes "commit-staged".

fcakyon/claude-codex-settings · 46 tokens

resolve-pr-comments

This skill should be used when user asks to "address PR comments", "resolve PR feedback", "handle review comments", "fix PR issues", "respond to PR review", or explicitly invokes "resolve-pr-comments".

fcakyon/claude-codex-settings · 47 tokens

review-pr

This skill should be used when user asks to "review a PR", "review pull request", "review this pr", "code review this PR", "check PR.

fcakyon/claude-codex-settings · 36 tokens

update-pr-summary

This skill should be used when user asks to "update PR summary", "update PR description", "rewrite PR body", "refresh PR title and body", or explicitly invokes "update-pr-summary".

fcakyon/claude-codex-settings · 43 tokens