skills sourced live from GitHub · all skills listed are free · each skill is provided under its author's license.
home / Coding / Using Git Worktrees Skill by @obra
The skill is the skills/using-git-worktrees folder inside that repository. Copy it into the folder your agent loads skills from; check your agent's documentation for where that is.
Use when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via…
Creates an isolated workspace before feature work begins. It first checks whether isolation already exists, prefers native worktree tools, falls back to git worktrees, then sets up the project and verifies a clean baseline.
The original SKILL.md is organised into these sections:
Written and maintained by @obra. It is published under the MIT license, which allows reuse with attribution. See the author profile. SkillDirectory does not claim authorship: this page adds our own review and links back to the original, and the skill's text belongs to its author.
# Using Git Worktrees ## Overview Ensure work happens in an isolated workspace. Prefer your platform's native worktree tools. Fall back to manual git worktrees only when no native tool is available. **Core principle:** Detect existing isolation first. Then use native tools. Then fall back to git. Never fight the harness. **Announce at start:** "I'm using the using-git-worktrees skill to set up an isolated workspace." ## Step 0: Detect Existing Isolation **Before creating anything, check if you are already in an isolated workspace.** ```bash GIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P) GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P) BRANCH=$(git branch --show-current) ``` **Submodule guard:** `GIT_DIR != GIT_COMMON` is also true inside git submodules. Before concluding "already in a worktree," verify you are not in a submodule: ```bash # If this returns a path, you're in a submodule, not a worktree — treat as normal repo …
Excerpt only, quoted from the author's repository. Open the repository for the complete file.