cleanup

Prune merged branches, stale worktrees, and dead remote refs from local git repositories.

Updated Apr 7, 2026
One-click install
npx skills add https://github.com/rnwolfe/engram --skill cleanup-rnwolfe
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cleanup
Source: https://github.com/rnwolfe/engram/tree/main/.claude/skills/cleanup
Command: npx skills add https://github.com/rnwolfe/engram --skill cleanup-rnwolfe

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Cleaning up a messy local git state by removing merged branches (local and remote), pruning remote tracking refs, removing stale worktrees, and landing on a clean main. This helps teams start new work without confusion and keeps the repository tidy after forge-loop sessions.

Core Features & Use Cases

  • Remove merged branches locally and remotely to reduce clutter and prevent accidental re-use.
  • Prune remote-tracking refs and stale worktrees to reflect the true state of the repository.
  • Ensure you land on a verified-clean base branch (e.g., main) before starting new work.

Quick Start

Run a safe cleanup to remove merged branches, prune stale remote refs, and land on a clean main.

Frequently Asked Questions about cleanup

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

FAQPage Schema
How do I clean up merged git branches and stale worktrees safely?

Cleaning up merged git branches and stale worktrees safely is done by pruning local and remote branches, removing dead remote refs, and switching to a verified-clean main branch with built-in guardrails. The process requires user confirmation for ambiguous items.

What is the safest way to prune remote tracking refs in a local repository?

Pruning remote tracking refs in a local repository safely means removing dead remote references while skipping branches with open PRs and preventing the deletion of base branches. The system lands you on a clean main branch after pruning.

When do I need to clean up my local git state before starting new work?

You need to clean up your local git state before starting new work or after post-merge cycles when the repository feels cluttered. Removing stale worktrees and merged branches ensures you start from a verified-clean base branch without confusion.

Will cleaning up local git branches delete my base branch or open PRs?

Cleaning up local git branches will not delete your base branch or open PRs. The cleanup process implements strict guardrails that skip branches with open PRs, prevent base branch deletion, and require user confirmation for ambiguous items.

Can I remove stale worktrees and dead remote refs at the same time?

Yes, you can remove stale worktrees and dead remote refs at the same time during a single cleanup operation. The process prunes merged branches locally and remotely, clears stale worktrees, and lands on a verified-clean base branch.

Why does my git repository feel cluttered after merging multiple branches?

Your git repository feels cluttered after merging because stale worktrees, dead remote tracking refs, and merged branches accumulate. Running a targeted cleanup restores a tidy repository state by pruning these remnants and switching to a clean main branch.