| name | worktree |
| description | Create and manage git worktrees for parallel development. Use when you need to work on multiple branches simultaneously without stashing or switching contexts. |
| argument-hint | [branch-name] [base-branch] |
| allowed-tools | Bash(git *), Bash(ls *), Bash(mkdir *), Bash(basename *) |
Git Worktree Workflow
Create a git worktree to enable parallel development on multiple branches.
Arguments
- First argument: New branch name (required)
- Second argument: Base branch to create from (optional, auto-detects default branch)
Worktree Directory Convention
Worktrees are created in ../worktrees/<repo-name>-<branch-name> relative to the main repository.
This naming convention:
- Keeps all worktrees in a shared
worktrees directory above the repo
- Includes repo name to avoid conflicts when working on multiple projects
- Includes branch name for easy identification
Example: If working in /home/user/projects/my-app on branch feature-auth, the worktree path would be /home/user/projects/worktrees/my-app-feature-auth
Instructions
-
Get repository info
repo_root=$(git rev-parse --show-toplevel)
repo_name=$(basename "$repo_root")
-
Check repository status
git status
git worktree list
-
Determine base branch
-
Create the worktree
branch_name="<first-argument>"
dir_safe_branch="${branch_name//\//-}"
worktrees_dir="$(dirname "$repo_root")/worktrees"
worktree_path="$worktrees_dir/${repo_name}-${dir_safe_branch}"
mkdir -p "$worktrees_dir"
git fetch origin <base-branch>
git worktree add "$worktree_path" -b "$branch_name" origin/<base-branch>
-
Verify creation
git worktree list
-
Report to user
- Confirm the new worktree path
- Show which branch it's based on
- Remind user how to navigate:
cd <worktree_path>
Temporary Branch Handling
When a branch has a temporary name (pattern: wt-* or similar timestamp-based names), you should:
-
Detect temporary branch
branch=$(git branch --show-current)
if [[ "$branch" == wt-* ]]; then
fi
-
Ask about the task context
- What feature or fix is being worked on?
- Is there an issue ID (e.g., ISSUE-123)?
-
Suggest and rename the branch
git branch -m <old-name> <new-name>
Naming conventions:
feature/<description> - New features
fix/<description> - Bug fixes
refactor/<description> - Code refactoring
docs/<description> - Documentation changes
ISSUE-123-<description> - When linked to an issue tracker
-
Example interaction:
User: Let's add user authentication
Claude: I notice the current branch has a temporary name 'wt-1706789012'.
Based on your task, I'll rename it to something more descriptive.
[Runs: git branch -m wt-1706789012 feature/user-auth]
Branch renamed to 'feature/user-auth'. Now let's implement the authentication...
Cleanup Instructions
When the user wants to remove a worktree:
repo_root=$(git rev-parse --show-toplevel)
repo_name=$(basename "$repo_root")
branch_name="<branch-name>"
dir_safe_branch="${branch_name//\//-}"
worktrees_dir="$(dirname "$repo_root")/worktrees"
git worktree remove "$worktrees_dir/${repo_name}-${dir_safe_branch}"
rm -rf "$worktrees_dir/${repo_name}-${dir_safe_branch}"
git worktree prune
git worktree list
Examples
/worktree feature/user-auth
/worktree feature/user-auth main
/worktree hotfix/login-bug production
Integration with claude-wt
This skill works with the claude-wt bash script:
claude-wt creates a worktree with a temporary branch name (e.g., wt-1706789012)
- The worktree is created at
../worktrees/<repo-name>-<branch-name>
- Claude Code starts in the worktree directory
- When the user describes their task, rename the branch appropriately
- Continue with the implementation
Red Flags
Never:
- Proceed with a temporary branch name (
wt-*) without asking about renaming
- Create worktrees in directories that don't follow the convention
Always:
- Use the path convention:
../worktrees/<repo-name>-<branch-name>
- Detect and offer to rename temporary branches
- Auto-detect the default branch if not specified
- Verify worktree creation with
git worktree list