跳到正文
cccskills
免费在 GitHub 公开

clean-gone-branches

Delete local git branches whose remotes are gone, after verifying via gh CLI that each was actually merged.

中文简介正在准备中。当前显示原文说明。

集成工具GitHub
查看安装方法

包含的文件(1)

  • SKILL.md2.5 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

What I do

Clean up orphaned local branches (those whose remote tracking branch is [gone]) by:

  1. Running git fetch --prune to sync remote state.
  2. Listing all local branches with [gone] remote tracking refs.
  3. Verifying each branch's PR status via gh pr list --state all to confirm it was merged (or closed).
  4. Showing the user a summary table with PR state and merge date.
  5. Asking for confirmation before deleting.
  6. Force-deleting confirmed branches with git branch -D.

When to use me

  • After a sprint or a batch of PRs land and you want to clean up stale local branches.
  • Any time git branch -vv shows several [gone] entries.
  • Before switching repos or doing a clean checkout.

Workflow

Step 1: Fetch and prune

git fetch --prune

Step 2: Find orphaned branches

git branch -vv | grep ': gone]'

If nothing found, report "No orphaned branches found." and stop.

Step 3: Verify PR status via gh CLI

For each orphaned branch, run:

gh pr list --head "<branch>" --state all --json state,mergedAt,title \
  --jq '.[0] | "\(.state) | merged: \(.mergedAt // "N/A") | \(.title)"'

Build a summary table:

BranchPR StateMerged AtPR Title

Flag any branches that are not MERGED (e.g. OPEN or CLOSED without merge) — these need user attention before deletion.

Step 4: Confirm with user

Show the table and ask:

  • "Delete all MERGED branches now?"

If any branch has no PR or is not merged, exclude it from the default delete list and call it out explicitly:

  • "These branches have no merged PR — skip them or confirm to force-delete anyway?"

Step 5: Delete

git branch -D <branch1> <branch2> ...

Report each deleted branch with its last commit hash.


Behavior rules

  • Never delete without explicit user confirmation.
  • Always use git branch -D (force) since git's merge check is against the local default branch, not the remote — remote deletion already confirms the work is done.
  • If gh is not available or returns no results, warn the user and do not auto-delete.
  • Prefer deleting all confirmed-merged branches in one command rather than one-by-one.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Implement comprehensive error handling for Python code paths to keep services resilient and user-friendly. Use when failures are currently silent or exceptions leak through.

中文简介正在准备中。当前显示原文说明。

Unique-AG/ai52026年10月19日 更新

Tabular and numerical data analysis with descriptive statistics and insights. Use when the user provides data, tables, CSVs, or numbers and wants analysis.

中文简介正在准备中。当前显示原文说明。

Unique-AG/ai52026年10月19日 更新

Financial factsheet analysis with key metrics extraction and investment rationale

中文简介正在准备中。当前显示原文说明。

Unique-AG/ai52026年10月19日 更新

ci-fix

免费

Diagnose and fix CI failures without leaving your editor.

中文简介正在准备中。当前显示原文说明。

Unique-AG/ai52026年10月19日 更新

Reproduce ai-repo PR checks locally with Poe and CI scripts, including per-package typecheck and coverage behavior. Use when validating changes before push or when user asks which local commands match CI.

中文简介正在准备中。当前显示原文说明。

Unique-AG/ai52026年10月19日 更新

Ask clarifying questions before implementing to ensure Python requirements are understood. Use when a task lacks detail, dependencies are unclear, or multiple interpretations are possible.

中文简介正在准备中。当前显示原文说明。

Unique-AG/ai52026年10月19日 更新

查看 Unique-AG 的全部技能

报告此技能的问题