using-git-worktrees

Automate Git worktree creation and isolation for feature branches with safety checks.

103|30|Updated Dec 24, 2025
One-click install
npx skills add https://github.com/CommandCodeAI/agent-skills --skill using-git-worktrees-commandcodeai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: using-git-worktrees
Source: https://github.com/CommandCodeAI/agent-skills/tree/main/skills/using-git-worktrees
Command: npx skills add https://github.com/CommandCodeAI/agent-skills --skill using-git-worktrees-commandcodeai

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers isolate feature work by creating dedicated git worktrees that share the same repository, enabling parallel development without constantly switching branches or disrupting the main workspace.

Core Features & Use Cases

  • Automatic worktree discovery and creation based on a priority: local project directories (.worktrees or worktrees) and preferences indicated in CLAUDE.md.
  • Safety-focused workflow that verifies the selected worktree directory is ignored by git to prevent accidental commits of worktree contents.
  • Flexible placement: project-local worktrees or a global user-space location, with automatic project name resolution and a clean setup for immediate work.
  • Use Case: Start a new feature branch in isolation, run tests, and validate changes without touching the main working directory.

Quick Start

Initiate the isolated workspace by instructing the AI to perform the following sequence:

  1. Detect existing worktree directories and choose based on priority (.worktrees > worktrees).
  2. If none exist, consult CLAUDE.md for a preferred location or prompt the user.
  3. Verify the chosen location is ignored by git; if not, update .gitignore and commit.
  4. Create the new worktree with git worktree add and switch into it.
  5. Run project setup commands automatically (npm install, cargo build, pip install) as detected by project files.
  6. Confirm the worktree is ready for feature development and report the path and status.

Frequently Asked Questions about using-git-worktrees

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a git worktree without accidentally committing its files?

To create a git worktree safely, verify the target directory is ignored by git. This skill automates this by checking the selected worktree location against .gitignore and updating it if necessary to prevent accidental commits.

What is the best way to isolate feature branches in a shared repository?

Isolating feature branches is best done using git worktrees. This creates dedicated working directories sharing the same repository, enabling parallel development without constantly switching branches or disrupting the main workspace.

How do I set up a git worktree and install project dependencies automatically?

You can set up a git worktree and install dependencies by creating the worktree and running project setup commands. This skill detects project files and automatically executes commands like npm install or cargo build for a clean baseline.

Can I specify a global location for git worktrees outside my project directory?

Yes, you can use a global location for git worktrees. This skill supports flexible placement in project-local directories or global user-space locations, automatically resolving project names and consulting CLAUDE.md for preferences.

Why does my git worktree directory need to be added to gitignore?

Your git worktree directory needs to be in gitignore to ensure safety. Verifying the worktree directory is ignored prevents the contents of your isolated feature work from being accidentally committed to the main repository.