worktree-cleanup
Remove stale worktrees and branches for merged PRs, prune remotes, and rebase the base branch. Use when the user asks to clean up worktrees, remove stale…
от Integralist★ 31 звезда на GitHub
Установить worktree-cleanup в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Clean up local Git worktrees and branches whose PRs are merged, prune
remotes, and rebase the base branch onto origin/<base>.
Always run from the repository's main checkout, not inside a worktree being removed.
Single-PR mode (--pr=<url|#number>)
- Verify the PR. Run
gh pr view <pr> --json state,headRefName,baseRefName,mergedAt,url. Ifstateis notMERGED, report it and stop without deleting work. - Check the worktree. Run
git worktree listand matchheadRefName. If found, rungit -C <path> status --short --branch; stop and ask if uncommitted or untracked files exist. If absent, continue. - Remove and prune. Run
git worktree remove <path>andgit fetch origin --prune. - Delete the local branch. Run
git branch -d <headRefName>. Fall back togit branch -D <headRefName>only after confirmingMERGEDstatus in step 1 and a clean worktree in step 2. Skip if absent locally. - Rebase the base branch. Proceed to Finish with
baseRefName.
Audit mode (default, no --pr)
- Inspect all worktrees. Run
git worktree listandgit status --short --branch. - Classify each non-main worktree. Note
prunableentries (missing directory). For each remaining worktree, checkgit -C <path> status --short --branchand, if on a branch,gh pr list --head <branch> --state all --json number,state,url. Flagprunableentries and cleanMERGEDPR worktrees as safe to remove; keep worktrees with uncommitted changes, detached HEADs without a PR, andOPEN/CLOSED-unmerged branches unless explicitly approved. - Confirm before deleting. Present the list (path, branch, PR state, clean or uncommitted) and wait for approval on which entries to remove.
- Clean up approved entries. Run
git worktree pruneifprunableentries were approved, remove approved worktrees withgit worktree remove <path>, rungit fetch origin --prune, and delete approved local branches (using-Donly for confirmedMERGEDPRs or explicitly approved branches). - Rebase the default branch. Proceed to Finish.
Finish
If the main checkout has uncommitted changes or is not on the target base
branch, ask before switching; otherwise run git rebase origin/<base> and
verify with git status --short --branch and git log -n 3 --oneline.
Report the removed worktrees, deleted branches, and updated base commit.
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
- 01
Bash(gh pr list:*) - 02
Bash(gh pr view:*) - 03
Bash(git log:*) - 04
Bash(git status:*) - 05
Bash(git worktree list:*)
FAQ
Что делает скилл worktree-cleanup?
Remove stale worktrees and branches for merged PRs, prune remotes, and rebase the base branch. Use when the user asks to clean up worktrees, remove stale branches for merged PRs, or after merging a PR from a worktree.
Как установить скилл worktree-cleanup?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл worktree-cleanup запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
AnthropicToolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
access
AnthropicManage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
configure
AnthropicSet up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
access
AnthropicManage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…