Claude-skill-registry-data merge-main-cleanup
This skill should be used when the user requests merging work into main and then deleting all other local and remote branches, keeping only main.
install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry-data
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry-data "$T" && mkdir -p ~/.claude/skills && cp -r "$T/data/merge-main-cleanup" ~/.claude/skills/majiayu000-claude-skill-registry-data-merge-main-cleanup && rm -rf "$T"
manifest:
data/merge-main-cleanup/SKILL.mdsource content
Merge Main Cleanup
Overview
Perform a full merge into main and then delete all other branches locally and on the default remote. Remove any worktrees tied to deleted branches.
When to Use
- User says to merge into main and keep only main.
- User wants a one-step cleanup of branches after merge.
Workflow
1) Validate repository state
- Run
and stop if there are uncommitted changes.git status --porcelain - Run
and work from that root.git rev-parse --show-toplevel - Run
to sync branch state.git fetch --all --prune
2) Determine base branch
- Prefer
; if missing, usemain
.master - Command:
git branch --list main master
3) Merge current branch into base
- Get current branch:
.git branch --show-current - If already on base, skip merge.
- Otherwise:
git checkout <base>git pull --ff-onlygit merge <current-branch>- Resolve conflicts if any, then complete the merge.
4) Push base to remote
- Push base:
git push origin <base>
5) Remove worktrees for non-base branches
- List worktrees:
.git worktree list - For each worktree whose branch is not
, remove it:<base>git worktree remove <path>
6) Delete all non-base branches (local + remote)
- Local branches (force delete, as requested):
- List:
git branch --format='%(refname:short)' - For each branch not
, run:<base>git branch -D <branch>
- List:
- Remote branches (origin):
- List:
git branch -r --format='%(refname:short)' | rg '^origin/' - For each remote branch not
, run:origin/<base>git push origin --delete <branch>
- List:
7) Verify only base remains
should show onlygit branch -vv
.<base>
should show onlygit branch -r
.origin/<base>
Notes
- This skill is intentionally destructive: it deletes all branches except base.
- If the remote is not named
, replace it accordingly.origin - If deletion of worktree files is blocked by policy, report and ask the user to remove them manually.