Skip to content

chore: add read-only stale/orphan branch audit script - #583

Open
essentialbit wants to merge 5 commits into
mainfrom
chore/audit-stale-branches-20260817
Open

chore: add read-only stale/orphan branch audit script#583
essentialbit wants to merge 5 commits into
mainfrom
chore/audit-stale-branches-20260817

Conversation

@essentialbit

Copy link
Copy Markdown
Owner

Summary

  • Adds scripts/audit_stale_branches.py, a read-only self-directed tooling script (same class as pr_merge_planner.py/reconcile_feature_backlog.py) that surveys every non-default branch on this repo and buckets it by relation to main.
  • No consensus/debate-cycle needed for this class of self-directed tooling PR (established precedent — eligible_backlog.py, pr_merge_planner.py, etc. shipped the same way).

Buckets

  • active_open_pr — has an open PR, leave alone
  • merged_safe_to_delete — PR merged, branch never cleaned up
  • closed_unmerged — PR closed without merging, needs review not auto-delete
  • no_pr_no_unique_commits — never had a PR, no commits absent from main, safe to delete
  • no_pr_has_unique_commits — never had a PR AND has real unshipped commits — orphaned work, needs a human look

Findings from a live run (informational, not part of this diff)

  • 171 non-default branches total
  • 122 merged-but-undeleted branches
  • 22 branches with unshipped commits and no PR at all — same class as the single agent/claude-20260712171340 stray branch already flagged for manual review in project memory, just never previously surveyed at scale

Never deletes anything — deletion is destructive and stays a human decision.

Test plan

  • python3 -m py_compile scripts/audit_stale_branches.py
  • python3 -c "from main import *" still imports cleanly (script is standalone, touches nothing else)
  • Live run against essentialbit/fredai produced the bucket counts above

🤖 Generated by FredAI's hourly self-improvement sensor

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant