원클릭으로
git-cleanup
Delete local branches that have been merged or whose PRs are closed/stale
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Delete local branches that have been merged or whose PRs are closed/stale
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
End-of-day — draft and post daily comments for tracked tickets missing a comment
Morning startup workflow for daily notes, yesterday summary, agenda, status comments, meeting sections, and daily branch setup. Use when invoked as `$work-start` or when the user asks to start the work day.
Track a Linear ticket or GitHub PR in today's daily note with fields and timestamped activity. Use when invoked as `$work-track` or when the user asks to track a work item.
Start work on a Linear ticket by gathering context, planning, creating a branch/worktree, implementing, testing, opening a draft PR, and updating Linear. Use when invoked as `$linear-plan` or when the user asks to start a Linear ticket.
Use for any question about a codebase, its architecture, file relationships, or project content — especially when graphify-out/ exists, where the question should be treated as a graphify query first. Turns any input (code, docs, papers, images, videos) into a persistent knowledge graph with god nodes, community detection, and query/path/explain tools.
Use for any question about a codebase, its architecture, file relationships, or project content — especially when graphify-out/ exists, where the question should be treated as a graphify query first. Turns any input (code, docs, papers, images, videos) into a persistent knowledge graph with god nodes, community detection, and query/path/explain tools.
| name | git-cleanup |
| description | Delete local branches that have been merged or whose PRs are closed/stale |
Use this skill when the user asks to run the migrated command git-cleanup or invokes $git-cleanup.
Analyze local branches, classify them by status, and offer to delete merged/stale ones.
Run git branch --show-current. If empty, stop and tell the user:
"You're in detached HEAD state. Check out a branch first."
Record the current branch name — it must never be deleted.
git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/origin/||' || git config init.defaultBranch || echo "main"
Record as <default-branch>. It must never be deleted.
git for-each-ref --format='%(refname:short)|%(committerdate:short)|%(committerdate:relative)' refs/heads/ | sort -t'|' -k2
Exclude <default-branch> and the current branch from candidates.
For each candidate branch:
Ancestor check: git merge-base --is-ancestor <branch> <default-branch> — if yes, it's merged (rebase-merged or fast-forwarded).
PR status: Query GitHub for the branch's PR state:
gh pr list --head "<branch>" --state all --json number,state,mergedAt --jq '.[0] | "\(.number)|\(.state)|\(.mergedAt // \"n/a\")"'
Place each branch into one of these categories:
| Category | Criteria |
|---|---|
| Active | Open PR, or current branch |
| Merged | PR state is MERGED, or branch is ancestor of default branch |
| Closed | PR state is CLOSED (not merged) |
| Stale | No PR found and not merged |
| Protected | Default branch or current branch — never delete |
Display a table grouped by category:
## Branch Cleanup Summary
### Active (will keep)
| Branch | Age | PR |
|--------|-----|----|
| ... | ... | .. |
### Merged (safe to delete)
| Branch | Age | PR |
|--------|-----|----|
| ... | ... | .. |
### Closed (safe to delete)
| Branch | Age | PR |
|--------|-----|----|
| ... | ... | .. |
### Stale — no PR (safe to delete)
| Branch | Age | PR |
|--------|-----|----|
| ... | ... | .. |
If there are no branches to delete, report "All branches are active or protected. Nothing to clean up." and stop.
Ask the user:
"Delete N branches (M merged, X closed, Y stale)? [yes/no/pick]"
- yes — delete all merged + closed + stale branches
- no — abort, keep everything
- pick — let user specify which categories or individual branches to delete
Before deleting branches, check for associated worktrees:
git worktree list --porcelain
For each confirmed branch, check if a worktree references it (the branch refs/heads/<branch> line in porcelain output). If so, remove the worktree first:
git worktree remove <worktree-path>
If removal fails (dirty worktree), warn the user and skip that branch — do not force-remove without explicit approval.
git branch -D <branch1> <branch2> ...
Delete in a single command for efficiency. Do NOT use -d (lowercase) since squash-merged branches won't be detected as merged by git.
List deleted branches and remaining local branches:
Deleted N branches:
- branch1
- branch2
Remaining local branches:
- main
- feature/current-work
- ...