Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add arcasilesgroup/ai-engineering --skill ai-git-cleanupgit clone --depth 1 https://github.com/arcasilesgroup/ai-engineeringWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/arcasilesgroup/ai-engineering/ai-git-cleanup)<a href="https://agentmods.dev/skills/arcasilesgroup/ai-engineering/ai-git-cleanup"><img src="https://agentmods.dev/badge/skills/arcasilesgroup/ai-engineering/ai-git-cleanup/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/arcasilesgroup/ai-engineering/ai-git-cleanup"><img src="https://agentmods.dev/badge/skills/arcasilesgroup/ai-engineering/ai-git-cleanup.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00202 | $0.02695 |
| Opus 5.5 | $0.00081 | $0.01078 |
| Sonnet 5.5 | $0.00040 | $0.00539 |
| Haiku 4.5 | $0.00020 | $0.00269 |
Grade A, and why
ai-git-cleanup scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 171 lines — stays where its author put it; the contents beside it link to each section on GitHub.
ai-git-cleanup — remove finished local work in one pass
Say a cleanup phrase and the pass runs itself. It deletes only work that is
finished — worktrees whose branch is merged into the local main, those merged
branches, and the branches a squash-merged pull request left behind (their
content provably already in origin/main) — and it never asks a question and
never takes a name. Anything unfinished, unprovable, or detached is left exactly
where it is. Run the steps in order, from the primary checkout, and report what
each one did.
The pass
- Remove the dead worktrees. The loop walks the session worktrees only —
the primary checkout is never a candidate, since
git worktree remove <repo>refuses it as a main working tree (and the pass leaves the tree you are standing in alone). For each worktree, read two facts before touching it: whether its HEAD is on a branch (git -C "<path>" symbolic-ref -q HEAD) and what uncommitted content it holds, ignored files included (git -C "<path>" status --porcelain --ignored --untracked-files=normal— the option is required: astatus.showUntrackedFiles=noin the repository or the global config makes the bare command print nothing at all, so the read must force the listing itself;normalkeeps a wholly ignored directory collapsed to one!! dir/line, so the report stays bounded and matches the list'sdir/entries literally). Remove it withgit worktree remove -- "<path>"only when the HEAD check names a branch that is already merged into the localmain, the status read printed no warning, and every status entry is either absent or an ignored path on the regenerable list below. Otherwise skip it and report it kept with the reason:- No branch (detached HEAD).
git worktree removeexits 0 on a clean detached worktree and the commits it holds become unreachable from every ref, so the pass never removes one: report it kept as "detached, no branch to prove". - Uncommitted content that is not regenerable. Tracked and untracked
content always keeps the worktree, and so does any ignored path outside the
list below — the removal is never forced, and git destroys ignored content
silently (a
.env, ignored screenshots). Report it kept and say what the status listed. - Unreadable status.
git statusexits 0 while warning on stderr when it cannot read a subdirectory or a path, so a read that warned is not a clean worktree: keep it and report the warning. The doubt is resolved by keeping, never by removing what the read did not see. - Ignored content that is all regenerable. Two groups, and nothing else:
the paths this framework rebuilds —
node_modules/,dist/,coverage/,.stryker-tmp/,reports/,.ai-engineering/receipts/,.ai-engineering/cache/,.ai-engineering/workflow/playwright/— plus the system and editor noise this repository already ignores in.gitignore:*.bun-build,.claude/reviews/, and*.DS_Store(macOS writes a.DS_Storeinto every directory a Finder window or an app touches, so a merged worktree whose only ignored content is one must still be removed). They are build, runtime, and machine output, never data, so they do not keep a worktree: remove it and name every ignored path dropped. The ceiling is that list — it is exactly what this framework regenerates and what the repository ignores as noise, so anything else ignored is treated as data and keeps the worktree. A match is anchored to the worktree root, never a substring or a bare name: the printed path must be the entry itself, or sit inside a listed directory, so a listed directory is taken whole (dist/coversdist/out.js, andnode_modules/covers everything under it). A lookalike is not the entry:packages/x/dist/out.jsis notdist/, andreports-archive/is notreports/. The two*-prefixed entries are the exception to the whole-path rule — they are suffix patterns matched against the path's last component at any depth, so*.DS_Storematchessub/.DS_Storeand*.bun-buildmatchesapp.bun-build. The read collapses a wholly ignored directory to one!! dir/line, so the report names the directories it drops; the ceiling is that a listed directory goes whole — a hand-written file insidedist/is dropped with it, unlisted, and only the paths git prints are ever seen. Never force a removal.
- No branch (detached HEAD).
- Prune the stale ones. Run
git worktree pruneto drop registrations whose directory is already gone. It removes no live worktree. - Delete the merged branches (needs git ≥ 2.56.0). Run
git branch --delete-merged refs/heads/main— it deletes only branches whose upstream is the localmainand that are fully merged into it, and never the branch checked out here. The option exists only from git 2.56.0: on any older git it fails with anunknown optionerror, and that is not a pass failure — steps 1 and 2 have already run — so report it and continue to step 4 for every merged branch. - Fall back for a merged branch without that upstream. List the candidates
with
git branch --merged main, then drop the current branch and any branch checked out in another worktree (the lines decorated*or+) and read each remaining name without its decoration. Delete each withgit branch -d -- "<branch>". The name goes in as one quoted argument that is data, never re-typed into a shell line: a branch name may legally carry metacharacters ($(…),;,|, spaces), and an unquoted interpolation executes them.--ends the options, so a name like-rcannot be read as a flag. A refusal is a keep, and it is never retried:-dtests the branch against its own upstream, so a branch merged intomainwhose upstream points elsewhere (a laggingorigin/main, arefs/heads/behind) is refused — report that branch kept and name the upstream mismatch as the reason.
What ships with it
1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 10d ago Changed · +32 lines · +57 tokens per session 1dff9eb07207
- 11d ago Changed · -61 lines · +4 tokens per session 5e4c9c2dd948
- 16d ago Changed · +57 lines · +51 tokens per session 73ad3a8dec10
- 18d ago First seen · 143 lines · 90 tokens per session scan A 9bf0deb208e4
ai-git-cleanup is a skill published in the GitHub repository arcasilesgroup/ai-engineering (61 stars, last pushed 2d ago), licensed Apache-2.0. It adds 202 tokens to every session and 2,695 once invoked, about $0.0008 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-28.
Other skills, from other repositories
spec-kitty-git-workflow
Understand how Spec Kitty manages git: what git operations Python handles automatically, what agents must do manually, worktree lifecycle, auto-commit behavior, merge execution, and the safe-commit pattern. Triggers: "how does spec-kitty use git", "worktree management", "auto-commit", "who commits what", "git…
spk-admin-git-workflow
Operate Spec Kitty git workflows, worktrees, safe commits, merge preflights, stale state checks, and recovery.
spk-gate-merge
Merge an accepted Spec Kitty mission safely, preserving git invariants, mission state, and post-merge follow-through.
setup-husky-dotnet
Use when configuring Git hooks in .NET projects before team commits occur, to enforce commit message standards and code formatting automatically.
ai-agents-generation-and-release
Operate the ai-agents generation and release machinery, covering the seven buildall.py generators, generateagents.py, the drift gates, the version-free plugin manifests, and the npm publish path. Use when you say regenerate the mirrors, run the drift checks, why is the plugin version gate red, release the npm cli. Do…
ship
Run the four pre-flight checks, then create the PR or validate a contributor branch without touching it. Use when you say ship it, ship this branch, or run pre-flight and open the PR, and run it after review. Do NOT use to open a PR without the gates (use push-pr), and do NOT use to run the review axes themselves (use…