docs(worktrees): support the OS temp directory as a worktree location#1985
Open
muunkky wants to merge 1 commit into
Open
docs(worktrees): support the OS temp directory as a worktree location#1985muunkky wants to merge 1 commit into
muunkky wants to merge 1 commit into
Conversation
Support using $TMPDIR for worktrees so short-lived ones get reaped by the OS. Cleanup ownership is decided by path, so the temp location has to keep a worktrees/ component or finishing-a-development-branch disowns it and leaves the branch attached.
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 #666. Taking the second pass you invited when you closed #668.
Who is submitting this PR? (required)
claude-opus-4-8), 1M contextsuperpowersitself.What problem are you trying to solve?
#666 asks for one thing: let worktrees live in the OS temp directory, so short-lived ones get reaped without anyone having to remember them. Today the skill offers
.worktrees/at the project root and nothing else.There's a trap in doing it naively, and it's the actual content of this change.
finishing-a-development-branchdecides what it owns by path:So if the skill starts putting worktrees at, say,
$TMPDIR/superpowers-worktrees/, superpowers creates them and then disowns them at cleanup — the worktree is never removed and the branch delete fails with it still attached.What does this PR change?
Documents the temp directory as a location, with the path shape that keeps cleanup working. Ten added lines in
using-git-worktrees, nothing removed.The
worktrees/component is the whole point: the existing ownership check matches on it, so the temp worktree stays superpowers-owned and gets removed normally. No lifecycle system, no registry, no daemon — and no change tofinishing-a-development-branch.Also notes what the issue itself raises: this suits short-lived branches,
$TMPDIRis reaped on a schedule you don't control, and a directory that vanishes mid-branch needsgit worktree prune(which the cleanup path already runs).Is this change appropriate for the core library?
Yes — a configuration option in a core skill, and it's what #666 asked for.
What alternatives did you consider?
The obvious one is to extend the ownership rule in
finishing-a-development-branchto name a temp path explicitly. That would be more robust: it wouldn't depend on people keeping theworktrees/component in the path. I didn't do it because it turns out not to be necessary — a path underworktrees/already satisfies the rule as written — and reusing the existing check beats adding a second one.The price: if someone sets a temp location without that component, cleanup silently disowns the worktree. That's a real footgun and it's the reason the guidance spells the path out rather than saying "use
$TMPDIR".I also didn't touch option 2 from the issue body (
~/.config/superpowers/worktrees/). The rototill removed that path deliberately andtests/claude-code/test-worktree-path-policy.shasserts it doesn't come back.Does this PR contain multiple unrelated changes?
No. One file, one option.
Existing PRs
#668 is the prior attempt. You closed it as "a massive amount of complexity for what should be a straightforward configuration option" — a JSON registry, CLI manager, GC daemon, post-merge hooks and LaunchAgents. This is the straightforward option: ten lines of guidance, no new machinery, no new files.
#1933 rewrote the ownership block in
finishing-a-development-branchand has since merged. I've re-checked this againstdevafter that landed: the rule still matches on.worktrees/orworktrees/, so the path shape here still works and this PR still doesn't need to touch that file.Also related: #1542 asks for a RAM-backed worktree location. Not building for it — one problem per PR — but it's the same "configurable non-default location" shape, so the convention here is the one it would inherit.
Environment tested
claude-opus-4-8(1M context)tests/claude-code/test-worktree-path-policy.shpasses. I checked the ownership claim by reading the rule on currentdev, not by running a macOS reap — I'm on Linux and haven't reproduced the$TMPDIRcleanup timing the issue describes.Evaluation
No eval sessions. This adds a documented option below the existing priority order and changes no existing instruction — the default is still
.worktrees/— so there's no prior behaviour to compare against. If you'd rather see a baseline, I can run one.Rigor
superpowers:writing-skillsand completed adversarial pressure testingFirst box unticked: I didn't use
writing-skillsand have no pressure-test results.The adversarial part I did do is the failure mode above — I went looking for how this breaks, found the disown-at-cleanup path, and checked that the path-policy test still passes and the deleted global path stays deleted.
Human review