# Worktree Check

> Use before git write operations (commit, push, merge, rebase) to verify you are in a git worktree. Guides worktree setup if missing. Keywords: worktree, isolation, git commit, git push.

- Skill: `erikpr1994/worktree-check` (Agent Skill)
- Install (CLI): `npx skillmds@latest add erikpr1994/worktree-check`
- Raw SKILL.md: https://api.skillmd.com/api/skills/erikpr1994/worktree-check/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: erikpr1994 (https://skillmd.com/u/erikpr1994)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/erikpr1994/worktree-check

---


# Worktree Check

Ensure git write operations happen inside an isolated worktree.

## When to Use
- Before `git commit`, `git push`, `git merge`, or `git rebase`
- When unsure if you are in a worktree

## Verify Worktree

```bash
# Worktree indicators
[ -f .git ] && echo "worktree"

git rev-parse --git-dir 2>/dev/null | grep -q "/worktrees/" && echo "worktree"
```

If neither check confirms a worktree, create one before proceeding.

## Create Worktree (Recommended)

```bash
# Prefer .worktrees/ if present
ls -d .worktrees worktrees 2>/dev/null

# Ensure gitignored
git check-ignore -q .worktrees || echo ".worktrees/" >> .gitignore

# Create and enter worktree
branch="feature/your-branch"
git worktree add .worktrees/your-branch -b "$branch"
cd .worktrees/your-branch
```

## Proceed Safely

Re-run the git command from inside the worktree once it is created.

## Notes
- If the user asks to proceed without a worktree, confirm explicitly before running git write operations.

