cleanup

Automate post-merge branch cleanup with fetch, prune, and safe deletion.

Updated Jan 22, 2026
One-click install
npx skills add https://github.com/BryceEWatson/bryce-labs-toolkit --skill cleanup-bryceewatson
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cleanup
Source: https://github.com/BryceEWatson/bryce-labs-toolkit/tree/main/skills/cleanup
Command: npx skills add https://github.com/BryceEWatson/bryce-labs-toolkit --skill cleanup-bryceewatson

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Post-merge branch cleanup: fetch, switch to base branch, fast-forward update, delete merged branch, prune stale refs.

Core Features & Use Cases

  • Detects the remote and base, fetches with prune, protects critical branches, and updates the base via fast-forward.
  • Deletes the previously-current branch if safe, offering a --force option for non-fully-merged branches.
  • Supports dry-run mode and per-repo configuration.

Quick Start

Run the cleanup in your repository after merging a PR using /cleanup to apply safe, automated cleanup.

Frequently Asked Questions about cleanup

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

FAQPage Schema
How do I automatically delete a git branch after a PR is merged?

Automated post-merge branch cleanup fetches remote refs with pruning, fast-forwards your base branch, and safely deletes the merged branch. This prevents stale local branches from accumulating after pull requests are integrated into the main codebase.

What is the safest way to clean up stale git branches in my workflow?

Safe git branch cleanup involves dry-run mode and branch protection rules to prevent deleting unmerged work. It detects your remote and base branch automatically, ensuring critical branches remain untouched while removing only fully merged refs.

Can I configure default git cleanup behavior for a specific repository?

You can configure per-repo defaults using git config cleanup.* settings. This allows you to define repository-specific rules for remote detection, base branch updates, and branch deletion behaviors without passing arguments every time.

Does git branch cleanup protect branches that are not fully merged?

Branch protection rules prevent the deletion of critical or unmerged branches during cleanup. A --force option exists to delete branches that are not fully merged, overriding the default safety checks when you are certain of the action.

How does automatic remote fetch with pruning work during branch cleanup?

Remote fetch with pruning updates your local view of remote branches by removing references to branches that no longer exist on the server. This ensures your local repository stays synchronized with the remote before switching and fast-forwarding the base branch.

Do I need to manually switch to the base branch before deleting a merged branch?

No, the cleanup workflow automatically switches to the detected base branch before deletion. It then fast-forwards the base to match the remote state and safely removes the previously current branch without requiring manual git checkout commands.