branch-cleanup-after-pr

Synchronize local Git branches and delete merged or obsolete ones.

1|Updated May 30, 2025
One-click install
npx skills add https://github.com/pkuppens/on_prem_rag --skill branch-cleanup-after-pr
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: branch-cleanup-after-pr
Source: https://github.com/pkuppens/on_prem_rag/tree/main/.cursor/skills/branch-cleanup-after-pr
Command: npx skills add https://github.com/pkuppens/on_prem_rag --skill branch-cleanup-after-pr

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill automates the cleanup of local Git branches after a pull request has been merged, ensuring your local repository stays tidy and up-to-date with remote changes.

Core Features & Use Cases

  • Sync Local Branches: Automatically checks out the main branch, pulls the latest changes, and fetches remote updates with pruning.
  • Remove Obsolete Branches: Identifies and deletes local branches that have been merged into the main branch or whose remote counterparts have been deleted.
  • Use Case: After successfully merging a feature branch into main on GitHub, run this Skill to remove the now-redundant local feature branch and ensure your local main is current.

Quick Start

Run the branch cleanup skill to sync your local branches after a pull request merge.

Frequently Asked Questions about branch-cleanup-after-pr

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

FAQPage Schema
How do I clean up local Git branches after a pull request is merged?

To clean up local Git branches after a pull request, you need to sync with the remote by checking out main, pulling updates, and pruning stale remote-tracking branches before deleting fully merged local branches. The skill automates this entire process.

What is the best way to delete local branches that are fully merged into main?

The best way to delete fully merged local branches is to first synchronize your local main branch with the remote and prune deleted remote-tracking branches. This skill identifies and removes obsolete local branches that are fully merged into main automatically.

Does Git branch cleanup work with squash and rebase merge workflows?

Yes, Git branch cleanup works with squash and rebase workflows. This skill supports deleting local branches whose remote counterparts no longer exist, which is essential for maintaining a clean repository after squash or rebase merges.

Why do I have stale local branches after merging a pull request on GitHub?

Stale local branches remain because merging a pull request on GitHub deletes the remote branch but does not automatically delete your local copy. Running a branch synchronization and cleanup process fetches remote updates with pruning to remove these obsolete local branches.

How do I prune stale remote-tracking branches and sync my local main branch?

To prune stale remote-tracking branches and sync your local main branch, you checkout the main branch, pull the latest changes, and fetch remote updates with pruning enabled. This skill automates that synchronization before identifying branches safe for deletion.