git-worktree-clean

git-worktree-clean is a skill for Claude Code from FlorianBruniaux/claude-code-plugins. It costs 19 tokens per session (1,827 once invoked), scanned A, original, MIT.

A cleanup tool for old Git worktrees, which are separate working directories linked to one repository. It finds merged and unmerged worktrees, reports their disk use, and removes selected ones.

In plain words
What is it for?
Preview cleanup, automatically remove merged worktrees, review unmerged ones interactively, and report the space reclaimed.
Why use it?
It helps reclaim disk space while giving extra review to worktrees whose branches still contain unmerged work.

Skill for Claude Code

Written for Claude Code: disable-model-invocation in frontmatter.

Part of the devops-pipeline plugin — 11 skills, 8 commands shipped together

Good fit Preview cleanup, automatically remove merged worktrees, review unmerged ones interactively, and report the space reclaimed.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/florianbruniaux/claude-code-plugins/git-worktree-clean
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 FlorianBruniaux/claude-code-plugins --skill git-worktree-clean
Clone the repo
git clone --depth 1 https://github.com/FlorianBruniaux/claude-code-plugins

Made for: Claude Code.

Or install devops-pipeline, the plugin that ships this one along with the rest of its 11 skills, 8 commands.

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-worktree-clean

README.md
[![agentmods](https://agentmods.dev/badge/skills/florianbruniaux/claude-code-plugins/git-worktree-clean/github.svg)](https://agentmods.dev/skills/florianbruniaux/claude-code-plugins/git-worktree-clean)
Your own site
<a href="https://agentmods.dev/skills/florianbruniaux/claude-code-plugins/git-worktree-clean"><img src="https://agentmods.dev/badge/skills/florianbruniaux/claude-code-plugins/git-worktree-clean/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-worktree-clean

Your own site · 80×15
<a href="https://agentmods.dev/skills/florianbruniaux/claude-code-plugins/git-worktree-clean"><img src="https://agentmods.dev/badge/skills/florianbruniaux/claude-code-plugins/git-worktree-clean.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 19 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,827 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. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 1 finding, up to medium

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • medium Excessive Agency · line 34
    Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.
    Fix: Add human-in-the-loop confirmation for destructive, irreversible, or high-impact operations. Never auto-execute commands that modify files, send data, or alter system state.
How audits are shown
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.00019 $0.01827
Opus 5.5 $0.00008 $0.00731
Sonnet 5.5 $0.00004 $0.00365
Haiku 4.5 $0.00002 $0.00183

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

Security

Grade A, and why

git-worktree-clean 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 1mo 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.

plugins/devops-pipeline/skills/git-worktree-clean/SKILL.md · 244 lines

How it starts

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

Git Worktree Clean

Batch cleanup of stale git worktrees. Safely removes merged branches, reports disk usage, and handles unmerged branches interactively.

Core principle: Auto-clean merged worktrees, interactive review for unmerged, always report what was reclaimed.

Part of: Worktree Lifecycle Suite | /git-worktree | /git-worktree-status | /git-worktree-remove

Process

  1. List All Worktrees: git worktree list
  2. Classify Each: merged vs unmerged vs protected
  3. Calculate Disk Usage: Per-worktree size
  4. Auto Mode: Remove all merged worktrees (safe)
  5. Interactive Mode: Review unmerged worktrees one by one
  6. Database Cleanup Reminder: List DB branches to clean
  7. Report: Summary of actions taken and space reclaimed

Flags

Flag Effect
--dry-run Preview what would be cleaned, no changes
--all Include unmerged worktrees (interactive confirmation each)
--force Remove all worktrees without confirmation (dangerous)

Worktree Discovery

# Get main branch name
MAIN_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')
MAIN_BRANCH=${MAIN_BRANCH:-main}

# Protected branches (never auto-clean)
PROTECTED="main master develop staging production"

# List all worktrees (skip main working tree)
git worktree list --porcelain | while read line; do
  # Parse worktree path and branch
  # Skip the main worktree (first entry)
done

Classification

for WORKTREE in $WORKTREES; do
  BRANCH=$(git -C "$WORKTREE" rev-parse --abbrev-ref HEAD)

  # Skip protected
  if echo "$PROTECTED" | grep -qw "$BRANCH"; then
    echo "PROTECTED: $BRANCH (skipped)"
    continue
  fi

  # Check merge status
  if git merge-base --is-ancestor "$BRANCH" "$MAIN_BRANCH" 2>/dev/null; then
    echo "MERGED: $BRANCH → safe to remove"
    MERGED_LIST="$MERGED_LIST $WORKTREE"
  else
    echo "UNMERGED: $BRANCH → requires review"
    UNMERGED_LIST="$UNMERGED_LIST $WORKTREE"
  fi
done

Read the full file on GitHub · 244 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. 1mo ago First seen · 244 lines · 19 tokens per session scan A 5e43d5265930

Subscribe to this mod's changes

git-worktree-clean is a skill published in the GitHub repository FlorianBruniaux/claude-code-plugins (42 stars, last pushed 1mo ago), licensed MIT. It adds 19 tokens to every session and 1,827 once invoked, about $0.0001 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-04.