clean-branches

Delete local git branches and worktrees deleted on the remote.

Updated Jun 24, 2026
One-click install
npx skills add https://github.com/AvatarGanymede/pcraft --skill clean-branches-avatarganymede
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: clean-branches
Source: https://github.com/AvatarGanymede/pcraft/tree/main/.agents/skills/clean-branches
Command: npx skills add https://github.com/AvatarGanymede/pcraft --skill clean-branches-avatarganymede

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill automates the process of deleting local branches that have been deleted on the remote, including their worktrees, streamlining branch cleanup after merging pull requests.

Core Features & Use Cases

  • Branch Cleanup: Deletes local branches that have been marked as deleted on the remote.
  • Worktree Removal: Also removes any associated git worktrees.
  • Use Case: After merging a pull request, this Skill can be used to automatically clean up branches and worktrees, reducing clutter and ensuring your repository remains organized.

Quick Start

Run the clean-branches skill to remove all local branches that have been deleted on the remote.

Frequently Asked Questions about clean-branches

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

FAQPage Schema
How do I delete local git branches after merging a PR?

To delete local git branches after merging a PR, you need to fetch remote updates and prune branches marked as deleted. This skill automates that branch cleanup process to remove stale local refs and keep your repository organized.

What is the best way to automate branch cleanup for deleted remote branches?

The best way to automate branch cleanup is to run a process that lists and removes local branches marked as deleted on the remote. This skill handles the fetch and prune commands required to clear those obsolete branches automatically.

How do I remove git worktrees associated with deleted remote branches?

To remove git worktrees associated with deleted remote branches, you must prune the worktree references alongside the local branch deletion. This skill automates worktree removal to ensure linked workspace directories are cleaned up post-merge.

Does this branch cleanup skill require any specific git tools or plugins?

No specific git tools or plugins are required. This skill relies on standard git commands to fetch, prune, list, and remove branches and worktrees, functioning within your existing repository maintenance environment without extra dependencies.

When should I run post-merge branch cleanup in my repository?

You should run post-merge branch cleanup immediately after a pull request is merged and the remote branch is deleted. Running the skill at this point prevents local clutter by ensuring obsolete branches and worktrees are removed.

Why are stale local branches still showing after the remote is deleted?

Stale local branches remain because local git repositories do not automatically sync remote deletions. You must execute a fetch and prune operation to detect and remove local branches marked as deleted on the remote.