using-git-worktrees

Automates creation of isolated Git worktrees for feature development.

Updated Dec 4, 2025
One-click install
npx skills add https://github.com/jr2804/prompts --skill using-git-worktrees-jr2804
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: using-git-worktrees
Source: https://github.com/jr2804/prompts/tree/main/skills/development/using-git-worktrees
Command: npx skills add https://github.com/jr2804/prompts --skill using-git-worktrees-jr2804

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps teams safely start feature work by creating isolated git worktrees, preventing changes from affecting the main workspace and providing a consistent baseline.

Core Features & Use Cases

  • Directory discovery and selection: Chooses a project-local or global worktree location based on existing directories and CLAUDE.md preferences.
  • Safety verification: Verifies the chosen directory is ignored by git and enforces best practices to prevent accidental commits of worktree contents.
  • Automatic setup: Detects project type (Node.js, Rust, Python, Go) and runs the appropriate setup commands after creating the worktree.
  • Use Case: Start feature development on a new branch without disrupting the main development tree.

Quick Start

Tell the system you want to create an isolated worktree for a feature and follow these steps:

  1. Check for existing worktree directories (.worktrees or worktrees) and decide location.
  2. If none exist, consult CLAUDE.md for a location preference; if still none, ask the user.
  3. Ensure the chosen directory is ignored by git; if not, add it to .gitignore and commit.
  4. Create the worktree with git worktree add "<path>" -b "<BRANCH_NAME>" and cd into the new path.
  5. Run project setup commands automatically based on project files (package.json, Cargo.toml, requirements.txt, etc.).
  6. Run the project’s test suite to verify a clean baseline.

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 an isolated git worktree for feature development?

You can create an isolated git worktree by checking for local worktree directories, validating gitignore, running git worktree add with a new branch, and executing detected project setup commands.

What is the best way to prevent accidental commits of git worktree contents?

The best way to prevent accidental commits of git worktree contents is to ensure the worktree directory is ignored by git, adding it to .gitignore and committing the change before creating the worktree.

Can I use git worktrees with Node.js, Rust, Python, and Go projects?

Yes, git worktrees work with Node.js, Rust, Python, and Go projects by detecting project files like package.json, Cargo.toml, and requirements.txt to run the appropriate setup commands after creating the worktree.

How does directory discovery work when creating a git worktree?

Directory discovery for git worktrees checks for existing project-local directories like .worktrees or worktrees, then consults CLAUDE.md for global location preferences, and finally asks the user if no preference is found.

Do I need to run project tests after setting up a git worktree?

Yes, the skill runs the project test suite after creating the git worktree and executing setup commands to verify a clean baseline before starting feature development.

Why should I use isolated git worktrees instead of branching in the main workspace?

Isolated git worktrees prevent changes from affecting the main workspace by providing a separate directory for each branch, ensuring a consistent baseline without disrupting your main development tree.