cleanup
Skill3 starsChanged 30 days agoMITView on GitHub
List stale branches, long-open PRs, merged branches, and orphaned worktrees, then close or delete each one with confirmation.
- Commits and pushes
71 other projects use a version of this.
Adopted by
Most recently taken up by
- udecode/better-convextheir own version, first seen Nov 9, 2026
- fynnhaupt/skillstheir own version, first seen Nov 8, 2026
- VforVal/lumberjacktheir own version, first seen Nov 8, 2026
- LeonardiFranco/skillstheir own version, first seen Nov 8, 2026
- frnkgns/Overgeared-Skillstheir own version, first seen Nov 8, 2026
- Integralist/agent-skillstheir own version, first seen Nov 6, 2026
Used with
Projects with it also use chips, react-query-best-practices and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
udecodeSkillchips
Run the project's suggested-task ledger, the chips. /chips alone brings this session's open tasks up to date: it applies what the ledger helper says, settles stale and split tasks, cards what can start and reports the board, and /chips all also takes the ship-list tasks and the ones no live session owns, and merges duplicate tasks across the board. Use for /chips, /chips offer, start or drop, \"what chips are open\", \"suggest a task for X\", \"update the chips\", \"clean up the chips\", \"which chips are stale\", \"is this chip still worth doing\", \"merge duplicate chips\", at the last hand-back of a run that offered a task, and whenever pstack would file a tracked issue, a follow-up, a reflect Backlog item or an out-of-band PR.
Also in 3 projects that use this
bibektimilsina00Skillreact-query-best-practices
Audit and fix React Query usage in apps/web — enforce query key factories, signal forwarding, staleTime, and proper mutation patterns. Use when reviewing or fixing server-state code.
Also in 3 projects that use this
bibektimilsina00Skillyou-might-not-need-a-callback
Analyze and fix useCallback anti-patterns in your code
Also in 3 projects that use this
Scylla23Skillredo
Re-run the last routed task one model tier up (haiku → sonnet → opus → fable). User-invoked escalation when the previous result missed. Pass --dry-run to preview without running.
Also in 3 projects that use this
Aetheria-Labs1Skillplan-page
Plan one storefront page from strategy through final copy, section order, proof, offers, template direction, responsive layout, and production asset requirements. Stops at an approved execution-ready specification.
Also in 3 projects that use this
SocialKit-APISkillvideo-transcripts
Extract transcripts from social videos through SocialKit across YouTube, TikTok, Instagram, Facebook, X/Twitter, LinkedIn, and direct video file URLs. Use when the user asks to transcribe, get captions or subtitles, pull the spoken text, or read what a video says, including one video or many at once. Returns full text plus timestamped segments. Not for posting, private accounts, or unrelated website scraping.
Also in 3 projects that use this
- +3 more from bibektimilsina00
Other versions71 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 71
- simstudioai/sim★ 30ksame name
- pipecat-ai/pipecat★ 17ksame name
- udecode/plate★ 17ksame name
- civitai/civitai★ 7.3ksame name
- mampfes/hacs_waste_collection_schedule★ 2.3ksame name
- trycompai/comp★ 2.1ksame name
- udecode/dotai★ 1.2ksame name
- LedgerHQ/ledger-live★ 627same name
- ericboy0224/learn-docker-and-k8s★ 472same name
- udecode/better-convex★ 452same name
61 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository42 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- asideSkill
- assessmentSkill
- auditSkill
- benchmarkSkill
- brainSkill
- checkpointSkill
- concise-modeSkill
- cross-modelSkill
- deploySkill
- designSkill
- explainSkill
- fix-issueSkill
- ganSkill
- guardSkill
- hotfixSkill
- incidentSkill
- infraSkill
- interview-meSkill
- investigateSkill
- migrateSkill
- module-auditSkill
- morningSkill
- onboardSkill
- planSkill
- profileSkill
- pr-summarySkill
- readmeSkill
- refactorSkill
- researchSkill
- resolveSkill
- respondSkill
- retroSkill
- reviewSkill
- session-logSkill
- setupSkill
- shipSkill
- skill-newSkill
- spikeSkill
- tddSkill
- testSkill
- zoom-outSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
21 rules. 0 are common, 12 are distinctive, and 9 are very specific to this project.
0
Common
Most of the 61 edited versions we read keep these.
12
Distinctive
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 16
When the repository has accumulated many old branches.
- Distinctive: line 17
When you want to prune merged branches that were never deleted after merge.
- Distinctive: line 18
When open PRs have gone stale and need to be closed or re-evaluated.
- Distinctive: line 19
When worktrees from previous tasks were left behind.
- Distinctive: line 20
Before a release to reduce clutter.
- Very specific: line 32
No arguments: full scan covering branches, PRs, and worktrees.
- Distinctive: line 45
Detect the platform and account: Read git remote get-url origin to determine GitHub or GitLab.
- Distinctive: line 57
Find orphaned worktrees: Run git worktree list --porcelain.
- Very specific: line 96
If
--applywas NOT passed, stop here: Default mode is dry-run. Print the report, remind the user to re-run with --apply to mutate, and … - Very specific: line 98
Confirm and act: Only when --apply was passed.
- Distinctive: line 108
Prune remote tracking branches: Run git remote prune origin to clean up references to deleted remote branches.
- Very specific: line 124
Never delete protected branches: main, master, develop, staging, production, or branches matching release/*.
- Distinctive: line 125
Always confirm before force-deleting unmerged branches.
- Distinctive: line 126
Never close PRs that have activity in the last 7 days, even if they are older than the stale threshold.
- Very specific: line 127
Always prefix gh commands with GH_TOKEN per the github-accounts rule.
- Very specific: line 128
Always prefix glab commands with GITLAB_TOKEN and GITLAB_HOST per the gitlab-accounts rule.
- Very specific: line 131
When a branch exists both locally and on the remote, delete both if approved.
- Very specific: line 144
Stop and drop the item when a candidate branch is main, master, develop, staging, production, or matches release/*.
- Very specific: line 145
Stop after the report when the invocation lacks --apply.
- Distinctive: line 146
Stop and ask again when the user's selection names an item absent from the report.
- Distinctive: line 147
Stop and keep the worktree when git worktree list --porcelain shows uncommitted changes in it.
“Common” is measured: kept by at least 6 in 10 of the 61 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Overview
Repository hygiene tool that finds stale branches, lingering PRs, merged branches not yet deleted, and orphaned worktrees. Presents everything in a table, asks for confirmation per item, and cleans up what you approve.
When to use
- When the repository has accumulated many old branches.
- When you want to prune merged branches that were never deleted after merge.
- When open PRs have gone stale and need to be closed or re-evaluated.
- When worktrees from previous tasks were left behind.
- Before a release to reduce clutter.
When NOT to use
- For refactoring or cleaning up code. Use
/reviewor a manual refactor instead. - For dependency updates or vulnerability scanning. Use
/auditinstead. - For git commit, push, or PR creation. Use
/shipinstead.
Arguments
This skill accepts optional arguments after /cleanup:
- No arguments: full scan covering branches, PRs, and worktrees. Default mode is dry-run. No mutation happens without
--apply. branches: scan branches only.prs: scan PRs only.worktrees: scan worktrees only.--dry-run: explicit dry-run flag. Same as the default. Kept for clarity.--apply: perform the cleanup. Required for any mutation. Without this flag, the skill prints the report and exits.
Examples: /cleanup branches, dry-run, /cleanup prs --apply, /cleanup --apply.
The two-phase flow exists because cleanup is destructive: read the report, decide, then re-run with --apply.
Steps
- Detect the platform and account. Read
git remote get-url originto determine GitHub or GitLab. Identify the correct account token per the github-accounts or gitlab-accounts rules. - Find merged branches. Run
git branch --merged origin/HEAD 2>/dev/nullto list local branches whose HEAD is reachable from the default branch. Iforigin/HEADis not set, tryorigin/main, thenorigin/master. Exclude protected branches:main,master,develop,staging,production, and any branch matchingrelease/*. These can be safely deleted withgit branch -d. - Find stale branches. For each local and remote branch not in the merged list and not protected, check the date of the last commit:
git log -1 --format="%ci" <branch>. Flag branches with no commits in the last 30 days as stale. Record the branch name, last commit date, last commit message, and author. - Find stale PRs. Query the platform for open PRs in the current repo.
- GitHub:
GH_TOKEN=$(gh auth token --user <account>) gh pr list --state open --json number,title,author,createdAt,updatedAt,isDraft,url - GitLab:
GITLAB_TOKEN=<token> GITLAB_HOST=<host> glab mr list -F json, which lists open MRs by default - Flag PRs open for more than 14 days with no activity in the last 7 days as stale.
- Flag draft PRs open for more than 7 days separately.
- GitHub:
- Find orphaned worktrees. Run
git worktree list --porcelain. For each worktree, check if its branch still exists and is not merged. A worktree whose branch was deleted or merged is orphaned. Present findings. Display a table grouped by category:
## Cleanup Report ### Merged branches (safe to delete) | Branch | Merged into | Last commit | |--------|------------|-------------| | feature/auth-v2 | main | 12 days ago | | bugfix/null-check | main | 3 weeks ago | ### Stale branches (no commits in 30+ days) | Branch | Last commit | Author | Last message | |--------|------------|--------|-------------| | feature/old-idea | 45 days ago | alice | WIP: initial attempt | ### Stale PRs (open 14+ days, no recent activity) | PR | Title | Author | Age | Last activity | |----|-------|--------|-----|--------------| | #42 | Add caching layer | bob | 21 days | 18 days ago | ### Draft PRs (open 7+ days) | PR | Title | Author | Age | |----|-------|--------|-----| | #55 | WIP: new layout | carol | 10 days | ### Orphaned worktrees | Path | Branch | Reason | |------|--------|--------| | /tmp/repo-auth | feature/auth | branch deleted |- If
--applywas NOT passed, stop here. Default mode is dry-run. Print the report, remind the user to re-run with--applyto mutate, and exit. Confirm and act. Only when
--applywas passed. For each category, ask the user which items to clean up. Accept "all", a comma-separated list of names or numbers, or "skip".- Merged branches:
git branch -d <branch>. - Stale branches:
git branch -D <branch>with a warning that this force-deletes an unmerged branch. - Stale PRs: close without a comment, per
../../rules/pr-comment-discipline.md. The terminal report names each closed PR and its idle time, so the user can tell the author directly.- GitHub:
GH_TOKEN=$(gh auth token --user <account>) gh pr close <number> - GitLab:
GITLAB_TOKEN=<token> GITLAB_HOST=<host> glab mr close <number>
- GitHub:
- Draft PRs: same as stale PRs.
- Orphaned worktrees:
git worktree remove <path>.
- Merged branches:
- Prune remote tracking branches. Run
git remote prune originto clean up references to deleted remote branches. Print summary.
### Cleanup complete - N merged branches deleted - N stale branches deleted - N PRs closed - N worktrees removed - Remote tracking branches pruned
Rules
- Never delete protected branches:
main,master,develop,staging,production, or branches matchingrelease/*. - Always confirm before force-deleting unmerged branches. Make the warning visible.
- Never close PRs that have activity in the last 7 days, even if they are older than the stale threshold.
- Always prefix
ghcommands withGH_TOKENper the github-accounts rule. - Always prefix
glabcommands withGITLAB_TOKENandGITLAB_HOSTper the gitlab-accounts rule. - Close a PR with no comment. The reason goes in the terminal report, where the user decides how to tell the author.
- In
--dry-runmode, do not modify any state. Report only. - When a branch exists both locally and on the remote, delete both if approved. Delete local first with
git branch -d <branch>, or-Dafter the force-delete warning, then remote withgit push origin --delete <branch>. - Show age and last activity in relative format.
Common Rationalizations
- "The user asked for cleanup, so
--applyis implied": the default is a dry run. Print the report and wait for a re-run with--apply. - "The branch is stale, so
-Dis fine": a stale branch can hold the only copy of unmerged work. Show the force-delete warning and get a per-item answer. - "
origin/HEADis missing, so skip the merged scan": fall back toorigin/main, thenorigin/master. - "The PR is 20 days old, close it": age alone is not staleness. Activity in the last 7 days keeps it open.
- "The default token works for
gh": the wrong account sees the wrong PRs or none. PrefixGH_TOKENfor the account read from the remote.
Red Flags
- Stop and drop the item when a candidate branch is
main,master,develop,staging,production, or matchesrelease/*. - Stop after the report when the invocation lacks
--apply. - Stop and ask again when the user's selection names an item absent from the report.
- Stop and keep the worktree when
git worktree list --porcelainshows uncommitted changes in it.
Verification
- The report lists every category the invocation scanned, with relative ages.
- In dry-run mode,
git branch -a,git worktree list, and the open PR list are unchanged after the run. - With
--apply, each approved branch is absent fromgit branch -aand each approved worktree fromgit worktree list. - Each closed PR shows the state
CLOSEDinGH_TOKEN=$(gh auth token --user <account>) gh pr view <number> --json state, orglab mr viewon GitLab. - The summary counts match the items the user approved.
Related skills
/ship- Commit, push, and create PRs./morning- Cross-account sweep of open PRs, reviews, and issues. This skill covers one repository; that one covers every account.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

