fix(rig-worktree): default worktrees to .claude/worktrees so the harness can manage them (#61) - #62
Merged
Merged
Conversation
…ess can manage them (#61) Rig created worktrees under .claude/rig-worktrees/, but the Claude Code harness only adopts worktrees under .claude/worktrees/ — so EnterWorktree / ExitWorktree refused them and you lost the native worktree lifecycle. Point the default there instead; a worktree created by setup-worktree.sh is now adoptable via EnterWorktree({ path }). --path still overrides, and remove-worktree.sh resolves via `git worktree list`, so pre-existing .claude/rig-worktrees/ worktrees still tear down fine. Two adjacent bugs found while verifying end-to-end: - remove-worktree.sh reported "(kept branch)" after force-deleting the branch: KEEP_BRANCH is "0" (non-empty) when the flag is absent, so ${KEEP_BRANCH:+…} always fired. Compare the value; name the deleted branch. - setup-worktree.sh aborted on any repo with no gitignored .env files: the env-symlink filter chain ends in a grep that exits 1 on no match, and under `set -o pipefail` that killed the script before it printed the path or installed deps. Guard the chain with `|| true`; route `git worktree add` stdout chatter to stderr so stdout carries only the path (the `| tail -1` contract). Verified: create → lands under .claude/worktrees/, registered in `git worktree list`, populated checkout; remove (default) deletes the branch and reports it; remove --keep-branch keeps it and reports that. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0157AoJ6PVpKyt5V8GCVrodf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #61.
What
Change the default worktree location from
.claude/rig-worktrees/<branch>to.claude/worktrees/<branch>— the directory the Claude Code harness manages — so a worktree created byrig-worktree/setup-worktree.shcan be adopted natively viaEnterWorktree/ExitWorktreeinstead of only being reachable bycd.--pathstill overrides, andremove-worktree.shresolves targets viagit worktree list, so any pre-existing.claude/rig-worktrees/worktrees still tear down cleanly — no migration needed.Ported from two patches (
0001,0002) authored in a downstream install onto the kit's canonical source paths (scripts/,skills/).Two adjacent bugs fixed while verifying
remove-worktree.shclaimed "(kept branch)" after force-deleting it.KEEP_BRANCHis"0"(non-empty) when the flag is absent, so${KEEP_BRANCH:+…}always expanded. Now it compares the value and names the deleted branch.setup-worktree.shaborted on repos with no gitignored.envfiles. The env-symlink filter chain ends in agrepthat exits 1 on no match; underset -o pipefailthat killed the script before it printed the path or installed deps. Guarded with|| true; also routedgit worktree add's "HEAD is now at …" stdout chatter to stderr so stdout carries only the path (the| tail -1contract callers rely on).Verification
End-to-end smoke test (create → inspect → remove), both branch-disposition paths:
.claude/worktrees/, appears ingit worktree list, is a populated checkout (harness-adoptable) ✓tail -1of stdout is exactly the worktree path ✓(deleted branch …)✓--keep-branch→ keeps branch, reports(kept branch)✓🤖 Generated with Claude Code