worktree
Quickly generate a side-by-side git worktree to experiment with different branches.
Install
mkdir -p .claude/skills/worktree && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/14684" && unzip -o skill.zip -d .claude/skills/worktree && rm skill.zipInstalls to .claude/skills/worktree
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Create a git worktree from a target branch with a new branch nameKey capabilities
- →Create a git worktree from a target branch
- →Fetch the latest changes from the origin
- →Determine the worktree directory path
- →Create a new branch in the worktree
- →Verify the creation of the worktree
How it works
The skill parses the target branch and new branch name from arguments. It fetches the latest changes, determines a sibling directory for the worktree, and then uses `git worktree add` to create the worktree and new branch.
Inputs & outputs
When to use worktree
- →Check out a branch in a new directory
- →Switch branches without stashing
- →Manage parallel tasks
About this skill
Create Git Worktree
Create a new git worktree checked out from a target branch. Arguments: $ARGUMENTS should be in the format <target-branch> <new-branch-name>.
Examples:
/worktree main feature/add-auth/worktree prod hotfix/fix-crash/worktree test fix/flaky-tests
Step 1: Parse Arguments
Extract from $ARGUMENTS:
- Target branch (first arg): The base branch to create the worktree from (e.g.,
main,test,prod) - New branch name (second arg): The name for the new branch in the worktree
If arguments are missing, ask the user to provide them in the format: /worktree <target-branch> <new-branch-name>
Step 2: Fetch Latest
git fetch origin
Step 3: Determine Worktree Path
Place the worktree as a sibling directory to the current repo:
# If repo is at /Users/user/work/nudgebee/nudgebee
# Worktree goes to /Users/user/work/nudgebee/nudgebee-<new-branch-name>
REPO_ROOT=$(git rev-parse --show-toplevel)
WORKTREE_DIR="${REPO_ROOT}-$(echo '<new-branch-name>' | tr '/' '-')"
The branch name's slashes are converted to dashes for the directory name (e.g., feature/add-auth becomes nudgebee-feature-add-auth).
Step 4: Create the Worktree
git worktree add -b <new-branch-name> "$WORKTREE_DIR" origin/<target-branch>
This creates a new branch <new-branch-name> based on origin/<target-branch> and checks it out in the worktree directory.
Step 5: Verify and Output
# Show all worktrees
git worktree list
Output:
Worktree created:
Path: {worktree_dir}
Branch: {new-branch-name}
Based on: origin/{target-branch}
To start working:
cd {worktree_dir}
To remove later:
git worktree remove {worktree_dir}
When not to use it
- →When the user wants to work directly on the main repository without a separate worktree
- →When the user wants to delete an existing worktree
Limitations
- →The skill assumes the user is in a git repository.
- →It places the worktree as a sibling directory to the current repo.
- →The skill converts branch name slashes to dashes for the directory name.
How it compares
This skill automates the creation of a git worktree from a specified target branch with a new branch name, providing a structured command-line approach to managing parallel development environments compared to manual git commands.
Compared to similar skills
worktree side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| worktree (this skill) | 0 | 2mo | Review | Beginner |
| resolve-conflicts | 81 | 8mo | Review | Intermediate |
| dependency-upgrade | 26 | 5mo | Review | Intermediate |
| openspec-onboard | 10 | 6mo | Review | Beginner |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
resolve-conflicts
antinomyhq
Use this skill immediately when the user mentions merge conflicts that need to be resolved. Do not attempt to resolve conflicts directly - invoke this skill first. This skill specializes in providing a structured framework for merging imports, tests, lock files (regeneration), configuration files, and handling deleted-but-modified files with backup and analysis.
dependency-upgrade
wshobson
Manage major dependency version upgrades with compatibility analysis, staged rollout, and comprehensive testing. Use when upgrading framework versions, updating major dependencies, or managing breaking changes in libraries.
openspec-onboard
studyzy
Guided onboarding for OpenSpec - walk through a complete workflow cycle with narration and real codebase work.
codex-cli-bridge
alirezarezvani
Bridge between Claude Code and OpenAI Codex CLI - generates AGENTS.md from CLAUDE.md, provides Codex CLI execution helpers, and enables seamless interoperability between both tools
skill-sync
KyleKing
Syncs Claude Skills with other AI coding tools like Cursor, Copilot, and Codeium by creating cross-references and shared knowledge bases. Invoke when user wants to leverage skills across multiple tools or create unified AI context.
git-commits
bonny
Create well-structured git commits in logical chunks following best practices