forge-cleanup
Skill4 starsChanged 3 months agoApache-2.0View on GitHub
Load when the user wants to tidy up — 'clean up', 'remove stale stuff', after a merged PR, or when worktrees and scratch files pile up.
- Deletes or force-pushes
- Commits and pushes
In this repository35 other files it gives its agents.
- AGENTS.mdAGENTS.md
- 12-factor-appSkill
- caveman-commitSkill
- caveman-reviewSkill
- cavemanSkill
- conventional-commitsSkill
- creating-pull-requestsSkill
- deep-researchSkill
- dispatching-parallel-agentsSkill
- domain-modelingSkill
- finishing-a-development-branchSkill
- forge-docsSkill
- forge-eu-accessibilitySkill
- forge-flowSkill
- forge-initSkill
- forge-seoSkill
- forge-setupSkill
- forgeSkill
- forge-tailwindcss-conventionsSkill
- frontend-designSkill
- git-issue-trackerSkill
- grillingSkill
- kiss-principleSkill
- loopsSkill
- planning-and-task-breakdownSkill
- prototypeSkill
- pr-resolveSkill
- pr-reviewSkill
- resolving-merge-conflictsSkill
- ste100Skill
- subagent-driven-developmentSkill
- use-git-identitySkill
- using-git-worktreesSkill
- verification-before-completionSkill
- wayfinderSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 49
Only proceed on y or Y. Skip on anything else.
- Distinctive: line 65
After all confirmed removals:
- Distinctive: line 81
One candidate at a time: Never batch-confirm.
- Distinctive: line 83
Current branch protected: Never offer to delete the branch the user is on.
- Distinctive: line 94
Delete main, master, or the current branch
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Forge Cleanup
One-shot maintenance. Removes stale forge development artefacts. Asks the user before every removal.
Steps
1. Detect candidates
Collect every stale artefact in the repo:
# 1. Scratch files (least destructive)
ls /tmp/pr-review-*.md /tmp/resolve-*.md /tmp/review-*.diff /tmp/forge-*.md /tmp/*.loop.out 2>/dev/null
# 2. Stale worktrees
# For each .worktrees/<slug>/ check: branch not merged to main AND branch not on origin
for d in .worktrees/*/; do
[ -d "$d" ] || continue
BRANCH=$(cd "$d" && git branch --show-current)
git merge-base --is-ancestor "$BRANCH" main 2>/dev/null || git branch -r --contains "$BRANCH" 2>/dev/null | grep -q . || echo "$d"
done
# 3. Uncommitted changes (main repo)
git status --porcelain
# 4. Untracked files (main repo)
git ls-files --others --exclude-standard
# 5. Local branches (feat/*, fix/*, chore/*, hotfix/* with no upstream, excluding current)
git for-each-ref --format='%(refname:short) %(upstream:short)' refs/heads | awk '$2 == "" && $1 ~ /^(feat|fix|chore|hotfix)\// && $1 != "'"$(git branch --show-current)"'" {print $1}'2. Ask per candidate (one at a time)
For each candidate, format and ask:
Found: <type> <path-or-name>
Remove it? [y/N] >Only proceed on y or Y. Skip on anything else. Continue to next candidate.
3. Act on confirmed removals
| Type | Command |
| Scratch file | rm -f <path> |
| Stale worktree | git worktree remove <path> --force (then git branch -D <branch> if branch still local) |
| Uncommitted changes | git checkout -- <path> (file-level) or git reset --hard HEAD (repo-level — ask again) |
| Untracked file | rm -f <path> |
| Local branch | git branch -D <branch> |
Log each action: Removed <type>: <path-or-name>.
4. Final pull
After all confirmed removals:
git checkout main
git pullReport:
Cleanup complete.
Removed: N scratch, N worktrees, N uncommitted, N untracked, N branches
On main at <commit-sha>Rules
- One candidate at a time. Never batch-confirm.
- Default is NO. Empty input = skip.
- Current branch protected. Never offer to delete the branch the user is on.
- Worktree branches — if the worktree branch isn't on
origin, offer to delete it after removing the worktree. - Uncommitted changes — offer file-by-file first; if many, offer repo-level
reset --hardas a second question. - No auto-confirm. Even
--yesflag doesn't bypass; this skill is interactive by design.
Boundaries
Forge Cleanup does not:
- Touch committed history (no
git rebase, nogit commit --amend) - Push anything (no
git push) - Modify remote state
- Delete
main,master, or the current branch - Touch other users' worktrees
It only removes local stale artefacts the user explicitly confirms.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
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.

