Token导航 LogoToken导航TokenDH.com
前端设计只读github未标认证来源可访问许可证需确认审计提醒

git-worktreeGit 工作树

Agent Skill

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

总安装

514

周安装

21

GitHub Stars

16,191

下载量

165
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/udecode/plate --skill git-worktree

简介

git-worktree 用于处理 GitHub 仓库、Issue、Pull Request 等协作信息。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中围绕代码变更进行整理。
  • 通过 npx skills add 命令从 GitHub 仓库安装使用。
  • 需确认仓库访问权限,防止误操作影响分支或协作流程。
  • 建议查看原始文档以明确支持的命令和操作类型。

SKILL.md

Git Worktree Manager

This skill provides a unified interface for managing Git worktrees across your development workflow. Whether you're reviewing PRs in isolation or working on features in parallel, this skill handles all the complexity.

What This Skill Does

  • Create worktrees from main branch with clear branch names
  • List worktrees with current status
  • Switch between worktrees for parallel work
  • Clean up completed worktrees automatically
  • Interactive confirmations at each step
  • Automatic.gitignore management for worktree directory
  • Automatic.env file copying from main repo to new worktrees
  • Automatic dev tool trusting for mise and direnv configs with review-safe guardrails

CRITICAL: Always Use the Manager Script

NEVER call git worktree add directly. Always use the worktree-manager.sh script.

The script handles critical setup that raw git commands don't:

  1. Copies .env, .env.local, .env.test, etc. from main repo
  2. Trusts dev tool configs with branch-aware safety rules:

- mise: auto-trust only when unchanged from a trusted baseline branch - direnv: auto-allow only for trusted base branches; review worktrees stay manual

  1. Ensures .worktrees is in .gitignore
  2. Creates consistent directory structure
# ✅ CORRECT - Always use the script
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh create feature-name

# ❌ WRONG - Never do this directly
git worktree add .worktrees/feature-name -b feature-name main

When to Use This Skill

Use this skill in these scenarios:

  1. Code Review (/ce:review): If NOT already on the target branch (PR branch or requested branch), offer worktree for isolated review
  2. Feature Work (/ce:work): Always ask if user wants parallel worktree or live branch work
  3. Parallel Development: When working on multiple features simultaneously
  4. Cleanup: After completing work in a worktree

How to Use

In Claude Code Workflows

The skill is automatically called from /ce:review and /ce:work commands:

# For review: offers worktree if not on PR branch
# For work: always asks - new branch or worktree?

Manual Usage

You can also invoke the skill directly from bash:

# Create a new worktree (copies .env files automatically)
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh create feature-login

# List all worktrees
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh list

# Switch to a worktree
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh switch feature-login

# Copy .env files to an existing worktree (if they weren't copied)
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh copy-env feature-login

# Clean up completed worktrees
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh cleanup

Commands

create <branch-name> [from-branch]

Creates a new worktree with the given branch name.

Options:

  • branch-name (required): The name for the new branch and worktree
  • from-branch (optional): Base branch to create from (defaults to main)

Example:

bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh create feature-login

What happens:

  1. Checks if worktree already exists
  2. Updates the base branch from remote
  3. Creates new worktree and branch
  4. Copies all.env files from main repo (.env,.env.local,.env.test, etc.)
  5. Trusts dev tool configs with branch-aware safety rules:

- trusted bases (main, develop, dev, trunk, staging, release/*) compare against themselves - other branches compare against the default branch - direnv auto-allow is skipped on non-trusted bases because .envrc can source unchecked files

  1. Shows path for cd-ing to the worktree

list or ls

Lists all available worktrees with their branches and current status.

Example:

bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh list

Output shows:

  • Worktree name
  • Branch name
  • Which is current (marked with ✓)
  • Main repo status

switch <name> or go <name>

Switches to an existing worktree and cd's into it.

Example:

bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh switch feature-login

Optional:

  • If name not provided, lists available worktrees and prompts for selection

cleanup or clean

Interactively cleans up inactive worktrees with confirmation.

Example:

bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh cleanup

What happens:

  1. Lists all inactive worktrees
  2. Asks for confirmation
  3. Removes selected worktrees
  4. Cleans up empty directories

Workflow Examples

Code Review with Worktree

# Claude Code recognizes you're not on the PR branch
# Offers: "Use worktree for isolated review? (y/n)"

# You respond: yes
# Script runs (copies .env files automatically):
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh create pr-123-feature-name

# You're now in isolated worktree for review with all env vars
cd .worktrees/pr-123-feature-name

# After review, return to main:
cd ../..
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh cleanup

Parallel Feature Development

# For first feature (copies .env files):
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh create feature-login

# Later, start second feature (also copies .env files):
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh create feature-notifications

# List what you have:
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh list

# Switch between them as needed:
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh switch feature-login

# Return to main and cleanup when done:
cd .
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh cleanup

Key Design Principles

KISS (Keep It Simple, Stupid)

  • One manager script handles all worktree operations
  • Simple commands with sensible defaults
  • Interactive prompts prevent accidental operations
  • Clear naming using branch names directly

Opinionated Defaults

  • Worktrees always created from main (unless specified)
  • Worktrees stored in .worktrees/ directory
  • Branch name becomes worktree name
  • .gitignore automatically managed

Safety First

  • Confirms before creating worktrees
  • Confirms before cleanup to prevent accidental removal
  • Won't remove current worktree
  • Clear error messages for issues

Integration with Workflows

/ce:review

Instead of always creating a worktree:

1. Check current branch
2. If ALREADY on target branch (PR branch or requested branch) → stay there, no worktree needed
3. If DIFFERENT branch than the review target → offer worktree:
   "Use worktree for isolated review? (y/n)"
   - yes → call git-worktree skill
   - no → proceed with PR diff on current branch

/ce:work

Always offer choice:

1. Ask: "How do you want to work?
   1. New branch on current worktree (live work)
   2. Worktree (parallel work)"

2. If choice 1 → create new branch normally
3. If choice 2 → call git-worktree skill to create from main

Troubleshooting

"Worktree already exists"

If you see this, the script will ask if you want to switch to it instead.

"Cannot remove worktree: it is the current worktree"

Switch out of the worktree first (to main repo), then cleanup:

cd $(git rev-parse --show-toplevel)
bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh cleanup

Lost in a worktree?

See where you are:

bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh list

.env files missing in worktree?

If a worktree was created without.env files (e.g., via raw git worktree add), copy them:

bash ${CLAUDE_PLUGIN_ROOT}/skills/git-worktree/scripts/worktree-manager.sh copy-env feature-name

Navigate back to main:

cd $(git rev-parse --show-toplevel)

Technical Details

Directory Structure

.worktrees/
├── feature-login/          # Worktree 1
│   ├── .git
│   ├── app/
│   └── ...
├── feature-notifications/  # Worktree 2
│   ├── .git
│   ├── app/
│   └── ...
└── ...

.gitignore (updated to include .worktrees)

How It Works

  • Uses git worktree add for isolated environments
  • Each worktree has its own branch
  • Changes in one worktree don't affect others
  • Share git history with main repo
  • Can push from any worktree

Performance

  • Worktrees are lightweight (just file system links)
  • No repository duplication
  • Shared git objects for efficiency
  • Much faster than cloning or stashing/switching

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

34.54%
按下载量换算57

Claude

30.62%
按下载量换算51

Cursor

17.94%
按下载量换算30

Gemini CLI

10.4%
按下载量换算17

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

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

来源信息

继续浏览同类 Skills