using-git-worktrees

Creates isolated git worktree workspaces with native tool detection and baseline test verification.

Updated Oct 16, 2025
One-click install
npx skills add https://github.com/hugotown/dotfiles --skill using-git-worktrees-hugotown
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: using-git-worktrees
Source: https://github.com/hugotown/dotfiles/tree/main/agents/skills/using-git-worktrees
Command: npx skills add https://github.com/hugotown/dotfiles --skill using-git-worktrees-hugotown

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Feature work done directly in your main checkout risks contaminating your current branch and mixing unrelated changes. This Skill ensures every implementation task starts in an isolated workspace, using your platform's native worktree tools when available and falling back to manual git worktrees otherwise. ## Core Features & Use Cases - Isolation Detection: Checks whether you are already inside a linked worktree or a submodule before creating anything, avoiding duplicate or phantom workspaces. - Native Tool Preference with Git Fallback: Uses harness-provided worktree tools (e.g., EnterWorktree) first, and only runs git worktree add when no native tool exists. - Safe Directory Selection: Picks .worktrees/ or worktrees/ based on existing conventions, verifies the directory is git-ignored, and commits the ignore rule if needed. - Use Case: Before implementing a new feature branch, the Skill sets up .worktrees/feature-x, installs dependencies (npm, cargo, pip, or go), runs the test suite to confirm a clean baseline, and reports readiness. ## Quick Start Ask the AI to set up an isolated worktree for your next feature branch and verify the project tests pass before starting 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 create an isolated git worktree for feature development?▼

Run `git worktree add <path> -b <branch-name>` to create a linked worktree on a new branch. Prefer placing it in a `.worktrees/` directory at the project root, and verify that directory is listed in .gitignore before creating it.

How do I check if I am already inside a git worktree?▼

Compare `git rev-parse --git-dir` with `git rev-parse --git-common-dir`. If they differ, you are in a linked worktree; also run `git rev-parse --show-superproject-working-tree` to rule out being inside a submodule, which shows the same difference.

Should I use git worktree add or a native worktree tool?▼

Use the native tool (such as EnterWorktree or a /worktree command) whenever one is available, because it manages directory placement, branching, and cleanup. Manual `git worktree add` is only a fallback and can create state the harness cannot track.

Why must the worktrees directory be added to .gitignore?▼

An unignored worktree directory causes the entire nested worktree contents to be committed into the parent repository. Verify with `git check-ignore -q .worktrees` and commit the ignore rule before creating the worktree.

What happens if git worktree add fails with a permission error?▼

A permission error usually means the sandbox blocked worktree creation. The fallback is to inform the user, continue working in the current directory, and still run dependency setup and baseline tests in place.