Token导航 LogoToken导航TokenDH.com
研究检索执行命令github未标认证来源可访问clear审计通过

using-git-worktrees使用 Git 工作树

Agent Skill

using-git-worktrees 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

1,023

周安装

41

GitHub Stars

61

下载量

331
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/julianobarbosa/claude-code-skills --skill using-git-worktrees

简介

using-git-worktrees 用于查找、检索和筛选相关信息,支持基于关键词的任务定位。

  • 适用于在开发流程中快速获取相关线索或技术资料。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装并使用该技能。
  • 安装前需确认权限范围和维护状态,避免触发联网或文件读写操作。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Git Worktrees with tmux Integration

Create isolated workspaces, open them in tmux windows within your current session, and dispatch tasks — all in one flow.

Core Flow

1. Create worktree     → git worktree add .claude/worktrees/{name} -b {branch}
2. Create tmux window  → new window in CURRENT session named {session}-{name}
3. cd into worktree    → send-keys to the new window
4. Dispatch task       → send-keys with the command to execute

Workflow Routing

IntentAction
"create worktree for X"Create → steps 1-3 only
"create worktree and run Y"Create + Dispatch → steps 1-4
"clean up worktree X"Cleanup → remove worktree + tmux window + optionally delete branch
"list worktrees"Show git worktree list
"analyze for parallelization"Read references/bmad-orchestration.md for BMAD-specific dependency analysis
"merge worktree branches"Read references/bmad-orchestration.md for merge workflow

Step 1: Create Worktree

Safety Check

Before creating, verify .claude/worktrees/ is git-ignored:

# Check if ignored (test with a hypothetical file)
git check-ignore .claude/worktrees/test 2>/dev/null

If NOT ignored, add to .gitignore immediately:

echo ".claude/worktrees/" >> .gitignore
# Stage and commit the gitignore change

Create

REPO_ROOT=$(git rev-parse --show-toplevel)
WORKTREE_NAME="the-feature-name"
BRANCH_NAME="feature/the-feature-name"  # or bmad/story-1-3 etc.
BASE_BRANCH="main"  # or current branch

mkdir -p "$REPO_ROOT/.claude/worktrees"
git worktree add "$REPO_ROOT/.claude/worktrees/$WORKTREE_NAME" -b "$BRANCH_NAME" "$BASE_BRANCH"

Verify

git worktree list

Step 2: Create tmux Window

Create a new window in the current tmux session (not a new session). The window name follows the pattern {current-session-name}-{worktree-name} so it's easy to identify.

# Get current tmux session name
SESSION=$(tmux display-message -p '#S')
WINDOW_NAME="${SESSION}-${WORKTREE_NAME}"
WORKTREE_PATH="$REPO_ROOT/.claude/worktrees/$WORKTREE_NAME"

# Create window in current session, starting in worktree directory
tmux new-window -t "$SESSION" -n "$WINDOW_NAME" -c "$WORKTREE_PATH"

Step 3: Ensure Working Directory

The -c flag in step 2 already sets the initial directory, but if you need to explicitly cd (e.g., shell profile overrides it):

tmux send-keys -t "${SESSION}:${WINDOW_NAME}" "cd '$WORKTREE_PATH'" Enter

Step 4: Dispatch Task (Optional)

Send a command to the new tmux window:

# Example: launch Claude Code with a task
tmux send-keys -t "${SESSION}:${WINDOW_NAME}" "claude 'your task here'" Enter

# Example: run a BMAD skill
tmux send-keys -t "${SESSION}:${WINDOW_NAME}" "claude '/bmad-create-story story 1-3'" Enter

# Example: run any shell command
tmux send-keys -t "${SESSION}:${WINDOW_NAME}" "make test" Enter

For unattended execution (no permission prompts):

tmux send-keys -t "${SESSION}:${WINDOW_NAME}" "claude --dangerously-skip-permissions 'your task'" Enter

Important: Only use --dangerously-skip-permissions if the user explicitly requests it.

Cleanup Workflow

After work is complete and merged:

WORKTREE_NAME="the-feature-name"
REPO_ROOT=$(git rev-parse --show-toplevel)
SESSION=$(tmux display-message -p '#S')

# 1. Kill the tmux window
tmux kill-window -t "${SESSION}:${SESSION}-${WORKTREE_NAME}" 2>/dev/null

# 2. Remove the git worktree
git worktree remove "$REPO_ROOT/.claude/worktrees/$WORKTREE_NAME"

# 3. Optionally delete the branch (only if merged)
git branch -d "$BRANCH_NAME" 2>/dev/null

# 4. Prune stale worktree references
git worktree prune

Quick Reference

SituationAction
.claude/worktrees/ existsUse it (verify ignored)
Not in .gitignoreAdd .claude/worktrees/ and commit
Not in tmuxSkip tmux steps, just create worktree and report path
Branch already existsUse git worktree add <path> <existing-branch> (no -b)
Worktree path existsReport error, ask user to remove or pick different name

Naming Conventions

ElementPatternExample
Worktree directory.claude/worktrees/{name}.claude/worktrees/story-1-3
Branch{convention}/{name}bmad/story-1-3-deploy-nat-gateway
tmux window{session}-{name}hypera-golden-image-story-1-3

The branch naming convention depends on the project. Check CLAUDE.md for project-specific patterns (e.g., bmad/story-{id} for BMAD projects).

Troubleshooting

Branch already checked out:

# Another worktree has this branch — remove it first or use a different name
git worktree list  # find which worktree has the branch

tmux window name conflict:

# Rename or kill the conflicting window
tmux kill-window -t "session:conflicting-name" 2>/dev/null

Worktree not in.gitignore after adding:

# .gitignore uses directory patterns — ensure trailing slash
# Check with: git check-ignore .claude/worktrees/testfile

References

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

补充不同宿主或平台的使用分布数据

能力 5

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

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

平台分布

Claude Code

24.07%
按下载量换算80

OpenCode

23.4%
按下载量换算77

Codex

18.26%
按下载量换算60

Gemini CLI

13.16%
按下载量换算44

Antigravity

6.78%
按下载量换算22

Cursor

3.33%
按下载量换算11

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/julianobarbosa/claude-code-skills --skill using-git-worktrees;npx skills add julianobarbosa/claude-code-skills --skill "using-git-worktrees" 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills