Brings diverged remote branches up to date with develop — classifies, rescues unique work, then resets or deletes stale branches
67
80%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./.claude/skills/sync-stale-branches/SKILL.mdBring old/diverged remote branches up to date with develop.
Run this periodically to keep the branch list clean and PR-able.
EXCLUDE — branches to leave untouched (space-separated, no origin/ prefix)develop mastergit fetch --prune
# All remote branches minus the exclude list
git branch -r | grep -v 'origin/HEAD' \
| sed 's|remotes/||' \
| grep -v -E '^origin/(develop|master)$'Add any other branches to exclude to the grep pattern.
For every candidate origin/<branch>:
A — unique file count (three-dot diff from merge-base):
git diff --name-only origin/develop...origin/<branch> | wc -lB — files ONLY in the branch (not in develop):
git diff --name-only --diff-filter=A origin/develop origin/<branch>Classify as:
These branches were never extended beyond the old fork point.
git push origin --delete <branch>All unique files are already captured in a feature branch we are keeping. Reset the branch to develop HEAD so it is current but carries no stale code.
git push origin origin/develop:refs/heads/<branch> --forceRescue uncovered files before resetting.
Group uncovered files by module/domain:
Modules/Foo/… → belongs to whatever feature owns FooOn the target feature branch (must already exist and be ahead of develop):
git checkout origin/<stale-branch> -- <uncovered-file1> <uncovered-file2> ...
git add <files>
git commit -m "chore: rescue <description> from stale <stale-branch>"
git push origin HEAD --force-with-leaseIf the target feature branch does not yet exist, use the feature-branch-extraction procedure to create it properly on top of develop HEAD first.
git push origin origin/develop:refs/heads/<branch> --force# Confirm each branch is now equal to develop
for branch in <cleaned-branches>; do
ahead=$(git rev-list origin/develop..origin/$branch --count)
behind=$(git rev-list origin/$branch..origin/develop --count)
echo "$branch → ahead=$ahead behind=$behind"
doneExpected: all cleaned branches show ahead=0 behind=0.
copilot/*) are AI-generated; resetting them is safe —--diff-filter=A flag catches files the branch adds that develop lacks.git fetch --prune first so local remote-tracking refs are current.fb83b36
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.