using-git-worktrees

Create isolated Git worktrees for feature branches and validate test baselines.

Updated Apr 30, 2026
One-click install
npx skills add https://github.com/koseki2580/skills --skill using-git-worktrees-koseki2580
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: using-git-worktrees
Source: https://github.com/koseki2580/skills/tree/main/skills/using-git-worktrees
Command: npx skills add https://github.com/koseki2580/skills --skill using-git-worktrees-koseki2580

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Using a single working directory for multiple branches can cause conflicts, accidental commits, and messy state when you need isolation for feature development.

Core Features & Use Cases

  • Isolated workspaces per branch: Create and switch to an isolated directory using git worktree without disturbing your current workspace.
  • Project-local safety guardrails: When using a project-local .worktrees/ or worktrees/ directory, it verifies the directory is ignored by git before creating the worktree to prevent accidental tracking.
  • Baseline setup and validation: Automatically runs project setup (e.g., npm/cargo/pip) and verifies a clean test baseline so you know the new workspace starts in a good state.
  • Real-world use case: Start a long-running feature branch while keeping the main working directory clean, then run tests to confirm the baseline before you begin implementing the feature.

Quick Start

Use the skill to create an isolated worktree for your feature branch, then run the project’s setup and verify the test baseline before implementation.

Frequently Asked Questions about using-git-worktrees

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

FAQPage Schema
How do I isolate feature work with Git worktrees to avoid contaminating my current workspace?

To isolate feature work with Git worktrees, create a separate directory using `git worktree add -b`. This prevents conflicts and accidental commits in your main working directory while keeping branch state independent.

What is the safest way to set up a Git worktree directory for a new branch?

The safest way to set up a Git worktree is to use a project-local directory like `.worktrees/` and verify it is ignored with `git check-ignore`. This prevents the worktree files from being accidentally tracked by Git.

How do I validate a clean test baseline when creating a Git worktree?

To validate a clean test baseline in a new Git worktree, automatically run project setup commands like npm or cargo, then execute the project's test command to confirm the workspace starts in a good state before implementation.

Can I run dependency setup automatically when adding a Git worktree?

Yes, dependency setup can run automatically when adding a Git worktree by detecting project files like package.json or Cargo.toml. This ensures the isolated workspace has all required dependencies installed before you begin feature work.

When should I use Git worktrees instead of switching branches in a single directory?

You should use Git worktrees instead of switching branches when you need isolated workspaces for long-running features. This approach avoids messy state and conflicts that often occur when managing multiple branches in a single working directory.

Why does my project-local worktree directory need to be ignored by Git?

Your project-local worktree directory needs to be ignored by Git to prevent accidental tracking of nested repository files. Verifying ignore status with `git check-ignore` ensures the worktree remains a safe, isolated workspace.