branch-cleanup
Skill9 starsChanged 3 months agoMITView on GitHub
Delete remote and local branches that have been merged into master. Run after every merge to keep the repo to master-only. Supports both git-push deletion and GitHub API deletion (when git push --delete returns 403 due to proxy restrictions).
- Commits and pushes
7 other projects use a version of this.
Adopted by
Most recently taken up by
- gspencergoog/skillstheir own version, first seen Sep 8, 2026
- imMamdouhaboammar/mergefytheir own version, first seen Sep 2, 2026
- stealth-factory/skillstheir own version, first seen Aug 22, 2026
- lwhsu/freebsd-claude-skillstheir own version, first seen Aug 5, 2026
- DScardini91/agentic-ostheir own version, first seen Jun 26, 2026
- astamvalley/claude-foundationtheir own version, first seen Apr 3, 2026
Other versions7 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 7
- fxstein/ai-todo★ 16same name
- stealth-factory/skills★ 4same name
- astamvalley/claude-foundation★ 2same name
- DScardini91/agentic-os★ 2same name
- gspencergoog/skills★ 2same name
- lwhsu/freebsd-claude-skills★ 2same name
- imMamdouhaboammar/mergefy★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository109 other files it gives its agents.
- AGENTS.mdAGENTS.md
- docs/agents.mdAGENTS.md
- agent/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- router/CLAUDE.mdCLAUDE.md
- .agents/skills/llms.txtllms.txt
- agent-harnessSkill
- auto-fixSkill
- brain-dumpSkill
- industrial-brutalist-uiSkill
- changelog-enforcerSkill
- checkpoint-strategySkill
- context-primeSkill
- cooldown-resumeSkill
- council-reviewSkill
- data-quality-auditSkill
- debug-tracerSkill
- dependency-auditSkill
- deslopSkill
- docs-syncSkill
- duplicate-threadSkill
- email-triageSkill
- fabric-patternsSkill
- feature-flagSkill
- git-hygieneSkill
- graphifySkill
- implementation-plannerSkill
- insightsSkill
- issue-resolverSkill
- learn-ruleSkill
- local-ai-querySkill
- lr-schedule-advisorSkill
- minimalist-uiSkill
- modularity-reviewSkill
- full-output-enforcementSkill
- parallel-agentsSkill
- parallel-worktreesSkill
- prompt-librarySkill
- prompt-transparencySkill
- pro-workflowSkill
- redesign-existing-projectsSkill
- release-readinessSkill
- replay-learningsSkill
- repo-memory-updaterSkill
- repowise-intelligenceSkill
- researchSkill
- resource-panelSkill
- risky-module-reviewSkill
- sandboxed-execSkill
- scope-guardSkill
- self-improveSkill
- session-handoffSkill
- skill-composerSkill
- smart-commitSkill
- high-end-visual-designSkill
- stitch-design-tasteSkill
- system-prompt-auditSkill
- task-alive-updatesSkill
- task-scoperSkill
- design-taste-frontendSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
7 rules. 0 are common, 6 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 6 edited versions we read keep these.
6
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 26
After merging any feature/fix branch into master
- Distinctive: line 27
After a release, when multiple branches have been absorbed
- Very specific: line 43
Make sure you are on master and Your branch is up to date with 'origin/master'.
- Distinctive: line 44
If not, push first before touching branches.
- Distinctive: line 74
Run tests before committing the merge:
- Distinctive: line 153
If a GitHub PAT was shared or pasted in plaintext during this session:
- Distinctive: line 155
Never commit a PAT to the repository.
“Common” is measured: kept by at least 6 in 10 of the 6 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Skill: branch-cleanup
When to Use
Run this skill:
- After merging any feature/fix branch into master
- After a release, when multiple branches have been absorbed
- Any time
git branch -ashows branches beyondmasterandgh-pages
Protected branches — never delete:
mastergh-pages(GitHub Pages deployment)
Step 1 — Confirm master is up to date
git fetch origin
git statusMake sure you are on master and Your branch is up to date with 'origin/master'.
If not, push first before touching branches.
Step 2 — List all remote branches
git branch -r | grep -v 'origin/master\|origin/gh-pages\|origin/HEAD'For each branch listed, check whether it is fully merged:
git log origin/master..origin/<branch-name> --oneline- Empty output → fully merged, safe to delete.
- Commits listed → unmerged work; merge it into master first (see Step 3), then return here.
Step 3 — Merge any unmerged branches (if needed)
For each branch with unmerged commits:
git merge --no-ff origin/<branch-name> -m "Merge branch '<branch-name>'"Resolve any conflicts (keep HEAD for code files; merge both sides for docs/changelog.md).
Run tests before committing the merge:
pytest -x -qThen push:
git push origin masterStep 4 — Delete merged branches
Option A — git push (standard)
git push origin --delete <branch-name>Repeat for every merged branch. If this returns 204 or succeeds, you are done.
Option B — GitHub API (use when git push --delete returns 403)
This happens when the git remote is proxied and lacks delete-refs permission.
Requires a GitHub PAT with repo scope (or delete_head_branch permission).
curl -s -o /dev/null -w "%{http_code}" -X DELETE \
-H "Authorization: token <GITHUB_PAT>" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/<owner>/<repo>/git/refs/heads/<branch-name>"Expected response: 204 (success). Any other code means failure — check PAT permissions.
To delete all merged branches in one pass:
REPO="<owner>/<repo>"
PAT="<GITHUB_PAT>"
for branch in <branch1> <branch2> <branch3>; do
status=$(curl -s -o /dev/null -w "%{http_code}" -X DELETE \
-H "Authorization: token $PAT" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/$REPO/git/refs/heads/$branch")
[ "$status" = "204" ] && echo "✓ deleted $branch" || echo "✗ failed $branch (HTTP $status)"
doneOption C — Delete local tracking refs after remote deletion
git fetch --prune
git branch -d <branch-name> # safe delete (refuses if unmerged)Step 5 — Verify
git fetch --prune
git branch -aExpected output contains only:
* master
remotes/origin/master
remotes/origin/gh-pagesStep 6 — Security note on PATs
If a GitHub PAT was shared or pasted in plaintext during this session: Revoke and regenerate it immediately at https://github.com/settings/tokens. Never commit a PAT to the repository.
Automation — post-merge hook (optional)
To trigger this automatically after every successful push to master, add to
.claude/hooks/post-push.sh (create if it doesn't exist):
#!/usr/bin/env bash
# After pushing master, delete the branch we just merged from (if set).
if [ -n "$MERGED_BRANCH" ]; then
git push origin --delete "$MERGED_BRANCH" 2>/dev/null || \
curl -s -X DELETE \
-H "Authorization: token $GITHUB_PAT" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/$GITHUB_REPO/git/refs/heads/$MERGED_BRANCH"
fiSet MERGED_BRANCH before pushing:
MERGED_BRANCH=claude/my-feature git push origin masterAcceptance Checks
git branch -ashows onlymasterandgh-pageson remote- All merged branches confirmed empty (
git log origin/master..origin/<b>returns nothing) - Any PAT used in plaintext has been revoked and regenerated
pytest -x -qstill green after all merges
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

