Skip to content

fix(rig-worktree): default worktrees to .claude/worktrees so the harness can manage them (#61) - #62

Merged
pgebheim merged 1 commit into
mainfrom
fix/61-worktree-default-claude
Aug 5, 2026
Merged

pgebheim merged 1 commit into
mainfrom
fix/61-worktree-default-claude

Conversation

@pgebheim

@pgebheim pgebheim commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

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 by rig-worktree / setup-worktree.sh can be adopted natively via EnterWorktree/ExitWorktree instead of only being reachable by cd.

--path still overrides, and remove-worktree.sh resolves targets via git 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.sh claimed "(kept branch)" after force-deleting it. KEEP_BRANCH is "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.sh aborted on repos with no gitignored .env files. The env-symlink filter chain ends in a grep that exits 1 on no match; under set -o pipefail that killed the script before it printed the path or installed deps. Guarded with || true; also routed git worktree add's "HEAD is now at …" stdout chatter to stderr so stdout carries only the path (the | tail -1 contract callers rely on).

Verification

End-to-end smoke test (create → inspect → remove), both branch-disposition paths:

  • create → worktree lands under .claude/worktrees/, appears in git worktree list, is a populated checkout (harness-adoptable) ✓
  • tail -1 of stdout is exactly the worktree path ✓
  • remove (default) → deletes branch, reports (deleted branch …)
  • remove --keep-branch → keeps branch, reports (kept branch)

🤖 Generated with Claude Code

…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
@pgebheim
pgebheim merged commit 41283b3 into main Aug 5, 2026
2 checks passed
@pgebheim
pgebheim deleted the fix/61-worktree-default-claude branch August 5, 2026 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rig-worktree: place worktrees under .claude/worktrees/ so the Claude Code harness can manage them

1 participant