skills/sync-branch/SKILL.md
Syncs remote default branch locally (checkout, fetch --prune, pull) and returns to the previous branch when it still exists. Reports stashes and worktrees not yet handled. Use when the user asks to sync main, update default branch, fetch/pull origin, or run /sync-branch.
npx skillsauth add pkuppens/pkuppens sync-branchInstall 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.
Update default branch (main) without leaving the user stranded. Read-only on default branch — no commits.
Not for: branch deletion (branch-cleanup-after-pr), PRs, rebase.
- [ ] Pre-flight: working tree, stashes, worktrees
- [ ] Save current branch
- [ ] Checkout default → fetch --prune → pull
- [ ] Return to saved branch (if local + origin exist)
- [ ] Post: report leftover stashes/worktrees
Dirty tree — git status --porcelain non-empty → stop; ask stash / commit / abort. Do not auto-stash.
Stashes — git stash list. If any exist:
stash@{n} + branch message).git stash pop after return (only when user wants it).Worktrees — git worktree list. If more than one entry:
OLD_BRANCH=$(git branch --show-current)
DEFAULT=$(git symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null | sed 's|^origin/||')
[ -z "$DEFAULT" ] && DEFAULT=main
git checkout "$DEFAULT"
git fetch origin --prune
git pull --ff-only origin "$DEFAULT" 2>/dev/null || git pull origin "$DEFAULT"
if [ -n "$OLD_BRANCH" ] && [ "$OLD_BRANCH" != "$DEFAULT" ]; then
if git show-ref --verify --quiet "refs/heads/$OLD_BRANCH" \
&& git show-ref --verify --quiet "refs/remotes/origin/$OLD_BRANCH"; then
git checkout "$OLD_BRANCH"
elif git show-ref --verify --quiet "refs/heads/$OLD_BRANCH"; then
echo "Staying on $DEFAULT: $OLD_BRANCH has no origin ref."
elif git show-ref --verify --quiet "refs/remotes/origin/$OLD_BRANCH"; then
echo "Staying on $DEFAULT: recreate with git checkout -b $OLD_BRANCH origin/$OLD_BRANCH"
fi
fi
Detached HEAD: skip return; report HEAD short SHA.
PowerShell: same flow; chain with ; not &&. Default branch: gh repo view --json defaultBranchRef -q .defaultBranchRef.name if symbolic-ref fails.
Re-list git stash list and git worktree list if anything was reported in pre-flight and not yet addressed. Summarize:
git config changestools
Creates, queries, updates, and links Azure Boards work items via az boards CLI. Use when filing ADO work items, running WIQL queries, or setting area path, iteration, tags, and assignee.
tools
Creates, reviews, and completes Azure Repos pull requests and branch policies via az repos CLI. Use when opening ADO PRs, setting required reviewers, or configuring build validation policies.
development
Guides Azure Pipelines YAML structure, build validation on PRs, and staged deployment with environments and approvals. Use when authoring azure-pipelines.yml or configuring CI/CD on Azure DevOps.
tools
Orchestrates Azure DevOps work item, repo, and pipeline workflows using az CLI. Use when working with Azure DevOps, Azure Repos, Azure Boards, Azure Pipelines, or az devops commands.