clean-branches
Delete local branches whose remote has been deleted ([gone]), including their worktrees. Use for branch cleanup after merging PRs.
Best use case
clean-branches is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Delete local branches whose remote has been deleted ([gone]), including their worktrees. Use for branch cleanup after merging PRs.
Teams using clean-branches should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/clean-branches/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How clean-branches Compares
| Feature / Agent | clean-branches | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Delete local branches whose remote has been deleted ([gone]), including their worktrees. Use for branch cleanup after merging PRs.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# 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:**
```bash
git fetch --prune
```
2. **List branches to identify [gone] status:**
```bash
git branch -v
```
Branches with a `+` prefix have associated worktrees that must be removed before deletion.
3. **List worktrees for reference:**
```bash
git worktree list
```
4. **Remove worktrees and delete [gone] branches:**
```bash
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.Related Skills
verify
Run format, typecheck, test, and lint across the monorepo. Use after implementing changes.
tdd
Implement changes using Test-Driven Development (Red-Green-Refactor). Use for bug fixes, new features, or any code change that should have test coverage.
spec
Write a feature spec — the "what & why" of a kandev product feature, before coding. Use when the user says "let's spec X" or starts a new product feature.
simplify
Simplify recently changed code — inline one-off abstractions, remove speculative code, reduce nesting, replace cleverness with clarity. Run after implementing a feature.
record
Record an architectural decision (ADR) or save an implementation plan. Use after making significant design choices or completing features.
qa
Verify a feature works after implementation. Actively try to break it — edge cases, error paths, integration wiring, and real usage flows.
push
Commit and push to the current branch. Use --fixup to also wait for CI/CodeRabbit and fix issues.
pr
Commit, push, and create a PR. Default is ready-for-review with auto-fixup. Use --draft to skip review/fixup.
pr-fixup
Wait for CI checks and automated reviews (CodeRabbit, Greptile, Claude) on a PR, fix failures and address comments, then push.
playwright-cli
Automate browser interactions, test web pages and work with Playwright tests.
fix
Fix bugs and issues — reproduce, find root cause, minimal fix with regression test. Use when something is broken.
feature
Guided feature development — brainstorm, explore codebase, design architecture, implement with TDD, and review. Use for new features or significant changes.