git-worktree-remove

git-worktree-remove is a skill for Claude Code from FlorianBruniaux/claude-code-plugins. It costs 18 tokens per session (1,482 once invoked), scanned C, original, MIT.

A Git cleanup tool that removes a separate working directory and can clean up its local and remote branch. It checks for unmerged commits and unsaved changes first.

In plain words
What is it for?
Remove finished worktrees, delete their branches after confirmation, prune stale Git references, and identify related database branches that may need cleanup.
Why use it?
It helps prevent accidental loss of work or removal of important branches when closing a feature checkout.

Skill for Claude Code

Written for Claude Code: disable-model-invocation in frontmatter. Also seen: positional $N argument.

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

Good fit Remove finished worktrees, delete their branches after confirmation, prune stale Git references, and identify related database branches that may need cleanup.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/florianbruniaux/claude-code-plugins/git-worktree-remove
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-remove
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-remove

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

Your own site · 80×15
<a href="https://agentmods.dev/skills/florianbruniaux/claude-code-plugins/git-worktree-remove"><img src="https://agentmods.dev/badge/skills/florianbruniaux/claude-code-plugins/git-worktree-remove.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 18 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,482 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.00018 $0.01482
Opus 5.5 $0.00007 $0.00593
Sonnet 5.5 $0.00004 $0.00296
Haiku 4.5 $0.00002 $0.00148

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

Security

Grade C, and why

git-worktree-remove 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 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.

Recursive force deletehighDestructive command

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

**Using `rm -rf` instead of `git worktree remove`**
plugins/devops-pipeline/skills/git-worktree-remove/SKILL.md · 193 lines

How it starts

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

Git Worktree Remove

Safely remove a single git worktree with branch cleanup, merge verification, and database branch teardown.

Core principle: Safety checks first, then clean removal of worktree + branch + DB resources.

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

Process

  1. Validate Target: Identify worktree to remove
  2. Safety Check: Protect main/develop branches
  3. Check Merge Status: Warn if branch has unmerged changes
  4. Check Uncommitted Changes: Warn if worktree has dirty state
  5. Remove Worktree: git worktree remove
  6. Delete Local Branch: git branch -d (or -D with confirmation)
  7. Delete Remote Branch: git push origin --delete (with confirmation)
  8. Database Cleanup Reminder: Suggest DB branch deletion if applicable
  9. Prune References: git worktree prune

Safety Checks

Protected Branches

# Never remove worktrees for these branches (configurable)
PROTECTED_BRANCHES="main master develop staging production"

if echo "$PROTECTED_BRANCHES" | grep -qw "$BRANCH"; then
  echo "BLOCKED: Cannot remove worktree for protected branch '$BRANCH'"
  echo "Protected branches: $PROTECTED_BRANCHES"
  exit 1
fi

Uncommitted Changes

cd "$WORKTREE_PATH"
if [ -n "$(git status --porcelain)" ]; then
  echo "WARNING: Worktree has uncommitted changes:"
  git status --short
  echo ""
  echo "Options:"
  echo "  1. Commit changes first"
  echo "  2. Force remove (--force)"
  echo "  3. Cancel"
  # Wait for user decision
fi

Merge Status

# Check if branch is merged into main
MAIN_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')

if git merge-base --is-ancestor "$BRANCH" "$MAIN_BRANCH" 2>/dev/null; then
  echo "Branch '$BRANCH' is merged into $MAIN_BRANCH. Safe to delete."
  MERGED=true
else
  echo "WARNING: Branch '$BRANCH' is NOT merged into $MAIN_BRANCH."
  echo "You may lose work if you delete this branch."
  MERGED=false
fi

Read the full file on GitHub · 193 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 · 193 lines · 18 tokens per session scan C 9a95779fad03

Subscribe to this mod's changes

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