plugins/coordinator.bak/skills/consolidate-git/SKILL.md
Use when the repo has multiple stale branches that need cleaning up — inventories all branches, absorbs unique commits into the current branch, deletes stale branches, and merges to main. This skill should be used when the user asks to "clean up branches", "consolidate branches", "consolidate git", "merge all branches", or mentions stale/old branches that need cleanup.
npx skillsauth add oduffy-delphi/coordinator-claude consolidate-gitInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Reduce branch sprawl to a single clean main. Inventories all local and remote branches, absorbs any unique commits into the current branch, deletes stale branches, then merges to main via /merge-to-main.
Announce at start: "I'm using the coordinator:consolidate-git skill to consolidate all branches and merge to main."
List all local and remote branches, determine ownership, and categorize.
1a. Identify the current user:
MY_EMAIL=$(git config user.email)
1b. List all branches with tip author:
git branch -a
For each branch (excluding main and the current branch), check the author of the most recent commit on the tip:
# Local branch:
git log -1 --format='%ae' <branch>
# Remote-only branch:
git log -1 --format='%ae' origin/<branch>
1c. Categorize each branch:
| Category | Definition | Action |
|----------|-----------|--------|
| current | The checked-out branch | Absorb target — everything merges here |
| main | The trunk branch | Merge target — current branch merges here at the end |
| mine (stale) | Tip author matches $MY_EMAIL | Check for unique commits, absorb if any, then delete |
| other's | Tip author does NOT match $MY_EMAIL | Leave untouched |
1d. Present the inventory to the PM as a table:
| Branch | Local | Remote | Owner | Category |
|--------|-------|--------|-------|----------|
| main | yes | yes | — | trunk |
| work/striker/2026-03-20 | yes | yes | me | mine (stale) |
| feature/foo | no | yes | me | mine (stale) |
| feature/bar | no | yes | [email protected] | other's — skipped |
| work/striker/2026-03-23 | yes (current) | yes | me | current |
Only branches categorized as "mine (stale)" proceed to Steps 2–4. Other people's branches are reported but never touched.
For each stale branch, check if it has commits not in the current branch:
# For local branches:
git log --oneline <current-branch>..<stale-branch>
# For remote-only branches:
git log --oneline <current-branch>..origin/<stale-branch>
Categorize the result:
For each stale branch with unique commits:
git show --stat <commit> to understand what changedgit cherry-pick <commit> --no-editgit merge <stale-branch> --no-editgit cherry-pick --abort or git merge --abort) and skip — note this in the reportReport each absorption decision to the PM:
"Branch
work/striker/2026-03-20has 2 unique commits — both are experiment data snapshots already superseded by current branch. Skipping."
or:
"Branch
feature/auth-rewritehas 5 unique commits with real code changes. Cherry-picking into current branch."
After all unique commits are absorbed (or explicitly skipped), delete stale branches:
# Local branches — use safe delete (-d), not force delete (-D)
git branch -d <branch>
# Remote branches — batch deletions into one push
git push origin --delete <branch1> <branch2> <branch3>
Use -d (safe delete), not -D. Safe delete will refuse if the branch has unmerged commits — this is a final safety net. If -d refuses, investigate before escalating to -D with PM approval.
After deletion, prune stale remote tracking refs:
git fetch --prune
Invoke /merge-to-main to create a PR, wait for CI, merge, and clean up.
If the current branch IS main (because all work was already absorbed and we're cleaning remotes only), skip this step.
## Branch Consolidation Complete
### Absorbed
- `work/striker/2026-03-20` — no unique commits (already merged)
- `feature/foo` — 3 commits cherry-picked into current branch
### Skipped (superseded)
- `work/striker/2026-03-19` — 1 commit (stale experiment data, current branch has newer version)
### Deleted
- Local: work/striker/2026-03-20, work/striker/2026-03-19
- Remote: origin/work/striker/2026-03-20, origin/work/striker/2026-03-19, origin/feature/foo
### Left Untouched (other owners)
- `feature/bar` ([email protected]) — not ours, skipped
### Merged to Main
- PR: {url}
- Now on: main @ {sha}
- All of *our* branches cleaned — only main + other owners' branches remain
If on main with no other branches: Abort early — nothing to consolidate.
If the current branch is behind main: Merge main into the current branch first before absorbing other branches — ensures the final state includes everything.
If a stale branch has diverged significantly: Prefer merge over cherry-pick. If the merge has extensive conflicts, flag to the PM rather than resolving silently — the PM may want to inspect before committing.
If remote branches have no local counterpart: Fetch them first (git fetch origin <branch>) to inspect their commits, then delete the remote after inspection.
-d (safe) by default. -D only with explicit PM approval.git config user.email are candidates. Everyone else's branches are reported but never modified or deleted.tools
Orient session — preflight, load context, choose work
documentation
Wrap up finished work — capture lessons, update docs
development
Triangulate plan-claim / code-reality / review oracles to classify each plan into DELIVERED+REVIEWED / DELIVERED-UNREVIEWED / PARTIAL / IN-FLIGHT / ABANDONED. Run after any crash or 'did we actually finish what we think we finished?' moment.
testing
Check for a published coordinator update and advise a preserve-by-default migration path — never a blind overwrite.