Skip to content
Agentmart
Submit a tool

using-git-worktrees

Use when starting feature work that needs isolation from the current workspace, or before executing implementation plans

Skill by basnijholt

IndexedMIT★ 1
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/basnijholt-using-git-worktrees

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Use when starting feature work that needs isolation from the current workspace, or before executing implementation plans

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/using-git-worktrees

What's inside

Skill name
using-git-worktrees
Description
Use when starting feature work that needs isolation from the current workspace, or before executing implementation plans
License
MIT
Instructions
50 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# Using Git Worktrees

**Before reading or editing any project file, decide where to work.**
Implementation happens in a worktree that holds only your work, never in the
main checkout and never on main/master. If your human partner asks you to work
in place, do so.

## 1. Check the current checkout

```bash
git rev-parse --git-dir --git-common-dir
git status --porcelain
git rev-list --count origin/main..HEAD
```

Reuse the current checkout only if all of these hold:

- the two git dirs differ. Equal dirs (e.g. `.git` twice) mean you are in
  the main checkout: go to step 2, even if it is clean;
- `git status --porcelain` prints nothing;
- the count is 0, apart from commits you made in this session.

A session can open in a worktree another agent is still using, so being in a
worktree is not enough. Never commit, stash, or reset changes you did not make.
A detached HEAD in a fresh worktree is fine; baspowers:finishing-a-development-branch
creates the branch. If any check fails, go to step 2.

## 2. Create a new worktree

1. **Directory:** the one your instructions name, else an existing
   `.worktrees/` or `worktrees/` in the main checkout's root (first line of
   `git worktree list`), else `.worktrees/` there.
2. **Ignore it first:** `git check-ignore -q <dir>` must succeed before you
   create the worktree. If it fails, append the directory to
   `$(git rev-parse --git-common-dir)/info/exclude` (create the file if
   missing). Do not commit a `.gitignore` change.
3. **Create from the default branch, not HEAD:**
   `git fetch origin && git worktree add -b <branch> <dir>/<branch> origin/main`
4. **Stay there:** do all remaining work in the new worktree, with absolute
   paths; some harnesses reset the shell's directory between commands.

If worktree creation is blocked, say so. Work on a new branch in place only if
the current checkout is fresh; otherwise stop and report.

## 3. Baseline

Install dependencies the way the project does and run its test suite before
changing anything. Report pre-existing failures separately from your work.

From basnijholt/baspowers, MIT.

More from basnijholt/baspowers

Signals

Stars
1
Forks
0
Open issues
0
Last commit (this folder)
Oct 8, 2026 (20 days ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from basnijholt

Cite this page

using-git-worktrees skill. Agent Mart. https://agentmart.dev/skills/basnijholt-using-git-worktrees (last updated 2026-10-24)