using-git-worktrees

Creates isolated git worktrees with directory selection, gitignore verification, and baseline test validation.

3|Updated May 8, 2026
One-click install
npx skills add https://github.com/wan-huiyan/agent-traffic-control --skill using-git-worktrees-wan-huiyan
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: using-git-worktrees
Source: https://github.com/wan-huiyan/agent-traffic-control/tree/main/plugins/agent-traffic-control/skills/using-git-worktrees
Command: npx skills add https://github.com/wan-huiyan/agent-traffic-control --skill using-git-worktrees-wan-huiyan

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? When starting feature work, developers often need an isolated workspace without disturbing their current checkout. Manually creating git worktrees risks polluting the repository with unignored directories, picking inconsistent locations, or starting from a broken baseline that hides pre-existing test failures. ## Core Features & Use Cases - Systematic Directory Selection: Follows a priority order of existing .worktrees/ or worktrees/ directories, then CLAUDE.md preferences, then asking the user, so worktree locations stay consistent across sessions. - Safety Verification: Runs git check-ignore before creating project-local worktrees and automatically adds missing entries to .gitignore and commits them, preventing worktree contents from being tracked. - Automated Setup and Baseline Validation: Auto-detects project type (Node.js, Rust, Python, Go) to install dependencies, then runs the test suite to confirm a clean baseline before implementation begins. - Use Case: Before executing an implementation plan for a new auth feature, create a worktree at .worktrees/auth on branch feature/auth, run npm install and npm test, and confirm 47 passing tests before writing any code. ## Quick Start Set up an isolated git worktree for my new feature branch and verify the project tests pass before I start implementing.

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 for a new feature branch?▼

Run git worktree add with a target path and the -b flag to create a new branch, for example git worktree add .worktrees/auth -b feature/auth. Then change into that directory and install project dependencies before starting work.

Where should git worktrees be stored in a project?▼

Prefer an existing .worktrees or worktrees directory in the project, with .worktrees winning if both exist. If neither exists, check CLAUDE.md for a stated preference, otherwise ask the user or use a global location outside the repository.

Why should worktree directories be added to gitignore?▼

Project-local worktree directories must be ignored so their contents are never tracked or committed to the repository. Verify with git check-ignore before creating the worktree, and if not ignored, add the entry to .gitignore and commit it first.

Should I run tests before starting work in a new worktree?▼

Yes, run the project test suite immediately after setup to establish a clean baseline. If tests fail, report the failures and get explicit confirmation before proceeding, so new bugs are not confused with pre-existing issues.

How do I clean up duplicate clones and stale worktrees?▼

Compare remotes with git remote -v and list relationships with git worktree list. Before deleting, check for uncommitted changes, stashes, unpushed commits, and unmerged branches, then remove with git worktree remove or rm -rf for verified stale clones.