TimZander / TimZander/claude

standards/CLAUDE.md: git worktree cannot remove the worktree you're standing in

Open Beginner friendly
#168 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
0
Forks
1
Avg merge
1d 3h
Merged PRs (30d)
7

Description

Problem

While cleaning up a merged feature worktree, removal could not be done from within the worktree itself. Two compounding reasons:

  1. git refuses to git worktree remove the worktree that is the current working directory.
  2. Windows locks any directory that is a live process's CWD, so even a forced Remove-Item fails with "being used by another process."

Since start-work creates worktrees under .claude/worktrees/ by default, an agent (or developer) operating inside a merged worktree cannot self-remove it — the cleanup step silently stalls or errors unless you know to run it from elsewhere.

Goal

Add a short rule to the git-hygiene / worktree area of standards/CLAUDE.md so this is handled correctly the first time.

Proposed content (for standards/CLAUDE.md)

Removing a worktree

You cannot remove the worktree you are currently standing in — git worktree remove refuses,
and on Windows the OS locks the live CWD so the directory can't be deleted either. Run cleanup
from the main repository (or another worktree):

# From the MAIN repo checkout, not the worktree being removed:
git worktree remove .claude/worktrees/<name>        # add --force if it has untracked files
git branch -d branches/<id>-<slug>                  # -d only deletes if merged; -D to force
git push origin --delete branches/<id>-<slug>       # if the remote branch is no longer needed

A branch checked out in a worktree can't be deleted until that worktree is removed first.

Acceptance criteria

  • standards/CLAUDE.md documents that worktree removal must run from outside the target worktree.
  • Notes the git refusal and the Windows CWD-lock.
  • Includes the correct removal order (remove worktree → delete local branch → delete remote branch).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open standards/CLAUDE.md and find the git-hygiene or worktree guidance. Add a short rule explaining that cleanup must run from the main repository or another worktree because Git refuses removal from the current worktree and Windows locks the live CWD. Document the order: remove the worktree, delete the local branch, then delete the remote branch.

Written by the indexing model from the issue text.

Assessment

Tech stack
git
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.