chore: add read-only stale/orphan branch audit script - #583
Open
essentialbit wants to merge 5 commits into
Open
Conversation
essentialbit/fredai has grown 171 non-default branches with no prior tooling to survey them. scripts/audit_stale_branches.py buckets each by relation to main via the GitHub API: active_open_pr, merged (PR merged but branch not deleted), closed_unmerged, and no-PR branches split by whether they carry commits absent from main. A live run found 122 merged-but-undeleted branches and 22 branches with real unshipped commits and no PR at all (ahead_by 1-3) -- the same class as the single `agent/claude-20260712171340` stray branch already flagged for manual user review in project memory, just never previously surveyed at scale. Read-only, no git/GitHub writes; deletion stays a human decision.
3 tasks
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.
Summary
scripts/audit_stale_branches.py, a read-only self-directed tooling script (same class aspr_merge_planner.py/reconcile_feature_backlog.py) that surveys every non-default branch on this repo and buckets it by relation tomain.eligible_backlog.py,pr_merge_planner.py, etc. shipped the same way).Buckets
active_open_pr— has an open PR, leave alonemerged_safe_to_delete— PR merged, branch never cleaned upclosed_unmerged— PR closed without merging, needs review not auto-deleteno_pr_no_unique_commits— never had a PR, no commits absent from main, safe to deleteno_pr_has_unique_commits— never had a PR AND has real unshipped commits — orphaned work, needs a human lookFindings from a live run (informational, not part of this diff)
agent/claude-20260712171340stray branch already flagged for manual review in project memory, just never previously surveyed at scaleNever deletes anything — deletion is destructive and stays a human decision.
Test plan
python3 -m py_compile scripts/audit_stale_branches.pypython3 -c "from main import *"still imports cleanly (script is standalone, touches nothing else)essentialbit/fredaiproduced the bucket counts above🤖 Generated by FredAI's hourly self-improvement sensor