Skip to content
Skill

Git post merge cleanup

Cleans merged branches, gone remote refs and finished worktrees after PRs land

Git post merge cleanup is an open-source agent skill for developer tools. It is available on Claude Code.

Scripts
None
Platforms
Claude Code
GitHub stars
12
Last commit
License
MIT
Listing updated

Similar skills

About Git post merge cleanup

This skill tidies a local git repository after a batch of pull requests has been merged. It looks for three kinds of leftover state: local branches already merged into the default branch, remote-tracking references whose remote branch was deleted, and secondary worktrees whose changes already exist on the main branch. The agent scans and classifies everything first, then shows a single plan grouped by category.

The workflow is built around safety. Scans are read-only, and the agent only deletes after the user confirms, or after an explicit --yes flag or a --dry-run preview. Branches with unmerged work and worktrees with genuinely unmerged changes are flagged for attention rather than touched. Tags are handled separately: they are only deleted when the owner has approved a disposable retention policy, and remote tag deletion needs separate authorization.

The skill relies on a set of reference files for edge cases such as squash-merged branches and worktree detection. It expects a git repository with an origin remote, and it uses standard git commands through Bash.

When your agent uses it

Clean up stale git state after merges in one pass: merged local branches, tracking refs whose remote is gone, and worktrees that look modified but are already on main. Scans, shows a plan, acts only on confirmation; supports --dry-run and --yes. Use after a batch of PRs lands. Trigger on "clean up branches", "prune branches", "stale branches", "clean up worktrees".

From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.

What it can access

From a static check of its 3 files (17 KB) on GitHub on 4 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.

Check another skill before you install it.

Install

This skill ships in the skill-madness plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

/plugin marketplace add ivy00johns/Skill-Madness
/plugin install skill-madness@skill-madness

Or copy only this skill to ~/.claude/skills/git-post-merge-cleanup:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ivy00johns/Skill-Madness.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/git-post-merge-cleanup &&
cp -R "$tmp/skills/git/git-post-merge-cleanup" ~/.claude/skills/git-post-merge-cleanup &&
rm -rf "$tmp"

For one project only, put the folder in .claude/skills/git-post-merge-cleanup inside it instead.

Claude Code docs on skills

Copy the skill folder to ~/.agents/skills/git-post-merge-cleanup to use it in every repository:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ivy00johns/Skill-Madness.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/git-post-merge-cleanup &&
cp -R "$tmp/skills/git/git-post-merge-cleanup" ~/.agents/skills/git-post-merge-cleanup &&
rm -rf "$tmp"

For one repository only, put the folder in .agents/skills/git-post-merge-cleanup inside it instead.

Codex docs on skills

Copy the skill folder to ~/.cursor/skills/git-post-merge-cleanup to use it in every project:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ivy00johns/Skill-Madness.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/git-post-merge-cleanup &&
cp -R "$tmp/skills/git/git-post-merge-cleanup" ~/.cursor/skills/git-post-merge-cleanup &&
rm -rf "$tmp"

For one project only, put the folder in .cursor/skills/git-post-merge-cleanup inside it instead.

Cursor docs on skills

Run in a terminal (add --scope workspace to install it for the current workspace only):

gemini skills install https://github.com/ivy00johns/Skill-Madness.git --path skills/git/git-post-merge-cleanup

Or copy the folder to ~/.gemini/skills/git-post-merge-cleanup yourself.

Gemini CLI docs on skills

For GitHub Copilot in VS Code, copy the skill folder to ~/.copilot/skills/git-post-merge-cleanup:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ivy00johns/Skill-Madness.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/git-post-merge-cleanup &&
cp -R "$tmp/skills/git/git-post-merge-cleanup" ~/.copilot/skills/git-post-merge-cleanup &&
rm -rf "$tmp"

For one project only, put the folder in .github/skills/git-post-merge-cleanup inside it instead.

VS Code docs on skills

Get the folder:

git clone --depth 1 https://github.com/ivy00johns/Skill-Madness.git

Then copy Skill-Madness/skills/git/git-post-merge-cleanup into your agent's skills folder as git-post-merge-cleanup. Agents that support SKILL.md read one folder per skill.

The SKILL.md format

What it does

Merged branch detection
Finds local and remote branches already merged into the default branch.
Gone tracking reference cleanup
Identifies tracking references whose remote branch was removed after merge.
Worktree safety classification
Separates worktrees whose changes already landed on main from those with unmerged work.
Confirmation before deletion
Presents one combined plan and waits for approval before running destructive commands.
Dry-run and auto-confirm flags
Supports a preview-only mode and a non-interactive mode that still prints the plan.
Protected tag handling
Keeps release and unknown-policy tags and requires explicit approval for tag deletion.

Good for

  • Clean up branches after a batch of pull requests has been merged
  • Remove worktrees whose changes already landed on main
  • Preview which stale branches would be deleted without changing anything
  • Prune remote-tracking references for branches deleted on GitHub

Git post merge cleanup FAQ

What triggers Git post merge cleanup?

Requests such as clean up branches, prune branches, stale branches or clean up worktrees, typically after PRs land.

Does Git post merge cleanup delete anything without asking?

By default no. It shows a plan and waits for confirmation. --dry-run stops after the plan, and --yes skips the prompt but still prints the plan first.

Will Git post merge cleanup remove the main worktree or the default branch?

No. The main worktree and the default branch, along with develop, staging and production, are excluded by its safety rules.

Does Git post merge cleanup delete tags?

Only tags the owner has approved as disposable. Release, signed and unknown-policy tags are kept, and remote tag deletion needs explicit authorization.

How do I install Git post merge cleanup in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/git-post-merge-cleanup to use it in all your projects, or to .claude/skills/git-post-merge-cleanup in one project. Or install the skill-madness plugin, which includes it: /plugin marketplace add ivy00johns/Skill-Madness, then /plugin install skill-madness@skill-madness.

Does Git post merge cleanup run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

Which AI agents can use Git post merge cleanup?

Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.

What are the best alternatives to Git post merge cleanup?

The closest alternatives to Git post merge cleanup are Git branch cleanup, Git clean worktrees, Merge PR, Gh PR merge worktree checkout trap and Fix merge conflicts.

Where this comes from

  • Description: from the skill's own SKILL.md.

More from ivy00johns/Skill-Madness

  1. Finds merged and stale git branches, then deletes them only after your confirmation

    • Open source
    • 12 GitHub stars
    • Developer tools
  2. Finds and removes git worktrees whose changes are already merged into main

    • Open source
    • 12 GitHub stars
    • Developer tools
  3. Bulk-scans a skill ecosystem for consistency, quality gaps and ownership conflicts

    • Open source
    • 12 GitHub stars
    • Developer tools
  4. Runs a single-skill quality review covering structure, triggering and output checks

    • Open source
    • 12 GitHub stars
    • Developer tools
  5. Turns skill review or audit reports into a prioritized list of concrete SKILL.md fixes

    • Open source
    • 12 GitHub stars
    • Developer tools
  6. Applies planned edits to SKILL.md files, validates them, and offers to sync

    • Open source
    • 12 GitHub stars
    • Developer tools