
using-git-worktrees
Git worktree management with tmux integration and task dispatch. Use when creating isolated dev environments, launching parallel feature work, running multiple Claude instances, managing worktrees, dispatching tasks to worktree terminals, or cleaning up after merge. Covers worktree creation in .claude/worktrees/, tmux window management in the current session, and command dispatch. Also use when someone says "create a worktree", "launch in a worktree", "worktree for story X", or "parallel development".
- Installs
- 104
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/julianobarbosa/claude-code-skills --skill using-git-worktrees- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads using-git-worktrees automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
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
| Intent | Action |
|---|---|
| "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
| Situation | Action |
|---|---|
.claude/worktrees/ exists | Use it (verify ignored) |
Not in .gitignore | Add .claude/worktrees/ and commit |
| Not in tmux | Skip tmux steps, just create worktree and report path |
| Branch already exists | Use git worktree add <path> <existing-branch> (no -b) |
| Worktree path exists | Report error, ask user to remove or pick different name |
Naming Conventions
| Element | Pattern | Example |
|---|---|---|
| Worktree directory | .claude/worktrees/{name} | .claude/worktrees/story-1-3 |
| Branch | {convention}/{name} | bmad/story-1-3-deploy-nat-gateway |
| tmux window | {session}-{name} | myproject-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
- WORKFLOW.md — Detailed step-by-step workflow with edge cases
- references/bmad-orchestration.md — BMAD sprint parallelization, dependency analysis, and merge workflows
- references/tmux-integration.md — Advanced tmux configuration for worktrees
- scripts/setup-worktree.sh — Shell script for automated worktree setup
Gotchas
.claude/worktrees/conflicts with.gitignoredefaults — must explicitly ignore it or the parent repo sees worktree files as untracked.- tmux session names with worktree paths hit filename length limits — use short branch-based names or the socket path errors.
- Concurrent
git statusacross worktrees can fail with index.lock errors — git locks the index per-repo, not per-worktree. - BMAD-specific parallel work assumes disjoint files: overlapping edits across stories cause merge headaches at integration.
- Shell prompts that read git branch via the worktree path can be slow — disable expensive prompt parts in worktrees.
FAQ
What does the using-git-worktrees skill do?
Git worktree management with tmux integration and task dispatch. Use when creating isolated dev environments, launching parallel feature work, running multiple Claude instances, managing worktrees, dispatching tasks to worktree terminals, or cleaning up after merge. Covers worktree creation in .claude/worktrees/, tmux window management in the current session, and command dispatch. Also use when someone says "create a worktree", "launch in a worktree", "worktree for story X", or "parallel development".
How do I install using-git-worktrees?
Run npx skills add https://github.com/julianobarbosa/claude-code-skills --skill using-git-worktrees in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/using-git-worktrees/ (personal) or .claude/skills/using-git-worktrees/ (project).
Which AI agents can use using-git-worktrees?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is using-git-worktrees safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains using-git-worktrees?
It is published by julianobarbosa in julianobarbosa/claude-code-skills. It has 104 recorded installs.
More from julianobarbosa/claude-code-skills
markitdown
julianobarbosa/claude-code-skills
Guide for using Microsoft MarkItDown - a Python utility for converting files to Markdown. Use when converting PDF, Word, PowerPoint, Excel, images, audio, HTML, CSV, JSON, XML, ZIP, YouTube URLs, EPubs, Jupyter notebooks, RSS feeds, or Wikipedia pages to Markdown format. Also use for document processing pipelines, LLM preprocessing, or text extraction tasks.
obsidian-vault-management
julianobarbosa/claude-code-skills
Creates, edits, and manages Obsidian vault content including notes, templates, daily notes, and dataview queries. Use when working with markdown files in an Obsidian vault, creating notes, writing templates, building dataview queries, or organizing knowledge management content.
neovim
julianobarbosa/claude-code-skills
Comprehensive guide for this Neovim configuration - a modular, performance-optimized Lua-based IDE. Use when configuring plugins, adding keybindings, setting up LSP servers, debugging, or extending the configuration. Covers lazy.nvim, 82+ plugins across 9 categories, DAP debugging, AI integrations, and performance optimization.
markitdown-skill
julianobarbosa/claude-code-skills
Guide for using Microsoft MarkItDown - a Python utility for converting files to Markdown. Use when converting PDF, Word, PowerPoint, Excel, images, audio, HTML, CSV, JSON, XML, ZIP, YouTube URLs, EPubs, Jupyter notebooks, RSS feeds, or Wikipedia pages to Markdown format. Also use for document processing pipelines, LLM preprocessing, or text extraction tasks.
obsidian
julianobarbosa/claude-code-skills
Guide for implementing Obsidian knowledge management - vault operations, plugin development, URI scheme automation, markdown extensions, and Local REST API integration. Use when working with Obsidian vaults, creating plugins, automating note workflows, querying notes via API, or implementing knowledge graph features.
argocd-advanced
julianobarbosa/claude-code-skills
Advanced ArgoCD operations beyond the core CLI/API — multi-cluster ApplicationSet generators, automated image updates, new-cluster bootstrapping, and workload onboarding via templated ApplicationSets. USE WHEN working with ApplicationSet CRDs (list, cluster, git, matrix, merge, SCM, pull request, plugin generators), configuring ArgoCD Image Updater (semver/digest/newest-build update strategies + git write-back), bootstrapping a new Kubernetes cluster into a multi-repo GitOps setup, registering clusters with proper labels for ApplicationSet targeting, onboarding a new workload via the standard ApplicationSet template, or troubleshooting any of these. For routine app sync/status/diff work use the core argocd skill instead.
Popular code quality & workflow skills
grill-me
mattpocock/skills
A relentless interview to sharpen a plan or design.
improve-codebase-architecture
mattpocock/skills
Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
handoff
mattpocock/skills
Compact the current conversation into a handoff document for another agent to pick up.
domain-modeling
mattpocock/skills
Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.
codebase-design
mattpocock/skills
Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.
diagnosing-bugs
mattpocock/skills
Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.