ai-git-cleanup

ai-git-cleanup is a skill for Claude Code, Codex from arcasilesgroup/ai-engineering. It costs 202 tokens per session (2,695 once invoked), scanned A, original, Apache-2.0.

A manually invoked Git cleanup workflow that finds finished local branches and worktrees, explains the evidence for each suggested deletion, and waits for one explicit approval before changing anything.

In plain words
What is it for?
Use it to review and remove completed local branches and worktrees, then sync the default branch only when it is behind.
Why use it?
It reduces the risk of deleting the only copy of unfinished work or removing a protected branch. It also makes every refusal and proposed command visible before execution.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to review and remove completed local branches and worktrees, then sync the default branch only when it is behind.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/arcasilesgroup/ai-engineering/ai-git-cleanup
Install

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.

Any agent
npx skills add arcasilesgroup/ai-engineering --skill ai-git-cleanup
Clone the repo
git clone --depth 1 https://github.com/arcasilesgroup/ai-engineering

Made for: Claude Code, Codex.

Wrote 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.

agentmods badge for ai-git-cleanup

README.md
[![agentmods](https://agentmods.dev/badge/skills/arcasilesgroup/ai-engineering/ai-git-cleanup/github.svg)](https://agentmods.dev/skills/arcasilesgroup/ai-engineering/ai-git-cleanup)
Your own site
<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.

agentmods 80×15 button for ai-git-cleanup

Your own site · 80×15
<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>
Per session 202 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,695 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce 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

Measured 10d ago against content hash 1dff9eb07207, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

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.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/analyze.mjs), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

skills/ai-git-cleanup/SKILL.md · 171 lines

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

  1. 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: a status.showUntrackedFiles=no in the repository or the global config makes the bare command print nothing at all, so the read must force the listing itself; normal keeps a wholly ignored directory collapsed to one !! dir/ line, so the report stays bounded and matches the list's dir/ entries literally). Remove it with git worktree remove -- "<path>" only when the HEAD check names a branch that is already merged into the local main, 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 remove exits 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 status exits 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_Store into 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/ covers dist/out.js, and node_modules/ covers everything under it). A lookalike is not the entry: packages/x/dist/out.js is not dist/, and reports-archive/ is not reports/. 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_Store matches sub/.DS_Store and *.bun-build matches app.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 inside dist/ is dropped with it, unlisted, and only the paths git prints are ever seen. Never force a removal.
  2. Prune the stale ones. Run git worktree prune to drop registrations whose directory is already gone. It removes no live worktree.
  3. 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 local main and 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 an unknown option error, 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.
  4. 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 with git 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 -r cannot be read as a flag. A refusal is a keep, and it is never retried: -d tests the branch against its own upstream, so a branch merged into main whose upstream points elsewhere (a lagging origin/main, a refs/heads/behind) is refused — report that branch kept and name the upstream mismatch as the reason.

Read the full file on GitHub · 171 lines

Files

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.

Changes

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.

  1. 10d ago Changed · +32 lines · +57 tokens per session 1dff9eb07207
  2. 11d ago Changed · -61 lines · +4 tokens per session 5e4c9c2dd948
  3. 16d ago Changed · +57 lines · +51 tokens per session 73ad3a8dec10
  4. 18d ago First seen · 143 lines · 90 tokens per session scan A 9bf0deb208e4

Subscribe to this mod's changes

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.

Related

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…

Priivacy-ai/spec-kitty · 125 tokens

spk-admin-git-workflow

Operate Spec Kitty git workflows, worktrees, safe commits, merge preflights, stale state checks, and recovery.

Priivacy-ai/spec-kitty · 32 tokens

spk-gate-merge

Merge an accepted Spec Kitty mission safely, preserving git invariants, mission state, and post-merge follow-through.

Priivacy-ai/spec-kitty · 30 tokens

setup-husky-dotnet

Use when configuring Git hooks in .NET projects before team commits occur, to enforce commit message standards and code formatting automatically.

SebastienDegodez/copilot-instructions · 30 tokens

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…

rjmurillo/ai-agents · 105 tokens

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…

rjmurillo/ai-agents · 80 tokens