cleanup-merged

cleanup-merged is a skill for Claude Code from uta2000/feature-flow. It costs 64 tokens per session (2,945 once invoked), scanned C, original, MIT.

A cleanup tool for removing worktrees, branches, and handoff files linked to merged or closed GitHub pull requests.

In plain words
What is it for?
Cleaning up one pull request or scanning the repository for all completed pull requests.
Why use it?
It prevents finished work from leaving unused local and remote Git files behind.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the feature-flow plugin — 12 skills, 1 agent, 4 hooks shipped together

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/uta2000/feature-flow/cleanup-merged
Any agent
npx skills add uta2000/feature-flow --skill cleanup-merged
Clone the repo
git clone --depth 1 https://github.com/uta2000/feature-flow

Made for: Claude Code.

Or install feature-flow, the plugin that ships this one along with the rest of its 12 skills, 1 agent, 4 hooks.

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-merged

README.md
[![agentmods](https://agentmods.dev/badge/skills/uta2000/feature-flow/cleanup-merged.svg)](https://agentmods.dev/skills/uta2000/feature-flow/cleanup-merged)
Your own site
<a href="https://agentmods.dev/skills/uta2000/feature-flow/cleanup-merged"><img src="https://agentmods.dev/badge/skills/uta2000/feature-flow/cleanup-merged.svg" alt="Measured on agentmods" height="20"></a>
Per session 64 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,945 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. 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.00064 $0.02945
Opus 5 $0.00032 $0.01473
Sonnet 5 $0.00013 $0.00589
Haiku 4.5 $0.00006 $0.00295

Measured 5d ago against content hash 1f052a394ae2, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade C, and why

cleanup-merged 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 5d 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.

rm -rf "<worktree_path>"
skills/cleanup-merged/SKILL.md · 268 lines

How it starts

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

Cleanup Merged — Post-Merge Worktree Reclaimer

Remove the local artifacts (worktree, local branch, remote branch, handoff file) that were created for a feature branch once its PR is merged or closed.

Announce at start: "Running cleanup-merged to reclaim worktrees and branches for merged PRs..."


Invocation

Argument pattern Behavior
cleanup-merged <pr-number> Clean up exactly one PR's handoff
cleanup-merged (no argument) Scan .feature-flow/handoffs/*.yml, clean up every handoff whose PR is MERGED or CLOSED

Process

Step 1: Resolve handoff files to process

CWD to base repo first. Handoff files live at .feature-flow/handoffs/ relative to the base repo root. If this skill is invoked from inside a worktree (or any other subdirectory), relative paths in the subsequent discovery would silently miss the handoffs. Resolve the base repo root up front and cd there:

BASE_REPO=$(git rev-parse --show-toplevel 2>/dev/null || git rev-parse --git-common-dir 2>/dev/null | xargs dirname)
if [ -z "$BASE_REPO" ] || [ ! -d "$BASE_REPO/.feature-flow/handoffs" ]; then
  echo "cleanup-merged: no base repo or no .feature-flow/handoffs/ directory — nothing to clean up."
  exit 0
fi
cd "$BASE_REPO"

If a specific PR number was provided:

ls .feature-flow/handoffs/<pr-number>.yml 2>/dev/null

If the file does not exist, announce: cleanup-merged: no handoff found for PR #<pr-number> — nothing to clean up. Exit cleanly.

If no argument was provided (batch mode):

Use find (not ls) to avoid literal-pattern pitfalls under nullglob unset:

find .feature-flow/handoffs -maxdepth 1 -type f -name '*.yml' 2>/dev/null

If no files match, announce: cleanup-merged: no handoff files found — nothing to clean up. Exit cleanly (this is the expected no-op path when no sessions have completed).

Exclude .feature-flow/handoffs/.log from the list (it is not a handoff YAML file).

Read the full file on GitHub · 268 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. 5d ago First seen · 268 lines · 0 tokens per session scan C 1f052a394ae2

Subscribe to this mod's changes

cleanup-merged is a skill published in the GitHub repository uta2000/feature-flow (4 stars, last pushed 2mo ago), licensed MIT. It adds 64 tokens to every session and 2,945 once invoked, about $0.0003 per session on Opus 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-31.