Agent Skillskdlbs/kandev › clean-branches

clean-branches

GitHub

清理本地已合并或远程删除的 Git 分支,包括关联的工作树。通过 fetch --prune 同步状态,识别并移除 [gone] 标记的分支及其 worktree,保持仓库整洁。

.agents/skills/clean-branches/SKILL.md kdlbs/kandev

Trigger Scenarios

PR 合并后需要清理本地分支 远程分支已删除但本地仍残留 需要批量删除标记为 [gone] 的分支

Install

npx skills add kdlbs/kandev --skill clean-branches -g -y
More Options

Non-standard path

npx skills add https://github.com/kdlbs/kandev/tree/main/.agents/skills/clean-branches -g -y

Use without installing

npx skills use kdlbs/kandev@clean-branches

指定 Agent (Claude Code)

npx skills add kdlbs/kandev --skill clean-branches -a claude-code -g -y

安装 repo 全部 skill

npx skills add kdlbs/kandev --all -g -y

预览 repo 内 skill

npx skills add kdlbs/kandev --list

SKILL.md

Frontmatter
{
    "name": "clean-branches",
    "description": "Delete local branches whose remote has been deleted ([gone]), including their worktrees. Use for branch cleanup after merging PRs."
}

Clean Branches

Remove local branches that have been deleted on the remote (marked [gone]), including any associated git worktrees.

Steps

  1. Fetch and prune remote refs:

    git fetch --prune
    
  2. List branches to identify [gone] status:

    git branch -v
    

    Branches with a + prefix have associated worktrees that must be removed before deletion.

  3. List worktrees for reference:

    git worktree list
    
  4. Remove worktrees and delete [gone] branches:

    git branch -v | grep '\[gone\]' | sed 's/^[+* ]//' | awk '{print $1}' | while read branch; do
      echo "Processing branch: $branch"
      worktree=$(git worktree list | grep "\\[$branch\\]" | awk '{print $1}')
      if [ ! -z "$worktree" ] && [ "$worktree" != "$(git rev-parse --show-toplevel)" ]; then
        echo "  Removing worktree: $worktree"
        git worktree remove --force "$worktree"
      fi
      echo "  Deleting branch: $branch"
      git branch -D "$branch"
    done
    
  5. Report which branches and worktrees were removed. If none were [gone], say no cleanup was needed.

Version History

  • b4239d8 Current 2026-07-24 17:31

Same Skill Collection

.agents/skills/acp-debug/SKILL.md
.agents/skills/add-integration/SKILL.md
.agents/skills/code-review/SKILL.md
.agents/skills/commit/SKILL.md
.agents/skills/context-engineering/SKILL.md
.agents/skills/create-kandev-plugin/SKILL.md
.agents/skills/debug/SKILL.md
.agents/skills/docs-maintainer/SKILL.md
.agents/skills/e2e/SKILL.md
.agents/skills/fix/SKILL.md
.agents/skills/harness-improvement/SKILL.md
.agents/skills/interview-me/SKILL.md
.agents/skills/plan/SKILL.md
.agents/skills/planner-orchestration/SKILL.md
.agents/skills/playwright-cli/SKILL.md
.agents/skills/pr-fixup/SKILL.md
.agents/skills/pr/SKILL.md
.agents/skills/product-demo-seeding/SKILL.md
.agents/skills/product-video-capture/SKILL.md
.agents/skills/push/SKILL.md
.agents/skills/qa/SKILL.md
.agents/skills/release/SKILL.md
.agents/skills/runtime-feature-flags/SKILL.md
.agents/skills/simplify/SKILL.md
.agents/skills/spec-driven-development/SKILL.md
.agents/skills/spec/SKILL.md
.agents/skills/tdd/SKILL.md
.agents/skills/using-agent-skills/SKILL.md
.agents/skills/verify/SKILL.md
.agents/skills/mobile-parity/SKILL.md
.agents/skills/record/SKILL.md

Metadata

Files
0
Version
1578843
Hash
0af69512
Indexed
2026-07-24 17:31

inicio - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-16 21:36
浙ICP备14020137号-1 $mapa de visitantes$