cleanup

Remove merged Minerva worktrees and prune matching local branches.

Updated May 16, 2026
One-click install
npx skills add https://github.com/honerlaw/agent-marketplace --skill cleanup-honerlaw
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cleanup
Source: https://github.com/honerlaw/agent-marketplace/tree/main/plugins/minerva/skills/cleanup
Command: npx skills add https://github.com/honerlaw/agent-marketplace --skill cleanup-honerlaw

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you safely remove merged Minerva worktrees and prune their corresponding local branches, preventing clutter and preserving in-progress work.

Core Features & Use Cases

  • Conservative merged-work cleanup: Removes only .minerva/worktrees/NNN-slug/ directories whose branches are detected as merged into the default branch.
  • Local branch pruning: Prunes the matching local branch for each removed worktree, using safe deletion and carefully constrained fallbacks.
  • Safety and idempotency: Supports --dry-run, includes pre-flight checks, and avoids touching the default branch or unmerged work.

Quick Start

Run minerva:cleanup --dry-run to see which merged worktrees and branches would be removed before doing anything destructive.

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 worktrees without deleting unmerged branches?

To safely remove merged git worktrees, validate the repository, detect the default branch, and check merge status via GitHub PRs or local branch checks before pruning matching local branches.

Can I do a dry-run before removing local branches and worktrees?

Yes, running a dry-run previews which merged worktrees and local branches would be removed. This idempotent pre-flight check ensures no destructive actions occur until you explicitly confirm the cleanup.

What is the best way to prune local branches after merging a pull request?

The best way to prune local branches after merging is to detect merged state via GitHub PRs or local checks, then safely delete the branch alongside its associated worktree directory.

Does this branch cleanup approach work with a specific work-unit slug?

Yes, branch cleanup can optionally target a specific work-unit slug or scan all `.minerva/worktrees/NNN-*` candidates. It checks merge status for the targeted slug to determine if safe deletion is possible.

How does merge detection work for local branch cleanup?

Merge detection for local branch cleanup works by validating the git repository, identifying the default branch, and checking merged state via GitHub PRs or local branch merge checks before applying any pruning actions.

When should I avoid using automated worktree removal?

You should avoid automated worktree removal when branches have not been merged into the default branch, as the cleanup process includes a confirmation gate specifically designed to preserve unmerged work and avoid touching the default branch.