Create Git Worktree

VerifiedCaution

Create a new Git worktree for an existing or new branch, using the project's collector directory convention.

Sby Skills Guide Bot
DevelopmentIntermediate
8/6/2026
Claude Code
#git-worktree#branch-management#spec-kit#workflow-automation

Recommended for

Automated summary

Creates a Git worktree for a specified branch under a project-specific collector directory, following the spec-kit convention.

Strengths

  • Enforces a consistent worktree path convention derived from the primary checkout
  • Supports an optional start-point and explicit --path/--parent overrides
  • Offers to move into the new worktree immediately after creation
  • Handles common failures such as missing Git or an existing target path with clear messages

Limitations

  • Requires a spec-kit project structure with a .specify/ directory and the associated bash script
  • Relies on Claude Code-specific mechanisms such as AskUserQuestion and $ARGUMENTS
  • Does not cover removing or cleaning up existing worktrees
When to use it

Use when you need to create an isolated working directory for a branch inside a spec-kit project.

When not to use it

Avoid in non-spec-kit repositories or when you need to remove or manage existing worktrees rather than create one.

Security analysis

Caution
Quality score84/100

The skill is a legitimate Git worktree helper and does not contain destructive commands, secret exfiltration, obfuscation, or safety-disabling instructions. It does use Bash and filesystem/Git mutations, plus absolute path overrides, so it warrants caution rather than being purely informational.

Findings
  • •Invokes a local Bash script (`.specify/extensions/git/scripts/bash/worktree-add.sh`) whose contents are not shown or validated.
  • •Allows absolute `--path` and `--parent` overrides, so worktrees/directories can be created outside the default collector location.
  • •Instructs execution of `cd <WORKTREE_PATH>` after confirmation, which relies on shell execution in the agent environment.
How this analysis is made

Examples

Create feature worktree
Create a new Git worktree for the branch feature/payments using the project's usual .worktrees collector directory.
Start from main
Create a worktree for a new branch hotfix/login starting from main.
Custom path
Create a Git worktree for branch docs/api-reference at /tmp/worktrees/api-docs.

name: speckit-git-worktree description: Create a new git worktree under the project's ${PROJ}.worktrees collector directory compatibility: Requires spec-kit project structure with .specify/ directory metadata: author: github-spec-kit source: git:commands/speckit.git.worktree.md

Create Worktree

Create a new Git worktree for an existing or new branch. By default, the command derives the collector directory from the primary checkout and places the worktree at:

<parent-of-primary-checkout>/<project>.worktrees/<branch>

This matches the same convention used by the feature workflow.

User Input

$ARGUMENTS

You MUST consider the user input before proceeding (if not empty).

Behavior

  1. Require a branch argument (<branch>).
  2. Optionally accept a start-point (<start-point>) to create a new branch from.
  3. Derive the target path using the shared collector convention unless overridden.
  4. Create the collector directory when missing.
  5. Create the worktree with git worktree add.
  6. After successful creation, ask the user whether to move into the new worktree directory using the AskUserQuestion tool.
  7. Print a short status summary including branch and path.

Post-Creation Prompt

After parsing command output and obtaining WORKTREE_PATH, call the AskUserQuestion tool with a yes/no choice:

  • question: Worktree created at <WORKTREE_PATH>. Move into this directory now?
  • options[]:
    • {label: "Yes", description: "I will move into the new worktree now"}
    • {label: "No", description: "Stay in the current directory"}
  • multiSelect: false

If the user selects Yes, output and execute the command:

cd <WORKTREE_PATH>

If the user selects No, continue without changing directories.

Arguments

  • --path <absolute-path>: Explicit worktree path override (same behavior as SPECKIT_WORKTREE_PATH).
  • --parent <absolute-path>: Explicit collector directory override (same behavior as SPECKIT_WORKTREE_PARENT).
  • <branch>: Required branch name.
  • <start-point>: Optional revision/branch/tag used when creating a new branch.

Execution

  • Bash: .specify/extensions/git/scripts/bash/worktree-add.sh [--path <absolute-path>] [--parent <absolute-path>] <branch> [<start-point>]

Graceful Degradation

  • If Git is not available or the current directory is not a repository: warn and exit.
  • If the target path already exists: refuse and explain how to override with --path.
  • If branch creation/worktree add fails: print Git error output and exit non-zero.

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

Environment declared by the author: Requires spec-kit project structure with .specify/ directory

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

openskills read 'create-git-worktree-msh3us7t'

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-git-worktree-msh3us7t/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