repo-cleanup

Reconciles stale git branches, worktrees, stashes, and untracked files after shipping.

Updated Mar 26, 2026
One-click install
npx skills add https://github.com/Sassy-Dog/sassydog-skills --skill repo-cleanup-sassy-dog
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: repo-cleanup
Source: https://github.com/Sassy-Dog/sassydog-skills/tree/main/skills/repo-cleanup
Command: npx skills add https://github.com/Sassy-Dog/sassydog-skills --skill repo-cleanup-sassy-dog

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? After merging pull requests, repositories accumulate debris: [gone] local branches, squash-merged branches that refuse to delete, orphaned agent worktrees and worktree-agent-* isolation branches, stale stashes, untracked noise files, and lingering remote branches. This Skill performs the low-level git reconciliation mechanics to clean all of it safely, with guards against deleting in-flight work. ## Core Features & Use Cases - Branch reconciliation: Fast-forward the default branch, sweep [gone] and squash-merged local branches (using -D after MERGED-PR verification), and delete stale remote branches while protecting branches that are the base of an open PR. - Worktree and stash triage: Remove detached or orphaned agent worktrees and classify stashes by closedByPullRequestsReferences — auto-dropping superseded work and asking only on genuinely ambiguous cases. - Untracked-file sweep: Enumerate with git clean -ndx (including gitignored files), auto-discard allowlisted noise like .DS_Store and node_modules/, and never touch a never-discard list such as .env.local. - Use Case: After a 35-issue parallel shipping run leaves 36 orphan worktree-agent-* branches and a pile of stashes, invoke this Skill to classify every artifact, delete what verifiably shipped, and surface only the genuinely ambiguous leftovers for review. ## Quick Start Ask the agent to clean up the repository by deleting merged branches, stale worktrees, and superseded stashes after the recent PRs shipped.

Frequently Asked Questions about repo-cleanup

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

FAQPage Schema
How do I delete local git branches whose remote was deleted?

Use git for-each-ref with %(upstream:track) and grep for [gone] to list branches whose upstream was deleted, then delete them. Grepping git branch -vv output for [gone] fails because the token renders as ': gone]' inside the tracking annotation.

Why won't a squash-merged branch delete with git branch -d?

After a squash merge, the feature branch tip is not an ancestor of the default branch, so git merge-base reports it unmerged and -d refuses. Verify the PR merged with gh pr list, then force-delete with git branch -D.

How do I know if a git stash is safe to drop?

Extract the issue number from the stash subject and check its closedByPullRequestsReferences via gh issue view. A merged closing PR means the work shipped and the stash is superseded; a closed issue with no PR references means it was abandoned and deserves review.

Can deleting a remote branch close someone's open pull request?

Yes. GitHub closes a PR when its base branch is deleted, and a merged branch can still be the base of another open PR in a stack. Subtract the open-PR baseRefName set from deletion candidates before pushing branch deletions.

Why does git clean miss node_modules and other ignored files?

Without the -x flag, git clean skips gitignored paths entirely, so build output and dependency directories are never enumerated. Use git clean -ndx for a dry run that includes ignored files, then remove specific paths with rm.