fix(refresh-repo,git-workflow-standards): catch zero-ahead branches; split into prune-branches#445
Merged
Merged
Conversation
…not just [gone] clean_gone only deletes [gone] branches; it found nothing to clean on a repo carrying two dead branches whose commits were already fully contained in main (pure ancestors, never [gone] since their remotes were still live). The real signal for "nothing useful" is ahead-count against the default branch, not remote-tracking status — [gone] was only ever a narrowing proxy for "probably merged." - refresh-repo Step 5 (renamed Branch and Worktree Cleanup): the stale ahead-count check is now unconditional, no longer gated on [gone]. Three passes cover every ref shape: worktree-paired (existing), bare local branches with no worktree, and remote-only branches with no local ref at all. Any local delete now also deletes the matching live remote branch. - git-workflow-standards: same rule, condensed to match this file's prose style, kept in sync per its own documented expectation. Widening "ahead of default" to run without [gone] is only safe because a protected-branch guard (default branch, checked-out-anywhere, referenced by an open PR as --head or --base) now runs first and unconditionally on every one of the three passes independently — dropping that guard would let the rule autonomously delete origin/main on a git-flow repo, since main is routinely an ancestor of develop there. The remote-delete step also re-confirms ancestry immediately before the destructive push (not once at the top of the run), since git push origin --delete ignores tip state and a race would silently discard new commits. Independently reviewed (Opus, high effort) before landing; the review caught the git-flow guard gap, an incomplete open-PR check (--head only, missing --base), and the missing pre-push recheck — all three folded in. Assisted-by: Claude:claude-opus-4-8 Claude-Session: https://claude.ai/code/session_012s1AcPKsXaLT5e1n6G9M2u
…ches /simplify (4-agent review: reuse, simplification, efficiency, altitude) on the prior commit's diff, plus a direct user request to split refresh-repo so invoking it doesn't load the full branch-cleanup procedure by default. - New skill github-workflows:prune-branches carries Step 5 (Protected/Stale/ three-pass/remote-delete) and the Cross-Repo Operating Modes wholesale. refresh-repo drops from ~264 lines back to 131 — a caller that only wants PR-readiness + sync no longer pays for cleanup prose it isn't using. - git-workflow-standards' "Stale branch" paragraph was re-deriving refresh- repo's mechanism and git-flow safety rationale instead of pointing at it (reuse + altitude agents, independently). Trimmed to the concept, now points at prune-branches as the procedure's new home. - Protected's open-PR check was 2 live `gh pr list` calls per candidate branch; now one repo-wide `--json headRefName,baseRefName` call up front, tested by set membership (efficiency agent). - Applied every negative-framed instruction rewrite the simplification agent proposed (never/NOT/NEVER -> positive statements) and cut the wording it flagged as filler or cross-file duplication. - wrap-up's Path A folds the old external `commit-commands:clean_gone` step into `/prune-branches` (invoked right after `/refresh-repo` in A1) — prune-branches is a strict superset of clean_gone's `[gone]`-only scope, so the separate step and the external plugin dependency both go away. - Updated every stale cross-reference this split or the clean_gone removal touched: plugin.json skill registration, both plugins' README/ARCHITECTURE diagrams, and the Related Skills sections in sync-main, troubleshoot- worktree, session-status, pr-sweep, skills-registry. Assisted-by: Claude:claude-opus-4-8 Claude-Session: https://claude.ai/code/session_012s1AcPKsXaLT5e1n6G9M2u
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.
What
clean_goneonly deletes[gone]branches. It missed two dead branches whose commits were already fully inmain— one had a live remote, one was remote-only after its PR merged. The real "nothing useful" signal is ahead-count against the default branch, not remote-tracking status.Changes
refresh-repoStep 5: stale check is unconditional, not gated on[gone]. Three passes cover every ref shape — worktree-paired, bare local, remote-only. Any local delete now also deletes a live matching remote branch, with a pre-push ancestry recheck.prune-branchescarries that whole procedure (and--sweep/--prune-stale) out ofrefresh-repo, which drops from ~264 lines to 131 — invoking it for PR-readiness + sync no longer loads the full cleanup prose.wrap-upfolds the old externalcommit-commands:clean_gonestep intoprune-branches, called right afterrefresh-repoin Path A —prune-branchesis a strict superset, so the separate step and the external dependency both go away.plugin.json, both plugins' README/ARCHITECTURE diagrams,sync-main,troubleshoot-worktree,session-status,pr-sweep,skills-registry— updated.Safety (independent Opus review before landing)
Dropping
[gone]on its own would let the rule autonomously deleteorigin/mainon a git-flow repo (mainis routinely an ancestor ofdevelop). Fixed with a protected-branch guard — default branch, checked-out-anywhere, referenced by an open PR as--heador--base— re-checked unconditionally on every pass. Also added: the open-PR check covers--base, not just--head; the remote delete re-confirms ancestry immediately before the push, not once at the top of the run.Quality pass (
/simplify, 4-agent review)git-workflow-standardswas re-derivingrefresh-repo's mechanism and git-flow rationale instead of pointing at it — trimmed to the concept, now points atprune-branches.gh pr listcalls per candidate branch; now one repo-wide call up front, tested by set membership.never/NOT/NEVER) rewritten as a direct positive statement, per explicit user direction; cut wording flagged as filler or cross-file duplication.Test plan
clean_gonereference outside the (unrelated, external) Anthropic plugin's own permission string; no remaining "refresh-repo does cleanup" claim anywhere.🤖 Generated with Claude Code
https://claude.ai/code/session_012s1AcPKsXaLT5e1n6G9M2u