agentsclimarketplace

Branch cleaner

Skill YuAICode/ai-skills/skills/branch-cleaner

列出可清理的本地分支(已合并 / 陈旧),供用户确认后再删。当用户说"清理分支 / 哪些分支可以删 / 列出过期分支 / 整理 git 分支 / 哪些分支可以清掉"时触发。From its SKILL.md

Install
npx -y skills add YuAICode/ai-skills --skill branch-cleaner

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
  • runs commandsInstructs the agent to run 4 commands, including `bash <skill>/bin/list-branches.sh` and 3 more.

SKILL.md

2.7 KB, 918 tokens by cl100k_base, as published. Nobody here has run it

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 --mergedgit for-each-refgit branch(列表)等只读命令,绝不执行任何删除。
  • 保护分支与当前分支绝不动:无论用户怎么说,mainmaster、当前所在分支 永远不出现在候选列表里。
  • 删前确认:MERGED 组每次删前确认;STALE 未合并组须额外再次确认,并说明风险。
  • 不联网、不改任何远程资源:只操作本地分支。

边界

  • 只扫本地分支,不扫远程分支(remote-tracking refs)。
  • STALE 判定基于 committerdate(最后提交时间),与远程推送时间无关。
  • 若仓库没有 main 也没有 master,MERGED: 组可能为空(输出会注明)。
  • 不打 tag、不推送、不改配置。

What ships with it: 3 files

10.1 KB alongside SKILL.md, 2 of them executable

bin/

tests/

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.