using-git-worktrees

using-git-worktrees is a skill for Claude Code from zhaixin244-wq/fnw. It costs 39 tokens per session (1,590 once invoked), scanned A, original, MIT.

A procedure for creating an isolated Git worktree for feature development or an implementation plan. A worktree is a separate working directory linked to the same Git repository.

In plain words
What is it for?
Use it to choose a worktree location, verify Git ignore settings, and create a separate workspace for a branch.
Why use it?
It lets work continue on another branch without switching the current directory’s branch and checks that the worktree location is safely ignored.

Skill for Claude Code

Written for Claude Code: installed under .claude/. Also seen: mentions CLAUDE.md; mentions subagents.

Good fit Use it to choose a worktree location, verify Git ignore settings, and create a separate workspace for a branch.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/zhaixin244-wq/fnw/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 zhaixin244-wq/fnw --skill using-git-worktrees
Clone the repo
git clone --depth 1 https://github.com/zhaixin244-wq/fnw

Made for: Claude Code.

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/zhaixin244-wq/fnw/using-git-worktrees.svg)](https://agentmods.dev/skills/zhaixin244-wq/fnw/using-git-worktrees)
Your own site
<a href="https://agentmods.dev/skills/zhaixin244-wq/fnw/using-git-worktrees"><img src="https://agentmods.dev/badge/skills/zhaixin244-wq/fnw/using-git-worktrees.svg" alt="Measured on agentmods" 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 original No closer match found 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 $0.00019 $0.00795
Sonnet 5 $0.00008 $0.00318
Haiku 4.5 $0.00004 $0.00159

Measured 4d ago against content hash 505f81d180b8, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-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 4d 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

Copies of this mod

1 near-identical copy found in the catalogue:

.claude/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. 4d 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 zhaixin244-wq/fnw (28 stars, last pushed 3mo ago), licensed MIT. It adds 39 tokens to every session and 1,590 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

prowler-commit

Creates professional git commits following conventional-commits format. Trigger: When creating commits, after completing code changes, when user asks to commit.

prowler-cloud/prowler · 33 tokens

gh-auth-isolation

Safely manage multiple GitHub identities (EMU + personal) in agent workflows.

github/gh-aw · 20 tokens

comet-github

A routing guide for Comet-related GitHub work. It directs requests about pull requests, issues, CI failures, ideas, and fixes to the appropriate review or implementation process.

rpamis/comet · 72 tokens

github-skill

Work with GitHub via the gh CLI — clone repositories, create/list/merge pull requests, create/list issues, and run any other gh command (API calls, workflow runs, releases, repo administration). List operations return parsed JSON.

zeenie-ai/OpenCompany · 51 tokens

codex-autoresearch

Run autonomous, measurable experiments in a Git repository: change one hypothesis, verify a numeric metric, keep improvements, and revert failures. Use when the user wants Codex to keep iterating toward a numeric target in the foreground or as a detached background run. Do not use for ordinary one-shot coding…

leo-lilinxiao/codex-autoresearch · 80 tokens

changelog-composer

Generates structured changelogs and release notes from git history and PRs, classifying breaking changes, features, fixes, performance, docs. Triggers on: "generate changelog", "write release notes", "what changed since", "prepare release", "release notes for", "diff since tag".

Mathews-Tom/armory · 67 tokens