pr-to-main-cleanup

Deletes merged feature branches locally and remotely after a squash-merged PR to main.

5.4k|571|Updated Nov 1, 2025
One-click install
npx skills add https://github.com/breaking-brake/cc-wf-studio --skill pr-to-main-cleanup
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pr-to-main-cleanup
Source: https://github.com/breaking-brake/cc-wf-studio/tree/main/.claude/skills/pr-to-main-cleanup
Command: npx skills add https://github.com/breaking-brake/cc-wf-studio --skill pr-to-main-cleanup

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

After a pull request is merged into main, leftover feature branches clutter both local and remote repositories, and standard git merge detection fails on squash merges, making cleanup error-prone.

Core Features & Use Cases

  • Branch Context Gathering: Checks the current branch and latest commit before performing any destructive action.
  • Synchronized Cleanup: Switches to main, pulls the latest changes from origin, then deletes the feature branch both locally and on the remote.
  • Squash-Merge Handling: Uses force delete (git branch -D) because squash-merged PRs are not recognized as merged by git.
  • Use Case: After your PR to main is merged, ask the assistant to clean up, and it will switch to main, sync with origin, and remove the stale feature branch in one flow.

Quick Start

Ask the assistant to clean up the merged feature branch after the PR to main has been merged.

Frequently Asked Questions about pr-to-main-cleanup

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

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

Switch to main, pull the latest changes from origin, then delete the branch locally with git branch -D and remotely with git push origin --delete. This skill automates that exact sequence.

Why does git say my branch is not fully merged after a squash merge?

Squash merging creates a new commit on main, so git cannot trace the feature branch commits as merged. Use git branch -D to force delete instead of the safer -d flag.

Can I delete both local and remote git branches in one step?

Yes, run git branch -D <branch> for the local copy and git push origin --delete <branch> for the remote copy. This skill chains both commands after syncing main.

Is it safe to force delete a branch with git branch -D?

It is safe only when the PR has been merged to main, since force delete skips git's merged-status check. Always pull the latest main first to confirm the merge landed before deleting.