cleanup-to-main

Delete stale local git branches removed from the remote.

Updated May 28, 2026
One-click install
npx skills add https://github.com/haryelramalho/skills --skill cleanup-to-main
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cleanup-to-main
Source: https://github.com/haryelramalho/skills/tree/main/skills/curated/cleanup-to-main
Command: npx skills add https://github.com/haryelramalho/skills --skill cleanup-to-main

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill removes local git branches that have already been deleted from the remote, helping you keep repositories clean without risking active work.

Core Features & Use Cases

  • Safe branch cleanup: Checks for uncommitted changes and branch sync before deleting anything.
  • Remote-aware pruning: Fetches and prunes remote references, then identifies local branches whose upstream is gone.
  • Protected workflow: Preserves local-only branches and always keeps main, master, and develop intact.
  • Detailed reporting: Summarizes deleted, skipped, and kept branches so you can review the cleanup outcome.
  • Use Case: After merging a batch of pull requests, run this Skill to safely remove stale feature branches from your machine.

Quick Start

Use the cleanup-to-main skill to safely remove local branches that were deleted from the remote after confirming your working tree is clean.

Frequently Asked Questions about cleanup-to-main

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I delete stale local git branches after merging pull requests?

Git branch cleanup removes stale local branches that no longer exist on the remote. It fetches and prunes remote references, identifies local branches with deleted upstreams, and safely removes them after verifying a clean working tree.

What happens to uncommitted changes when running a git branch cleanup?

Git branch cleanup requires a clean working tree before proceeding. The process checks for uncommitted changes and branch sync status, skipping deletion entirely if your workspace has pending modifications to ensure active work is preserved.

Does safe branch deletion preserve main, master, and develop branches?

Safe branch deletion always preserves main, master, and develop branches. The workflow detects default branches and protects them from removal, while also keeping local-only branches that have no remote upstream intact during the pruning process.

Can I prune remote git branches and get a report of deleted and skipped branches?

Yes, remote-aware pruning fetches and prunes remote references, then identifies local branches whose upstream is gone. It produces a detailed cleanup report summarizing deleted, skipped, and kept branches so you can review the outcome.

What's the best way to clean up git repository branches without losing local-only work?

The best way to clean up git repository branches safely is to use a protected workflow that fetches remote references, identifies branches with deleted upstreams, and preserves local-only branches while removing only stale tracked branches.

Why does git branch cleanup require a synced tracked branch before deletion?

Git branch cleanup requires a synced tracked branch to ensure remote references are accurate before identifying stale branches. This prevents accidental deletion of branches that still exist remotely but have not yet been fetched locally.