Repository navigation
Closed
feat(source-control): remove worktrees across repositories when cleanup runs outside a repository#11120
Feature
Copy link
Labels
agent-readyFully specified and briefed; eligible for autonomous pickup from the frontier.status: readyTriaged, unblocked, and fully specified; eligible to pick up.
Description
Refs: #7453
Agent Brief
Type: Feature
Summary: /source-control:worktree cleanup run outside a repository acts across repositories: it finds the same repositories as audit, shows the safe candidates grouped by repository behind one confirm, and removes each confirmed worktree from inside its owning repository with the single-repository guards unchanged.
Current behavior:
plugins/source-control/skills/worktree/context/cleanup.md(around :18): "Outside a repository, cleanup reports and removes nothing." It lists candidates per owning repository and tells the person to run cleanup from each one.scripts/worktree-discover.shalready maps every worktree to its owning repository, andauditoutside a repository already uses it (context/audit.mdaround :9).- fix(source-control): run the worktree reap without moving the caller's working directory #8021 made the removal sequence keep the caller's working directory out of the candidate.
Desired behavior (from #7453's proposed fix):
- Cleanup's out-of-repository path uses the
worktree-discover.shrows, runs the existing per-repository candidate logic (Step 2) for each owning repository, and shows one grouped confirm (Step 3's batching across repositories). - For each confirmed row, every Step 4 guard and the removal run against the owning repository with
git -C <owning-repo>(or a subshellcd), so the per-repository safety logic is unchanged and no directory change persists in the caller's shell. - The per-row stranded, superseded and unknown stops behave exactly as in a single-repository run.
--dry-runoutside a repository lists what would be removed and removes nothing.
Done when
-
cleanup.mdno longer says that cleanup outside a repository removes nothing; it describes the cross-repository path above. - An eval case: two repositories under one worktree root, each with one removable and one stranded worktree, cleanup run outside any repository. The expected output shows one grouped confirm, removes only the two removable worktrees, each through its owning repository, stops on both stranded rows, and leaves the caller's directory unchanged.
-
bash plugins/skill-quality/scripts/check-skill.sh plugins/source-control/skills/worktreeexits 0. -
scripts/check-changelog-fragments.shpasses with a source-control fragment.
Out of scope:
- Changing the guards themselves, or what counts as a safe candidate.
auditandstatusbehavior.
Metadata
Metadata
Assignees
Labels
agent-readyFully specified and briefed; eligible for autonomous pickup from the frontier.status: readyTriaged, unblocked, and fully specified; eligible to pick up.
Type
Fields
No fields configured for Feature.
Activity
github-actions commentedon Oct 30, 2026
Proposed work class: work-class: scoped
Basis: automated intake triage; the lanes App applied this class.
Size: Medium
Complexity: Medium
Uncertainty: Known
Flags: none
Blocked by: none
Understood: you want
/source-control:worktree cleanup, when run outside a repository, to reuse theworktree-discover.shrows. It would show one grouped confirm and remove each confirmed worktree through its owning repository. The single-repository guards stay unchanged, and--dry-runremoves nothing. The brief gives the current behavior, the desired behavior, the done-when items and the out-of-scope items, so I found nothing missing. I found no likely duplicates among the open issues. This is a follow-on to #7453.Automated triage, applied by the lanes App.