cleanup-git

cleanup-git is a skill for Claude Code, Codex from alexei-led/cc-thingz. It costs 70 tokens per session (832 once invoked), scanned A, original, MIT.

A cleanup tool for local Git branches and worktrees. A worktree is another working folder connected to the same Git repository.

In plain words
What is it for?
Use it to tidy Git state after pull requests or other branches have been merged.
Why use it?
It helps remove local branches and worktrees that are already merged, deleted remotely, or no longer needed, while offering a dry run first.

Skill for Claude CodeCodex

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

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.

agentmods
npx agentmods add skills/alexei-led/cc-thingz/cleanup-git
Any agent
npx skills add alexei-led/cc-thingz --skill cleanup-git
Clone the repo
git clone --depth 1 https://github.com/alexei-led/cc-thingz

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 cleanup-git

README.md
[![agentmods](https://agentmods.dev/badge/skills/alexei-led/cc-thingz/cleanup-git.svg)](https://agentmods.dev/skills/alexei-led/cc-thingz/cleanup-git)
Your own site
<a href="https://agentmods.dev/skills/alexei-led/cc-thingz/cleanup-git"><img src="https://agentmods.dev/badge/skills/alexei-led/cc-thingz/cleanup-git.svg" alt="Measured on agentmods" height="20"></a>
Per session 70 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 832 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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.00070 $0.00832
Opus 5 $0.00035 $0.00416
Sonnet 5 $0.00014 $0.00166
Haiku 4.5 $0.00007 $0.00083

Measured 6d ago against content hash 703b8e34acc5, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

cleanup-git 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 6d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (scripts/cleanup-git.sh), 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.

src/skills/cleanup-git/SKILL.md · 94 lines

How it starts

The opening of the file, as written. The whole thing — 94 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Cleanup Git

Clean local git branches and worktrees after work has merged. Dry-run first. Destructive commands require user approval.

Prefer a repo-local scripts/cleanup-git.sh when the target repo ships one. If it does not, use the bundled skill script from this skill's scripts/ directory. Do not improvise destructive cleanup commands outside the script workflow.

Command

Run from anywhere inside a repository:

scripts/cleanup-git.sh
scripts/cleanup-git.sh --apply
scripts/cleanup-git.sh --apply --force
scripts/cleanup-git.sh --base <ref>

Branch Detection

The script fetches/prunes remotes, then chooses the comparison branch:

  1. Remote default branch from refs/remotes/<remote>/HEAD.
  2. Local main, master, trunk, develop, or dev.
  3. Remote <remote>/{main,master,trunk,develop,dev}.

Use --base <ref> only for unusual repositories.

What It Removes

  • Worktrees whose branch has a GitHub PR in MERGED state, is merged into the detected base branch, or whose upstream is gone.
  • Local branches with the same criteria.

When gh is available, PR MERGED state is the source of truth for squash/rebase merges. Do not miss those just because git merge-base --is-ancestor fails after history rewrite. If no PR is found, or gh is unavailable, fall back to the git-based checks.

Guards

Hard guards:

  • Skip the current worktree.
  • Skip the current branch.
  • Skip the detected base branch and common long-lived branches: main, master, trunk, develop, dev.
  • Keep worktrees with uncommitted changes.

Soft guard:

  • Keep items with commits ahead of the base branch. --force overrides only this guard.
  • For merged PRs, treat only commits added after the PR head as "ahead". A squash/rebase-merged branch with no new local commits is still removable.

Workflow

  1. Run scripts/cleanup-git.sh and show the preview.
  2. Read reasons literally: remove ... (PR merged), remove ... (upstream gone), KEEP ... (dirty), KEEP ... (PR merged, N ahead — use --force).
  3. Surface every KEEP line as a human decision.
  4. Ask before running scripts/cleanup-git.sh --apply.
  5. Use --force only when the user confirms ahead commits are throwaway.

Read the full file on GitHub · 94 lines

Files

What ships with it

3 files 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. 6d ago First seen · 94 lines · 70 tokens per session scan A 703b8e34acc5

Subscribe to this mod's changes

cleanup-git is a skill published in the GitHub repository alexei-led/cc-thingz (35 stars, last pushed 1mo ago), licensed MIT. It adds 70 tokens to every session and 832 once invoked, about $0.0003 per session on Opus 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-08-30.

Related

Other skills, from other repositories

peekaboo

Provides runtime observation and interaction for native macOS interfaces through accessibility state and screenshots. Use when the task depends on visible or interactive state in a running SwiftUI/AppKit app: what is rendered, focused, selected, enabled, reachable through menus/windows/dialogs, or experienced across a…

johnkozaris/jko-claude-plugins · 104 tokens

mobile-flows-maestro

This skill should be used when Maestro is explicitly requested or already present and the task is to author, run, or debug iOS/Android Maestro flows; use Maestro MCP; or handle Maestro selectors, system UI, permissions, Keychain, JavaScript, waits, device state, flakiness, or CI. Evidence includes a .maestro directory…

johnkozaris/jko-claude-plugins · 102 tokens

validate-mobile

Run a Maestro flow on an explicitly selected iOS or Android device and report behavioral evidence.

johnkozaris/jko-claude-plugins · 20 tokens

validate-api

Run the project's Hurl scenarios with an OIDC access token passed as a secret variable.

johnkozaris/jko-claude-plugins · 20 tokens

backend-architecture

This skill should be used for consequential backend architecture decisions: module or service boundaries; modular monoliths versus independent services; service extraction and data migration; data ownership and consistency; synchronous, event-driven, actor/stateful, or pipeline designs; failure isolation…

johnkozaris/jko-claude-plugins · 119 tokens

esp32-expert

This skill should be used for ESP32-specific hardware and runtime work in ESP-IDF, Arduino-ESP32, or PlatformIO projects: target/build detection, FreeRTOS tasks and ISRs, memory/DMA, peripherals, power, networking/security, OTA, crash diagnosis, and unattended reliability. Trigger on "debug this ESP32 crash", "review…

johnkozaris/jko-claude-plugins · 137 tokens