Using git worktrees

From skeletorflet/opencode-supreme-setup · View interactive version

Using git worktrees is an AI agent skill from the GitHub repository skeletorflet/opencode-supreme-setup. Use when starting feature work that needs isolation from current workspace or before executing implementation plans

How to use this skill

Skill file

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.

Step 0: Detect Existing Isolation

Check if already in an isolated workspace using git rev-parse --git-dir and git rev-parse --git-common-dir.

If GIT_DIR != GIT_COMMON, you are already in a linked worktree. Skip to project setup.

Step 1: Create Isolated Workspace

Prefer native worktree tools. Fall back to git worktree add.

Step 3: Project Setup

Auto-detect and run appropriate setup (npm install, cargo build, pip install, etc.).

Step 4: Verify Clean Baseline

Run tests to ensure workspace starts clean.

Quick Reference

| Situation | Action |

|-----------|--------|

| Already in linked worktree | Skip creation |

| Native worktree tool available | Use it |

| No native tool | Git worktree fallback |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.