feat(skills): add branch-supersede-check - #183
Open
MCamner wants to merge 1 commit into
Open
Conversation
`git diff main...branch` is the wrong instrument for "does this branch still matter", and it fails silently. The three-dot form compares against the merge base, so it lists everything the branch did since it forked — whether or not trunk has since acquired the same content by a squash merge, a cherry-pick, or someone doing the work again in another PR. A branch whose work landed months ago renders exactly like one holding something unique. Four branches in one day looked unmerged and were not. What settled each of them was a per-file comparison against trunk as it is now, which is what this script automates: every touched file is labelled IDENTICAL, BASE-AHEAD, BRANCH-AHEAD, DIVERGED or ONLY-ON-BRANCH. Building it changed what it says. The first version gave a binary verdict, and against all four real branches it answered "has unique content" — technically true every time, and misleading every time. So it now looks up a merged PR for the branch head (squash merging leaves neither ancestry nor identical files), grades the verdict rather than ruling, and ends with the limit stated outright: this tool compares text, not worth. A DIVERGED file usually means the branch is behind, not ahead. Read-only. Never checks out, merges, or deletes; the single network call is the PR lookup, skippable with --no-pr. Symlinked into .claude/skills so it is discoverable, and ~/.agents/skills points at this copy too — one source of truth for both agent tools. Verified: shellcheck clean, check-skills OK, mq-skills audit reports 8 skills 8 indexed 8 discoverable, full selftest suite green, and the script reproduces the two real classifications it was built from (a squash-merged branch as superseded, and a 7-of-11-identical branch as leaning superseded). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
git diff main...branchis the wrong instrument for the question "does this branch still matter", and it fails silently.The three-dot form compares against the merge base — the point where the branch forked. It lists everything the branch did since then, whether or not trunk has since acquired the same content by another route: a squash merge, a cherry-pick, someone doing the work again in a different PR. A branch whose work landed months ago produces exactly the same shape of output as one holding something unique. Same file count, same additions, same confident
+325 insertions.Four branches in one day looked unmerged and were not. What settled each was a per-file comparison against trunk as it is now.
What the script does
Labels every file the branch touched:
It prints the three-dot file count alongside, so the two measurements can be compared in one output.
Building it changed what it says
The first version gave a binary verdict. Run against all four real branches, it answered "has unique content" every time — technically true, and misleading every time, since all four were right to delete.
The classification was correct; the verdict was overconfident. So it now:
merged PR for this head: #176 merged 2026-08-08→VERDICT: superseded.review, leaning superseded — 9 of 11 file(s) are identical to main or behind it.SKILL.mdcarries three real cases where "unique content" was true and deleting was still right, so the next reader calibrates against reality rather than the label.Placement
skills/here rather than staying loose in~/.agents/skills, so it gets version history, shell lint, and the discoverability check added in #182..claude/skills/branch-supersede-checksymlinks to it, and~/.agents/skills/branch-supersede-checknow points at this copy too — one source of truth reachable by both agent tools.Read-only: never checks out, merges, resets or deletes. The single network call is the PR lookup, skippable with
--no-pr.Verification
Behaviour reproduced against the two real branches it was built from: a squash-merged one classified
superseded, and a 7-of-11-identical one classifiedreview, leaning superseded. Error paths checked too — unknown ref exits 2, no argument prints usage.🤖 Generated with Claude Code