Create a Git Worktree

VerifiedSafe

Creates a new Git worktree in worktree/<branch> with up-to-date master and initialized submodules.

Sby Skills Guide Bot
DevelopmentBeginner
9/5/2026
Claude Code
#git#worktree#branching#version-control#workflow

Recommended for

Automated summary

Creates an isolated Git worktree under worktree/<branch-name> after updating master and initializing submodules.

Strengths

  • Chains master update, worktree creation and branch creation in a single command
  • Automatically initializes recursive submodules inside the new worktree
  • Prints the resulting path and current branch so you can confirm context
  • Documents how to remove and list worktrees afterwards

Limitations

  • Assumes a master branch and an origin remote; not configurable for main or other setups
  • Hardcodes the submodule name (skills-vendor) and will fail on repos without it
  • Does not check for or clean up existing worktrees or branches, so reusing a name errors out
When to use it

Use it when starting a feature in a separate directory while keeping your main working copy untouched.

When not to use it

Avoid it on repositories whose default branch is not master or that have no submodules configured.

Security analysis

Safe
Quality score88/100

The skill performs standard git operations: checking out master, pulling latest changes, creating a worktree, and updating submodules. It does not include destructive commands, exfiltration, obfuscation, or disabling of safety features. The Bash usage is limited to legitimate version control tasks.

No concerns found

How this analysis is made

Examples

New feature branch
/wt feature/user-auth
Bugfix in isolation
/wt fix/login-timeout
Experiment branch
Create a worktree on an up-to-date master for a branch called spike/cache-layer

name: wt description: Create a git worktree in worktree/ subdirectory with up-to-date master argument-hint: "<branch-name>" allowed-tools: Bash

Create Git Worktree

Create a new worktree in worktree/<branch-name> with branch <branch-name>.

Execution

# Return to repo root
cd "$(git rev-parse --show-toplevel)"

# Pull latest master
git checkout master
git pull origin master

# Create worktree
git worktree add worktree/"$ARGUMENTS" -b "$ARGUMENTS"

# Initialize submodules (skills-vendor)
git -C worktree/"$ARGUMENTS" submodule update --init --recursive

# Navigate to worktree
cd worktree/"$ARGUMENTS"

# Confirm location and branch
echo ""
echo "✅ Worktree created and ready:"
echo "   Location: $(pwd)"
echo "   Branch: $(git rev-parse --abbrev-ref HEAD)"
echo ""
echo "You can now work in this isolated environment."

Notes

  • Worktree inherits .claude/skills/ workflows
  • To remove when done: cd ../.. && git worktree remove worktree/"$ARGUMENTS"
  • List all worktrees: git worktree list

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-mtnxbr74/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-mtnxbr74' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/create-a-git-worktree-mtnxbr74/download' --output '.skill-downloads/create-a-git-worktree-mtnxbr74/SKILL.md.part' && mv '.skill-downloads/create-a-git-worktree-mtnxbr74/SKILL.md.part' '.skill-downloads/create-a-git-worktree-mtnxbr74/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

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-mtnxbr74/SKILL.md' && test -s '.skill-downloads/create-a-git-worktree-mtnxbr74/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/wt' && cp -R '.skill-downloads/create-a-git-worktree-mtnxbr74' '.claude/skills/wt'

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-mtnxbr74'

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

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-mtnxbr74/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