ai-git-cleanup
Skill65 starsChanged 2 months agoApache-2.0View on GitHub
Preview and remove finished local Git work using native Git safeguards. Show worktrees and branches merged into the selected base, preserve dirty or unmerged work, and never force-delete by default. Use for "tidy up", "delete old branches", "start fresh", or when the user names ai-git-cleanup.
In this repository41 other files it gives its agents.
- AGENTS.mdAGENTS.md
- a11y-auditSkill
- ai-adversarial-loopSkill
- ai-agents-mdSkill
- ai-architectSkill
- ai-audit-codeSkill
- ai-audit-designSkill
- ai-audit-docsSkill
- ai-brainstormSkill
- ai-codegraphSkill
- ai-config-to-projectSkill
- ai-debugSkill
- ai-design-md-plannerSkill
- ai-exploreSkill
- ai-issue-reportSkill
- ai-noteSkill
- ai-orchestratorSkill
- ai-prototypeSkill
- ai-prSkill
- ai-read-docsSkill
- ai-researchSkill
- ai-review-uiSkill
- ai-securitySkill
- ai-stress-testSkill
- ai-test-plannerSkill
- ai-triageSkill
- ai-verifySkill
- ai-visual-recapSkill
- ai-writeSkill
- ai-writing-behaviorSkill
- build-checkSkill
- code-auditSkill
- design-checkSkill
- feature-verifySkill
- full-reviewSkill
- perf-auditSkill
- review-routerSkill
- second-opinionSkill
- security-auditSkill
- spec-extractSkill
- verify-featureSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
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
- Distinctive: line 13
Start with a read-only preview.
- Very specific: line 53
After the person approves the preview, remove only clean, merged worktrees with git worktree remove -- "<path>", prune stale registrations …
- Distinctive: line 67
Read by: the person who asked for cleanup Dies: after each preview and approved pass Next: none
≈ “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
ai-git-cleanup — preview finished local work
Start with a read-only preview. Never fetch, push, delete remote branches, or
assume a default branch. Resolve the local base from the person's explicit
choice or repository configuration; if neither identifies one, ask once. Keep
$base_ref for Git comparisons and resolve $base_branch to that selected
base's short local branch name; the base itself is never a deletion candidate.
The cleanup pass never asks for a branch or worktree name.
git worktree list
git worktree prune --dry-run
git branch --merged "$base_ref" --format='%(refname:short)' | grep -Fvx -- "$base_branch"For each candidate, set $worktree_path to its exact checkout path and show
the branch, checkout path, and status before changing anything. Before
requesting approval, list every ignored path in the worktree:
git -C "$worktree_path" ls-files --others --ignored --exclude-standardShow every returned path relative to the worktree root and explain that removing
the worktree deletes it. If the command fails or cannot prove the complete list,
keep the candidate. Never delete ignored paths by default: the person must
explicitly approve deletion of every listed path after seeing the paths and
consequences, including paths classified as regenerable. Immediately before
removal, rerun the listing and keep the candidate if it differs from the preview
or cannot be read. Keep the current checkout, detached worktrees, dirty
worktrees, branches checked out elsewhere, and branches not merged into the
selected base.
Ignored output is regenerable only at node_modules/, dist/, coverage/,
.stryker-tmp/, reports/, .ai-engineering/receipts/,
.ai-engineering/cache/, .ai-engineering/workflow/playwright/,
*.bun-build, .claude/reviews/, and *.DS_Store; anything else ignored is
data. These existing system and editor noise paths are the only ignored outputs
the repository marks regenerated. Match each exact path relative to the worktree root:
reports-archive/ and
packages/x/dist are not matches. For each removal, report every ignored path it drops and the acknowledged
consequence.
After the person approves the preview, remove only clean, merged worktrees with
git worktree remove -- "<path>", prune stale registrations with
git worktree prune, and delete merged local branches with
git branch -d -- "<branch>". Git's refusal is the safety result: report it
and keep the candidate. Never use -D, --force, or retry a refusal.
For a named worktree that the person explicitly wants removed despite unmerged
work, use ai-eng worktree rm <slug> and follow its confirmation and safety
checks; this skill's automatic pass never substitutes for that request.
Lifecycle
Lane: any Writes: nothing Read by: the person who asked for cleanup Dies: after each preview and approved pass Next: none
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.

