escapeboy/claude-code-kit/git-sync-branches
Claude Code and agent skill by escapeboy/claude-code-kit
- community
Checking that the SKILL.md file is still in the repository.
Merges finished feature branches into develop, syncs master/main with develop, commits any uncommitted changes, and deletes the merged feature branches plus those triaged as Close (local and remote); unmerged work it did not close is kept and reported. Handles git submodules automatically. Use when you want to clean up branches and leave only develop and master/main in sync.
Install
npx vskill@latest install escapeboy/claude-code-kit/git-sync-branchesSKILL.md
git-sync-branches
Commit everything, merge finished feature branches into develop, sync master/main, delete merged and Close branches. Handles submodules.
When to Use (and When NOT to)
| Use this skill for | Use a simpler approach for | |
|---|---|---|
| Cleaning up multiple stale feature branches across a repo (and submodules) into develop/master | Merging a single branch you're actively working on — just git merge <branch> | |
| Bulk local + remote branch deletion after a sprint/release | Deleting one branch you already know is safe — git branch -d <branch> | |
| Repos with git submodules needing coordinated branch sync | Single-repo, no-submodule projects — plain git merge + git push | |
| Restoring master/develop to a known-clean, in-sync state | Reviewing a PR before merge — use the code-review skill instead |
Workflow
Step 1: Commit uncommitted changes
If there are untracked files or modifications, commit them:
Step 2: Identify the main branch name
- Check for
mastervsmain— use whichever exists - Check for
develop— this is the integration branch
Step 3: Process submodules (if any)
For each git submodule, run the full sync workflow inside the submodule first:
For each submodule that has feature branches:
cd <submodule-path>- Run Steps 1–12 of this workflow inside the submodule (its own
develop→main, deletions and push) cd ..back to parent
Step 4: Find all feature branches ahead of develop
For each feature branch, check how many commits it's ahead of develop:
Only merge branches that are actually ahead (non-zero).
Step 4b: Triage each branch — merge, hold, or close (don't blanket-merge)
Before merging, classify every feature branch and state the recommendation with a reason. Blanket "merge everything ahead" buries dead experiments and stale spikes into develop.
For each branch ahead of develop:
Recommend one of:
- Merge — real, finished, in-scope work. Proceed to Step 6.
- Hold — useful but not ready: unfinished, or it conflicts in a way you cannot resolve with confidence. Do not merge and do not delete it; report it so its author can finish it. Drift behind develop alone is not a reason to hold — a
--no-ffmerge handles it. Never rebase a branch here: rewriting a pushed branch would need a force-push. - Close — stale spike, superseded, or abandoned (old last-commit + no unique value vs develop). Recommend deleting WITHOUT merging; in Step 9/11 delete it but do NOT fold its commits into develop.
Print the verdict list (one line per branch: branch — verdict — reason) and proceed. Only Merge branches flow into Steps 5–7; Close branches skip straight to deletion; Hold branches are left as they are.
Step 5: Switch to develop and pull
Step 6: Merge each feature branch
For each branch marked Merge in Step 4b:
Submodule conflict resolution: If a merge fails with add_cacheinfo failed to refresh for path '<submodule>':
- Abort:
git merge --abort - First commit the current submodule pointer:
git add <submodule> && git commit -m "chore: update submodule pointer" - Retry the merge
Other conflicts: list the conflicted files and resolve each one:
Stage only those files by name (git add <file> ...) and git commit — never git add ., which would also sweep in unrelated files. If a conflict cannot be resolved with confidence, git merge --abort and re-mark the branch Hold.
Step 7: Update submodule pointer (if submodules exist)
After submodule sync, update the parent's pointer to the latest submodule commit:
Step 8: Merge develop into master/main
Step 9: Delete local feature branches — merged ones and Close verdicts
Any feat/ branch still left is unmerged and was not marked Close — a Hold branch, or a merge that was aborted. Keep it and list it in the Step 12 report.
Step 10: Push develop and master/main
Step 11: Delete remote feature branches
If you get "remote ref does not exist" errors, the branches are already gone — prune stale refs:
Step 12: Final verification
Both master/main and develop should point to the same commit (or master should be ≥ develop).
Report any feat/ branch that is still there (local or remote) with the reason it was kept.
Boundaries
Always
- Merge feature branches into
developfirst, never directly intomaster/main - Sync submodules before updating the parent's pointer
- Delete only branches that are merged into
developor marked Close in Step 4b. Close branches are deleted unmerged by design; every other unmerged branch is kept and reported
Ask first
- Nothing beyond the invocation itself — branch deletion, remote deletion, and pushes are exactly this skill's stated purpose
Never
- Delete an unmerged branch that was not marked Close
- Rebase or otherwise rewrite a feature branch
git add .while resolving conflicts — stage the resolved files by name- Force-push
- Delete
develop,main, ormaster
Example: parent repo + submodule layout
Parent repo branches: master (prod) + develop (default work branch) Submodule (base/) branches: main (prod) + develop
Order of operations:
- Sync
base/submodule: merge features →develop→main - Return to parent: commit updated
basepointer - Merge parent feature branches →
develop - Merge
develop→master - Delete merged and Close
feat/*branches in both repos; report any Hold branch
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking03-custom-skills/examples/git-sync-branches/SKILL.md
Popularity
- Repository stars
- 92
- Repository forks
- 14
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/escapeboy/claude-code-kit/git-sync-branches)