branch-cleaner
Skill1 starsChanged 6 months agoMITView on GitHub
列出可清理的本地分支(已合并 / 陈旧),供用户确认后再删。当用户说"清理分支 / 哪些分支可以删 / 列出过期分支 / 整理 git 分支 / 哪些分支可以清掉"时触发。
1 other project uses a version of this.
Adopted by
Most recently taken up by
- jMerta/codex-skillstheir own version, first seen Dec 14, 2025
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- jMerta/codex-skills★ 130same 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 repository35 other files it gives its agents.
- changelog-zhSkill
- claude-code-zhSkill
- code-haikuSkill
- commit-guard-zhSkill
- commit-roastSkill
- conflict-resolver-zhSkill
- cron-regex-buddySkill
- curl-buddySkill
- dep-auditSkill
- dockerfile-doctorSkill
- doc-syncSkill
- env-doctorSkill
- error-explain-zhSkill
- figma-to-pageSkill
- git-blame-storySkill
- gitignore-doctorSkill
- git-undoSkill
- go-migration-guardSkill
- json-yaml-doctorSkill
- lambda-logs-zhSkill
- license-pickerSkill
- mermaid-buddySkill
- mock-data-genSkill
- naming-buddySkill
- port-killerSkill
- pr-desc-zhSkill
- readme-initSkill
- skill-doctorSkill
- skill-scaffoldSkill
- slack-to-specSkill
- source-to-specSkill
- sql-explain-zhSkill
- standup-zhSkill
- test-gen-zhSkill
- tldr-thisSkill
The file
Files
branch-cleaner — 本地分支清理候选列表
扫描本地 git 分支,找出已合并进默认分支或长期无提交的"可清理"候选,展示给用户确认后再执行删除——脚本本身只读,绝不删分支。
何时触发
用户说"清理分支 / 哪些分支可以删 / 列出过期分支 / 整理 git 分支 / 哪些分支可以清掉"。
用法
1. 列出候选分支(确定性脚本)
bash <skill>/bin/list-branches.sh [额外保护分支...] [陈旧天数]
# 缺省:保护 main master + 当前分支,陈旧判定 60 天
# 例:bash <skill>/bin/list-branches.sh develop release 30输出两组:
MERGED:— 已合并进默认分支(main/master)的本地分支,带最后提交日期。STALE:— 最后提交早于 N 天的本地分支,带最后提交日期。
保护分支(绝不出现在候选列表): main / master / 当前所在分支 / 用户传入的额外保护分支。
2. Claude 展示候选并征得用户同意
- 把两组候选逐条/批量展示给用户。
- 必须明确得到用户同意后才执行删除,不能假设用户自动同意。
- 对每个候选分支说明它为何可删(已合并 / 陈旧多少天)。
3. 用户确认后执行删除
# 已合并分支(安全删):
git branch -d <分支名>
# 陈旧但未合并的分支(需强删,执行前额外确认一次):
git branch -D <分支名>MERGED组的分支用git branch -d(git 会再次验证已合并)。- 仅出现在
STALE组、未出现在MERGED组的分支属于"未合并但陈旧",强删 (-D) 前须向用户再次显式确认,说明该分支未合并进默认分支。
4. 删后确认
跑一次 git branch 让用户确认分支已消失。
硬规则
- 脚本只读:只用
git branch --merged、git for-each-ref、git branch(列表)等只读命令,绝不执行任何删除。 - 保护分支与当前分支绝不动:无论用户怎么说,
main、master、当前所在分支 永远不出现在候选列表里。 - 删前确认:
MERGED组每次删前确认;STALE未合并组须额外再次确认,并说明风险。 - 不联网、不改任何远程资源:只操作本地分支。
边界
- 只扫本地分支,不扫远程分支(remote-tracking refs)。
STALE判定基于committerdate(最后提交时间),与远程推送时间无关。- 若仓库没有
main也没有master,MERGED:组可能为空(输出会注明)。 - 不打 tag、不推送、不改配置。
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.

