git-cleanup

git-cleanup is a command for Claude Code from damusix/atomic-claude. It costs 63 tokens per session (2,776 once invoked), scanned C, original, MIT.

A command that scans a Git repository for stale worktrees, local branches, and optionally remote-tracking references. It reports candidates before asking what to remove.

In plain words
What is it for?
Use it to inspect repository clutter, review stale items, and clean selected local or remote-tracking Git references after approval.
Why use it?
It helps identify old Git state while requiring confirmation before cleanup actions that could remove branches or worktrees.

Command for Claude Code

Written for Claude Code: $ARGUMENTS substitution. Also seen: mentions subagents.

Good fit Use it to inspect repository clutter, review stale items, and clean selected local or remote-tracking Git references after approval.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/damusix/atomic-claude/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.

Clone the repo
git clone --depth 1 https://github.com/damusix/atomic-claude

Made for: Claude Code.

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

README.md
[![agentmods](https://agentmods.dev/badge/commands/damusix/atomic-claude/git-cleanup/github.svg)](https://agentmods.dev/commands/damusix/atomic-claude/git-cleanup)
Your own site
<a href="https://agentmods.dev/commands/damusix/atomic-claude/git-cleanup"><img src="https://agentmods.dev/badge/commands/damusix/atomic-claude/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 git-cleanup

Your own site · 80×15
<a href="https://agentmods.dev/commands/damusix/atomic-claude/git-cleanup"><img src="https://agentmods.dev/badge/commands/damusix/atomic-claude/git-cleanup.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 63 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,776 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. 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.00063 $0.02776
Opus 5.5 $0.00025 $0.01110
Sonnet 5.5 $0.00013 $0.00555
Haiku 4.5 $0.00006 $0.00278

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

Security

Grade C, and why

git-cleanup scanned grade C with 1 finding 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 12d 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.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

printf '%s\n' "$live" | grep -qx "$name" || rm -rf "$dir"
context/commands/git-cleanup.md · 240 lines

How it starts

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

You orchestrate git cleanup. The harness's default general agent runs atomic prompt git-cleanup (read-only scan). You present the report. The user picks. You execute.

Pre-flight

Outside a git repo the command refuses; inside one it records the two values the scout needs.

flowchart TD
    G{"Inside a git repo?"} -->|no| X["Refuse"]
    G -->|yes| B["Resolve base"]
    B --> W["Record current<br/>worktree"]
  • Inside a git repo?: git rev-parse --is-inside-work-tree. No: not in a git repo.

  • Resolve base: used by the scout: {{ template "base-resolution" . }}

  • Record current worktree: git rev-parse --show-toplevel. The scout must skip it from candidates.

Step 1 — Resolve staleness threshold

Default: 30 days.

Check user memory for an override. The harness's memory mechanism stores user preferences. Look for a memory entry whose description mentions "worktree", "branch", or "staleness" threshold. If found and it specifies a different value, use it. Otherwise, use 30.

If during execution the user says something like "remember N days as my staleness threshold" or "I prefer N days", save it to memory before continuing. Future runs pick it up automatically.

Step 2 — Determine scope

If arguments are given, target = the worktree that git worktree list --porcelain reports for branch $ARGUMENTS (branch + worktree inspected together; the branch alone when it has none) and skip to Step 4; otherwise target = all and continue to Step 3. Worktrees are enumerated with git worktree list, never a path glob, because their location depends on the resolved worktrees preference.

Step 3 — Ask about remote scope

Ask the user:

Question: Include remote branches in the staleness scan?
Options:
  - Local only (recommended) — scan every worktree git worktree list reports, and local branches
  - Local + remote — also fetch and flag stale remote branches (no remote deletion)

Default to local-only if the user is ambiguous.

Read the full file on GitHub · 240 lines

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. 12d ago Changed · -1 lines · +63 tokens per session 3756ee995a01
  2. 3mo ago First seen · 241 lines · 0 tokens per session scan C 9152680fdfe3

Subscribe to this mod's changes

git-cleanup is a command published in the GitHub repository damusix/atomic-claude (117 stars, last pushed 2d ago), licensed MIT. It adds 63 tokens to every session and 2,776 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

git-cleanup compared with commands from other repositories

git-cleanup next to 6 commands from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
git-cleanupdamusix/atomic-claudeCommand1172d agoMITC63Claude Code
worktreeFlorianBruniaux/claude-code-ultimate-guideCommand7.6kyesterdayCC-BY-SA-4.0A11Claude Code
agentloop-audit-queryalibaba/loongsuite-pilotCommand271yesterdayApache-2.0A20Claude Code
pull-repostravisjneuman/.claudeCommand1152d agoMITA13Claude Code
auto-claudetravisjneuman/.claudeCommand1152d agoMITA10Claude Code
address-pr-feedbackaxiomantic/spellbookCommand136d agoMITA43Claude Code
advanced-code-review-contextaxiomantic/spellbookCommand136d agoMITA19Claude Code