branch-cleanup — community branch-cleanup, ai-todo, community, ide skills

v1.0.0

About this Skill

Perfect for Coding Agents needing automated branch management and cleanup capabilities. Clean up local branches after PR merges. Syncs main with origin, identifies branches with merged PRs, and proposes safe deletion. Use when the user asks to clean up branches, delete merged branches, s

fxstein fxstein
[0]
[0]
Updated: 3/12/2026

Killer-Skills Review

Decision support comes first. Repository text comes second.

Reviewed Landing Page Review Score: 9/11

Killer-Skills keeps this page indexable because it adds recommendation, limitations, and review signals beyond the upstream repository text.

Original recommendation layer Concrete use-case guidance Explicit limitations and caution Quality floor passed for review Locale and body language aligned
Review Score
9/11
Quality Score
57
Canonical Locale
en
Detected Body Locale
en

Perfect for Coding Agents needing automated branch management and cleanup capabilities. Clean up local branches after PR merges. Syncs main with origin, identifies branches with merged PRs, and proposes safe deletion. Use when the user asks to clean up branches, delete merged branches, s

Core Value

Empowers agents to automate branch cleanup using Git, providing persistent TODO tracking and version control, and supporting protocols like git fetch and git pull, while integrating with libraries like OpenClaw, Cursor, and Claude.

Ideal Agent Persona

Perfect for Coding Agents needing automated branch management and cleanup capabilities.

Capabilities Granted for branch-cleanup

Automating branch cleanup for merged PRs
Syncing main branches with origin using git pull
Debugging branch conflicts with pre-flight checks

! Prerequisites & Limits

  • Requires Git installation and configuration
  • Limited to Git-based version control systems
  • Needs user input for branch switching

Source Boundary

The section below is imported from the upstream repository and should be treated as secondary evidence. Use the Killer-Skills review above as the primary layer for fit, risk, and installation decisions.

After The Review

Decide The Next Action Before You Keep Reading Repository Material

Killer-Skills should not stop at opening repository instructions. It should help you decide whether to install this skill, when to cross-check against trusted collections, and when to move into workflow rollout.

Labs Demo

Browser Sandbox Environment

⚡️ Ready to unleash?

Experience this Agent in a zero-setup browser environment powered by WebContainers. No installation required.

Boot Container Sandbox

FAQ & Installation Steps

These questions and steps mirror the structured data on this page for better search understanding.

? Frequently Asked Questions

What is branch-cleanup?

Perfect for Coding Agents needing automated branch management and cleanup capabilities. Clean up local branches after PR merges. Syncs main with origin, identifies branches with merged PRs, and proposes safe deletion. Use when the user asks to clean up branches, delete merged branches, s

How do I install branch-cleanup?

Run the command: npx killer-skills add fxstein/ai-todo/branch-cleanup. It works with Cursor, Windsurf, VS Code, Claude Code, and 19+ other IDEs.

What are the use cases for branch-cleanup?

Key use cases include: Automating branch cleanup for merged PRs, Syncing main branches with origin using git pull, Debugging branch conflicts with pre-flight checks.

Which IDEs are compatible with branch-cleanup?

This skill is compatible with Cursor, Windsurf, VS Code, Trae, Claude Code, OpenClaw, Aider, Codex, OpenCode, Goose, Cline, Roo Code, Kiro, Augment Code, Continue, GitHub Copilot, Sourcegraph Cody, and Amazon Q Developer. Use the Killer-Skills CLI for universal one-command installation.

Are there any limitations for branch-cleanup?

Requires Git installation and configuration. Limited to Git-based version control systems. Needs user input for branch switching.

How To Install

  1. 1. Open your terminal

    Open the terminal or command line in your project directory.

  2. 2. Run the install command

    Run: npx killer-skills add fxstein/ai-todo/branch-cleanup. The CLI will automatically detect your IDE or AI agent and configure the skill.

  3. 3. Start using the skill

    The skill is now active. Your AI agent can use branch-cleanup immediately in the current project.

Upstream Repository Material

The section below is imported from the upstream repository and should be treated as secondary evidence. Use the Killer-Skills review above as the primary layer for fit, risk, and installation decisions.

Upstream Source

branch-cleanup

Install branch-cleanup, an AI agent skill for AI agent workflows and automation. Review the use cases, limitations, and setup path before rollout.

SKILL.md
Readonly
Upstream Repository Material
The section below is imported from the upstream repository and should be treated as secondary evidence. Use the Killer-Skills review above as the primary layer for fit, risk, and installation decisions.
Supporting Evidence

Branch Cleanup

Automated workflow to sync main with origin and clean up local branches that have merged PRs.

Quick Start

When user asks to "clean up branches" or "delete merged branches":

  1. Pre-flight checks:

    • git fetch origin (update remote refs)
    • git branch --show-current (verify current branch)
    • If not on main: Ask user: "Should I switch to main? (Current: {branch})"
  2. Sync main:

    • git checkout main
    • git pull origin main --ff-only
    • If conflicts: ⚠️ Stop and report "Main has conflicts. Resolve manually."
  3. List local branches:

    • git branch --format='%(refname:short)'
    • Filter out: main, master, develop, staging, production, archive*
    • If no branches: Report "No local branches to clean up" and STOP.
  4. Check PR status for each branch:

    • Get PR for branch: gh pr list --head {branch} --state merged --json number,title,url
    • If merged PR found: Add to cleanup list
    • If no PR or not merged: Skip
  5. Present cleanup list:

    • Show table with: branch name, PR number, PR title, PR URL
    • Ask user: "Delete these {count} branches? (y/n)"
    • If user declines: STOP.
  6. Delete branches:

    • For each approved branch:
      • git branch -d {branch} (safe delete)
      • If fails with unmerged warning: Show warning and skip
      • If succeeds: Report "✅ Deleted {branch}"
    • Final summary: "Deleted {count} branches, skipped {count} unmerged branches"

Workflow Details

Step 1: Pre-flight Checks

bash
1# Fetch latest remote refs 2git fetch origin 3 4# Check current branch 5CURRENT_BRANCH=$(git branch --show-current)

If not on main:

  • Show: "Currently on {CURRENT_BRANCH}. Switch to main?"
  • Wait for user confirmation

Safety:

  • Never switch branches with uncommitted changes
  • Check: git status --porcelain (must be empty)

Step 2: Sync Main

bash
1# Switch to main 2git checkout main 3 4# Fast-forward merge only (no conflicts) 5git pull origin main --ff-only

If fast-forward fails:

  • ⚠️ Stop with error: "Main branch has diverged from origin. Manual resolution required."
  • Do NOT attempt merge or rebase

Step 3: Identify Merged Branches

For each local branch:

bash
1# Get merged PR for branch 2gh pr list --head {branch} --state merged --json number,title,url --limit 1

Branch categories:

StatusAction
Merged PR foundAdd to cleanup list
Open PR foundSkip (not merged)
No PR foundSkip (might be local work)
Protected branchSkip (main, master, etc.)

Protected branches:

  • main, master, develop, staging, production
  • Any branch starting with archive (e.g., archive-2024, archive/old)
  • Any branch matching origin/*

Step 4: Present Cleanup List

Format as markdown table:

markdown
1## Branches with merged PRs 2 3| Branch | PR | Title | 4|--------|-----|-------| 5| fxstein/AIT-12-feature | [#45](url) | Feature implementation | 6| oliver/ait-8-bugfix | [#38](url) | Fix login bug | 7 8Total: 2 branches

User prompt: "Delete these branches? They have merged PRs and are safe to remove. (y/n)"

Step 5: Safe Deletion

bash
1# Safe delete (only if fully merged) 2git branch -d {branch}

If git branch -d fails:

  • Shows: "The branch '{branch}' is not fully merged."
  • Action: Skip and report to user
  • Reason: Prevents data loss

Force delete (-D) is NEVER used automatically.

Edge Cases

No Merged Branches

If no branches qualify for cleanup:

✅ All local branches are up to date.
No merged branches found for cleanup.

Partially Merged Branches

If branch has commits not in main but PR is merged:

  • git branch -d will fail (expected)
  • Report: "⚠️ Skipped {branch}: has unmerged commits (possible rebase)"
  • User can manually verify with: git log main..{branch}

Archive Branches

Branches starting with archive are preserved:

  • ❌ Skip: archive-2024, archive/backup, archive-old-features
  • Reason: Archive branches contain historical work that should be manually managed

Remote Tracking Branches

Only delete local branches, never remote refs:

  • ✅ Delete: fxstein/AIT-12-feature
  • ❌ Skip: origin/fxstein/AIT-12-feature

Use git push origin --delete {branch} only if user explicitly requests remote deletion.

Error Handling

If ANY error occurs:

  1. STOP IMMEDIATELY
  2. Report the specific error
  3. Show current state: branch name, operation attempted
  4. WAIT for user input

Common errors:

ErrorCauseAction
"Not on main"Current branch not mainAsk to switch
"Fast-forward failed"Main diverged from originStop, manual resolution
"gh command not found"GitHub CLI not installedStop, ask user to install
"Branch not fully merged"Branch has unmerged commitsSkip branch

Safety Guarantees

  • ✅ Never force-delete (-D) branches
  • ✅ Never delete without user confirmation
  • ✅ Never modify remote branches
  • ✅ Never switch branches with uncommitted changes
  • ✅ Always use --ff-only for main sync

Output Format

Success

🔄 Syncing main with origin...
✅ Main is up to date

📋 Found 3 branches with merged PRs:
- fxstein/AIT-12-feature (PR #45)
- oliver/ait-8-bugfix (PR #38)
- fxstein/AIT-10-docs (PR #42)

🗑️  Deleting branches...
✅ Deleted fxstein/AIT-12-feature
✅ Deleted oliver/ait-8-bugfix
✅ Deleted fxstein/AIT-10-docs

✨ Cleanup complete: 3 branches deleted

With Skipped Branches

🗑️  Deleting branches...
✅ Deleted fxstein/AIT-12-feature
⚠️  Skipped fxstein/AIT-15-wip: not fully merged
✅ Deleted oliver/ait-8-bugfix

✨ Cleanup complete: 2 deleted, 1 skipped

Additional Features

Dry Run Mode

If user asks for "preview" or "dry run":

  • Execute steps 1-4 only
  • Show cleanup list
  • STOP before deletion

Delete Remote Branches

If user explicitly asks to "delete remote branches too":

  • After local deletion succeeds
  • For each deleted branch:
    bash
    1git push origin --delete {branch}
  • Report: "✅ Deleted {branch} (local + remote)"

Requirements

  • Git: Version 2.0+
  • GitHub CLI (gh): Required for PR status checks
  • Repository: Must be a git repository with GitHub remote

Forbidden Actions

  • ❌ Never use git branch -D (force delete)
  • ❌ Never delete branches without user confirmation
  • ❌ Never modify main, master, or protected branches
  • ❌ Never attempt merge/rebase to resolve conflicts

Related Skills

Looking for an alternative to branch-cleanup or another community skill for your workflow? Explore these related open-source skills.

View All

openclaw-release-maintainer

Logo of openclaw
openclaw

Your own personal AI assistant. Any OS. Any Platform. The lobster way. 🦞

333.8k
0
AI

widget-generator

Logo of f
f

Generate customizable widget plugins for the prompts.chat feed system

149.6k
0
AI

flags

Logo of vercel
vercel

The React Framework

138.4k
0
Browser

pr-review

Logo of pytorch
pytorch

Tensors and Dynamic neural networks in Python with strong GPU acceleration

98.6k
0
Developer