using-git-worktrees

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

Updated Jul 23, 2026
One-click install
npx skills add https://github.com/shrek-abaper/sap-nexus-agent --skill using-git-worktrees-shrek-abaper
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: using-git-worktrees
Source: https://github.com/shrek-abaper/sap-nexus-agent/tree/main/.comet/skills/skills/using-git-worktrees
Command: npx skills add https://github.com/shrek-abaper/sap-nexus-agent --skill using-git-worktrees-shrek-abaper

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Starting feature work directly in your main checkout risks polluting your current branch and mixing unrelated changes. This Skill ensures every piece of work happens in an isolated workspace, detecting existing isolation first and falling back to git worktrees only when no native tool exists. ## Core Features & Use Cases - Isolation Detection: Checks whether you are already inside a linked worktree or a git submodule before creating anything, preventing nested worktrees. - Native Tool Preference: Defers to platform-native worktree tools (e.g., EnterWorktree) and only uses manual git worktree add as a fallback. - Safe Directory Handling: Selects worktree locations by priority (explicit instructions > existing .worktrees/ or worktrees/ > default), and verifies the directory is git-ignored before creation. - Baseline Verification: Auto-detects the project type (Node, Rust, Python, Go), installs dependencies, and runs tests to confirm a clean starting state. - Use Case: Before implementing a new feature, ask the assistant to set up an isolated workspace; it will create a worktree on a new branch, install dependencies, and confirm tests pass before any code changes begin. ## 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 an isolated workspace with git worktree?▼

Run `git worktree add <path> -b <branch-name>` to create a linked worktree on a new branch, then cd into it. Verify the target directory is git-ignored first if it lives inside the project, such as `.worktrees/`.

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 and `git rev-parse --show-superproject-working-tree` returns nothing, you are in a linked worktree rather than a submodule or normal checkout.

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

Prefer the native worktree tool when your platform provides one, such as an EnterWorktree command, because it manages directory placement, branch creation, and cleanup. Use manual `git worktree add` only when no native tool is available.

Why does git worktree creation fail with a permission error?▼

A sandboxed environment can block `git worktree add` with a permission denial. In that case, work in the current directory instead, then run project setup and baseline tests in place.

What happens if baseline tests fail in a new worktree?▼

Failing baseline tests indicate pre-existing issues rather than problems from your new work. Report the failures and get explicit confirmation before proceeding, so new bugs are not confused with existing breakage.