Token导航 LogoToken导航TokenDH.com
前端设计需要联网github未标认证来源可访问许可证需确认审计通过

using-git-worktrees使用 Git 工作树

Agent Skill

using-git-worktrees 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

710

周安装

29

GitHub Stars

1

下载量

230
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:using-git-worktrees(使用 Git 工作树)
来源仓库:https://github.com/pixel-process-ug/superkit-agents
仓库路径:skills/using-git-worktrees
安装命令:
npx skills add https://github.com/pixel-process-ug/superkit-agents --skill using-git-worktrees
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/pixel-process-ug/superkit-agents --skill using-git-worktrees

简介

using-git-worktrees 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合围绕仓库状态和代码变更进行整理。

  • 适用于 Git 工作树相关的协作信息管理,可结合代码变更事项使用。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装,需确认权限范围和维护状态。
  • 安装前建议确认是否会触发联网、命令执行或文件读写等操作边界。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Using Git Worktrees

Overview

Create isolated working directories for parallel development tasks using git worktree, allowing multiple branches to be checked out simultaneously without conflicts. This skill enforces a deterministic, multi-phase process from directory selection through setup verification, ensuring every worktree is production-ready before any work begins.

When to Use

  • Starting a new feature branch that should not interfere with current work
  • Working on multiple tasks simultaneously (bug fix + feature)
  • Creating a clean environment for testing or code review
  • Running long processes (tests, builds) while continuing development

Phase 1: Select Worktree Directory

[HARD-GATE] Do NOT skip directory selection. Do NOT assume a default path without checking priorities.

Follow this priority order exactly:

Priority 1: Existing Worktree Matching Task

Check if a worktree already exists for the task:

git worktree list

If a matching worktree exists, use it. Do NOT create a duplicate.

Priority 2: CLAUDE.md Worktree Directory Hint

Check the project's CLAUDE.md for a configured worktree directory:

# Example CLAUDE.md entry
worktree-directory: ../worktrees

If specified, create worktrees under that directory.

Priority 3: Ask the User

If no hint is configured and no convention is obvious, ask the user where worktrees should be created. Suggest a sensible default:

../worktrees/<project-name>/<branch-name>

STOP — Confirm the worktree directory with the user before proceeding.

Directory Selection Decision Table

ConditionAction
Worktree for this branch already existsNavigate to existing worktree
CLAUDE.md has worktree-directoryUse configured path
Project has existing worktreesUse same parent directory pattern
No convention foundAsk user, suggest ../worktrees/<project>/<branch>
User specifies path inside repo rootWarn — must add to .gitignore

Phase 2: Safety Verification

[HARD-GATE] Do NOT create any worktree until all safety checks pass.

Check.gitignore Coverage

If the worktree directory is inside the repository root, ensure it is in .gitignore:

# Check if the worktree path would be tracked
git check-ignore <worktree-path>

If not ignored, warn the user and suggest adding it to .gitignore.

Verify Clean Working Tree

Check for uncommitted changes that could cause issues:

git status --porcelain

If the working tree is dirty, inform the user and ask how to proceed:

  • Commit changes first
  • Stash changes
  • Proceed anyway (worktree creation itself is safe)

Verify Branch Does Not Exist in Another Worktree

git worktree list

A branch cannot be checked out in two worktrees simultaneously. If the branch is already checked out, navigate to that existing worktree instead.

Safety Check Decision Table

CheckResultAction
Path inside repo, not in .gitignoreFAILAdd to .gitignore first
Branch already in another worktreeFAILUse existing worktree
Working tree dirtyWARNInform user, ask preference
Path already exists (not worktree)FAILChoose different path
All checks passPASSProceed to Phase 3

Phase 3: Create the Worktree

# For a new branch
git worktree add <path> -b <branch-name> <base-branch>

# For an existing branch
git worktree add <path> <existing-branch>

Always tell the user the full path where the worktree was created:

Worktree created at: /absolute/path/to/worktree
Branch: feature/my-feature
Base: main

STOP — Confirm the worktree was created successfully before proceeding to setup.

Phase 4: Project Setup and Auto-Detection

After creating the worktree, detect and run the project's setup commands.

Setup Detection Decision Table

Indicator FileEcosystemSetup Command
pnpm-lock.yamlNode.js (pnpm)pnpm install
yarn.lockNode.js (yarn)yarn install
package-lock.jsonNode.js (npm)npm install
package.json (no lock)Node.js (npm)npm install
pyproject.toml + tool.poetryPython (poetry)poetry install
pyproject.toml (no poetry)Python (pip)pip install -e.
setup.pyPython (pip)pip install -e.
requirements.txtPython (pip)pip install -r requirements.txt
go.modGogo mod download
Cargo.tomlRustcargo build
GemfileRubybundle install
composer.jsonPHPcomposer install

Multiple Ecosystems

If the project uses multiple ecosystems (e.g., a Go backend with a Node.js frontend), run setup for each detected ecosystem in the appropriate subdirectories.

Environment Files

If the project has .env.example or .env.template:

# Copy environment template if .env does not exist in worktree
cp .env.example .env  # then inform user to update values

Phase 5: Clean Baseline Test Verification

[HARD-GATE] Do NOT proceed with any work until baseline tests pass or failures are acknowledged.

Run the project's test suite to establish a clean baseline BEFORE starting any work:

# Use the project's test command
# Node.js: npm test / yarn test / pnpm test
# Python: pytest / python -m pytest
# Go: go test ./...
# Rust: cargo test

Purpose:

  • Confirms the worktree is set up correctly
  • Establishes that all tests pass before changes are made
  • Any test failures after this point are caused by your changes, not pre-existing issues

If baseline tests fail:

  • Report the failures to the user
  • Do NOT proceed with work until the baseline is understood
  • The base branch may have broken tests that need addressing first

Phase 6: Location Reporting

Always report the worktree location clearly to the user:

Worktree ready:
  Path:    /Users/dev/worktrees/myproject/feature-auth
  Branch:  feature/auth-refactor
  Base:    main
  Setup:   npm install (completed)
  Tests:   24 passed, 0 failed

Cleanup Patterns

After Merging or Completing Work

# Remove the worktree
git worktree remove <path>

# If files remain (dirty worktree), force removal
git worktree remove --force <path>

# Prune stale worktree references
git worktree prune

List All Worktrees

git worktree list

Handling Locked Worktrees

If a worktree is locked (to prevent accidental removal):

# Unlock before removing
git worktree unlock <path>
git worktree remove <path>

Anti-Patterns / Common Mistakes

Anti-PatternWhy It Is WrongWhat to Do Instead
Creating duplicate worktree for same branchGit does not allow it; wastes timeCheck git worktree list first
Worktree inside repo without .gitignoreWorktree files show as untrackedAdd path to .gitignore
Skipping dependency install in worktreeBuild/test failures from missing depsAlways run project setup
Skipping baseline test runCannot distinguish pre-existing vs new failuresRun tests before starting work
Assuming worktree has same env vars.env files are not shared between worktreesCopy and configure .env
Leaving stale worktrees after mergeDisk waste, confusing git worktree listRemove worktrees after branch completion
Force-removing worktree with uncommitted workPermanent data lossCommit or stash first

Integration Points

SkillIntegration
finishing-a-development-branchAfter completing work in a worktree, use this to merge or create a PR
dispatching-parallel-agentsRun agents in separate worktrees for true isolation
verification-before-completionValidate work before leaving the worktree
self-learningCheck CLAUDE.md for worktree directory preferences
planningWorktree creation is often the first step of plan execution

Skill Type

RIGID — Follow this process exactly. Every phase must be completed in order. Do NOT skip safety checks. Do NOT skip baseline test verification. Do NOT create worktrees without confirming the directory.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.13%
按下载量换算83

Claude

27.79%
按下载量换算64

Cursor

19.22%
按下载量换算44

Gemini CLI

9.44%
按下载量换算22

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills