using-git-worktrees

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

Updated May 21, 2026
One-click install
npx skills add https://github.com/CagesThrottleUs/private-ai-harness --skill using-git-worktrees-cagesthrottleus
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: using-git-worktrees
Source: https://github.com/CagesThrottleUs/private-ai-harness/tree/main/skills/using-git-worktrees
Command: npx skills add https://github.com/CagesThrottleUs/private-ai-harness --skill using-git-worktrees-cagesthrottleus

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Feature work done directly in a shared checkout risks contaminating the current branch and mixing unrelated changes. This Skill guarantees every implementation task starts in an isolated workspace, using the platform's native worktree tooling when available and falling back to manual git worktrees otherwise. ## Core Features & Use Cases - Isolation Detection: Detects whether you are already inside a linked worktree or a git submodule before creating anything, avoiding nested or duplicate workspaces. - Native Tool Preference with Git Fallback: Uses harness-native worktree tools (e.g., EnterWorktree, /worktree commands) first, and only runs git worktree add when no native tool exists, with directory priority rules and .gitignore safety verification. - Baseline Verification and CI Gate: Auto-detects the project stack (Node, Rust, Python, Go), installs dependencies, runs the test suite for a clean baseline, and invokes the ci-pipeline-setup skill if no CI configuration exists. - Use Case: Before implementing a new feature, ask the agent to set up an isolated workspace; it creates .worktrees/my-feature, installs dependencies, confirms tests pass, and reports the workspace is ready. ## Quick Start Set up an isolated git worktree for my new feature branch and verify the test baseline is clean 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 an isolated git worktree for a 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/my-feature -b my-feature. Prefer your platform's native worktree tool if one is available, since it manages placement and cleanup automatically.

How to 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 produces the same mismatch.

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

Use the native tool whenever one exists, such as an EnterWorktree tool or a /worktree command. Native tools own directory placement, branch creation, and cleanup; calling git worktree add directly creates state the harness cannot see or manage.

Why must the worktrees directory be in .gitignore?

An unignored project-local worktree directory risks committing the entire nested worktree contents into the repository. Verify with git check-ignore before creating the worktree, and add the directory to .gitignore and commit that change if it is not ignored.

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, then run dependency setup and baseline tests in the current directory instead of creating a worktree.

When should baseline tests run in a new worktree?

Run the project's test suite immediately after dependency installation, before writing any feature code. A clean baseline ensures later failures are attributable to your changes; if tests fail, report the failures and ask whether to proceed.