clean-branches — скилл для Claude Code: чистит локальные ветки git
Скилл проходит по локальным веткам git, находит слитые и осиротевшие и удаляет их по одной, с отчётом в конце.
npx skills add dyoshikawa/rulesync --skill clean-branches -a claude-codeЧто делает clean-branches
Скилл разбит на пять шагов. Сначала он смотрит текущее состояние: git branch --show-current, список веток, git remote show origin и git branch -vv. Так он находит текущую ветку, основную и те, чей upstream уже удалён. Дальше список слитых веток берётся через git branch --merged <default-branch>.
Потом обновляются remote-ссылки: git fetch --prune, при необходимости git remote prune origin. Удаление идёт только для явно ненужных веток — слитых в основную или потерявших upstream. Текущую и основную ветку скилл не трогает, а несмёрженные удалит лишь после явного подтверждения через git branch -D. Если что-то неоднозначно, он покажет кандидатов и спросит.
Ветки удаляются по одной, без широких wildcard-команд. В финале — сводка: что удалено, что пропущено и почему, был ли prune. Ставить есть смысл, если у вас накопились десятки веток после мержей и вы устали разбирать их руками.
Какие задачи решает
- убрать локальные ветки, уже слитые в main
- подчистить ветки с удалённым upstream
- обновить remote-ссылки и выкинуть исчезнувшие ветки
- получить отчёт о том, что удалено и что пропущено
- удалять ветки по одной, а не одной широкой командой
Примеры запросов агенту
- почисти локальные ветки в этом репозитории
- убери слитые ветки и сделай prune удалённых
- покажи, какие ветки можно удалить, и спроси перед удалением
Как установить clean-branches
1Через Skills CLI (Vercel)
npx skills add dyoshikawa/rulesync --skill clean-branches -a claude-code2Вручную: положить файлы
~/.claude/skills/clean-branches/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/clean-branches/
1Через Skills CLI (Vercel)
npx skills add dyoshikawa/rulesync --skill clean-branches -a codex2Вручную: положить файлы
.agents/skills/clean-branches/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add dyoshikawa/rulesync --skill clean-branches -a cursor2Вручную: положить файлы
.cursor/skills/clean-branches/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install dyoshikawa/rulesync clean-branches2Вручную: положить файлы
.github/skills/clean-branches/SKILL.md1Через Skills CLI (Vercel)
npx skills add dyoshikawa/rulesync --skill clean-branches -a gemini-cli2Командой платформы
gemini skills install https://github.com/dyoshikawa/rulesync --path .rulesync/skills/clean-branchesВручную: положить файлы
.devin/skills/clean-branches/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add dyoshikawa/rulesync --skill clean-branches -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о clean-branches
Как установить clean-branches в Claude?
Выполните npx skills add dyoshikawa/rulesync --skill clean-branches -a claude-code. Скилл появится в ~/.claude/skills/clean-branches/SKILL.md.
Что делает clean-branches?
Находит локальные ветки, слитые в основную, и ветки с удалённым upstream, затем удаляет их по одной. Заодно делает git fetch --prune и отчитывается о результате.
Удалит ли скилл ветку с незакоммиченными изменениями?
Несмёрженные ветки он трогает только после явного подтверждения и через git branch -D. Текущую и основную ветку не удаляет никогда.
Исходный текст
SKILL.md · MIT
--- name: clean-branches description: Clean up unnecessary local branches and prune stale remote-tracking branches targets: - "*" --- # Clean Branches Clean up unnecessary local branches and prune stale remote-tracking branches. ## Step 1: Inspect Current State Run the following: - `git branch --show-current` - `git branch --format='%(refname:short)'` - `git remote show origin` - `git branch -vv` Identify: - The current branch - The default branch (for example `main` or `master`) - Branches whose upstream has been deleted After identifying the default branch, list branches already merged into it: - `git branch --merged <default-branch>` If you want to use the remote-tracking branch as the source of truth, use: - `git branch --merged origin/<default-branch>` ## Step 2: Refresh Remote State Update remote refs and prune deleted remote branches: ```bash git fetch --prune ``` If needed, also run: ```bash git remote prune origin ``` ## Step 3: Select Branches to Delete Delete only branches that are clearly unnecessary. Safe candidates include: - Local branches already merged into the default branch you identified above - Local branches whose upstream branch is gone and are no longer needed Never delete: - The current branch - The default branch - Branches that are not fully merged unless the user explicitly asks for force deletion If there is any ambiguity, show the candidate branches to the user and ask for confirmation. ## Step 4: Delete Branches For merged branches, delete them safely: ```bash git branch -d <branch-name> ``` Only if the user explicitly approves force deletion for unmerged branches, use: ```bash git branch -D <branch-name> ``` Delete branches one by one, not with a broad wildcard command. ## Step 5: Report Result Summarize: - Which branches were deleted - Which branches were skipped and why - Whether stale remote-tracking branches were pruned
© dyoshikawa · MIT · dyoshikawa/rulesync