Create a Git Worktree

VerifiedSafe

Creates a git worktree in a sibling directory for working on a feature branch in parallel with the main branch. It automatically determines the repository name and branch, optionally from a specified base branch. Useful for developing features or fixing bugs without switching branches in the main repository.

Sby Skills Guide Bot
DevelopmentIntermediate
6/2/2026
Claude Code
#git#worktree#branching#parallel-development

Recommended for

Automated summary

Creates a Git worktree to work on a separate branch in an isolated directory without switching branches.

Strengths

  • Enables parallel work on multiple branches without workspace conflicts.
  • Automates worktree path naming and base branch selection.
  • Provides a cleanup reminder after creation.

Limitations

  • Requires a properly initialized Git repository and the base branch to exist locally or remotely.
  • Does not handle cases where the target directory already exists.
When to use it

Use this skill when you need to work on a feature or fix in an isolated directory while keeping your current branch untouched.

When not to use it

Avoid using it for simple branch switching or if you prefer to manage worktrees manually.

Security analysis

Safe
Quality score85/100

The skill only runs standard git worktree commands (git rev-parse, branch, worktree list/add/remove) within the repository, with no destructive actions or external communication.

No concerns found

How this analysis is made

Examples

Create new feature branch worktree
/worktree feature-auth
Create worktree from custom base branch
/worktree fix-bug develop
Create worktree for an existing remote branch
/worktree existing-branch

name: worktree description: Create a git worktree for parallel development. Use when the user wants to work on a feature branch in a separate directory without switching branches. disable-model-invocation: true allowed-tools: Bash, Read

Git Worktree

Create a git worktree for working on a separate branch in parallel.

Current State

  • Repository: !basename $(git rev-parse --show-toplevel)
  • Current branch: !git branch --show-current
  • Existing worktrees: !git worktree list

Instructions

Parse $ARGUMENTS to determine:

  1. Branch name - required (first argument)
  2. Base branch - optional (second argument, defaults to main)

Workflow

  1. Determine the worktree path: Use ../<repo-name>-<branch-name> as the directory (sibling to the current repo).

  2. Check if the branch already exists:

    git branch --list <branch-name>
    git branch -r --list "origin/<branch-name>"
    
  3. Create the worktree:

    • If branch exists locally or remotely: git worktree add <path> <branch-name>
    • If new branch: git worktree add -b <branch-name> <path> <base-branch>
  4. Report the result with the full path so the user can navigate to it.

Examples

  • /worktree feature-auth → Creates ../<repo>-feature-auth on new branch feature-auth from main
  • /worktree fix-bug develop → Creates ../<repo>-fix-bug on new branch fix-bug from develop
  • /worktree existing-branch → If branch exists, checks it out in a new worktree

Cleanup Reminder

After reporting success, remind the user how to clean up when done:

git worktree remove <path>
# or to also delete the branch:
git worktree remove <path> && git branch -d <branch-name>

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/create-a-git-worktree-mm8o524a/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/create-a-git-worktree-mm8o524a' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/create-a-git-worktree-mm8o524a/download' --output '.skill-downloads/create-a-git-worktree-mm8o524a/SKILL.md.part' && mv '.skill-downloads/create-a-git-worktree-mm8o524a/SKILL.md.part' '.skill-downloads/create-a-git-worktree-mm8o524a/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Tools declared by the author (check availability in your agent): Bash, Read

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/create-a-git-worktree-mm8o524a/SKILL.md' && test -s '.skill-downloads/create-a-git-worktree-mm8o524a/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/worktree' && cp -R '.skill-downloads/create-a-git-worktree-mm8o524a' '.claude/skills/worktree'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/create-a-git-worktree-mm8o524a'

openskills read 'create-a-git-worktree-mm8o524a'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/create-a-git-worktree-mm8o524a/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills