sync
Switch to main, pull, and delete the work branch once its pull request is merged
SKILL.md.claude/skills/sync/SKILL.md
GitHubBring the tree back to an up-to-date main after a pull request has been
merged, and clean up the branch it came from. Nothing here is
destructive as long as every step looks first; a branch is deleted only
after GitHub says its pull request is merged.
Look first:
git branch --show-current-- remember it; if it is notmain, it is the branch to clean up in step 3.git status --shortshows no tracked change. A change lying in the tree would follow the switch ontomain, or block it; commit it (thepushskill) or say so and stop. The untracked scratch files this tree habitually carries are fine to leave.
Switch and pull, fast-forward only:
git switch main git pull --ff-onlymainis never edited locally here, so a pull that cannot fast-forward means something is wrong; stop and report rather than merging or rebasing. Note the rangegit pullprints (old..new) and readgit log --oneline old..new-- the report names what came down, usually the merge of the pull request just finished plus any Dependabot merges that landed meanwhile.Delete the work branch, once it is known to be merged. Ask GitHub, not
git branch --merged, since a merged pull request is the fact that matters:gh pr list --head <branch> --state merged --json number,url --jq '.[0] | "\(.number) \(.url)"'An empty answer means no merged pull request for the branch; leave it alone and say so -- it may be open, or never have had one. When there is a merged pull request:
git branch -d <branch> git push origin --delete <branch>Pull requests here are merged with a merge commit, so
-daccepts the branch; if-drefuses, the branch has commits the merge did not carry -- report that instead of reaching for-D. Check the remote side first withgit ls-remote --heads origin <branch>; GitHub may already have deleted it, which is not an error. Finish withgit fetch --pruneso the stale remote-tracking ref goes too.Only the branch the tree was on is deleted. Other local or remote branches (
feature/*, old experiments) are not this skill's business, even when their pull requests are merged, unless they are named explicitly.Report: the branch that was left, the pulled range with the merge it carries, and which of the local and remote branches were deleted.