merge-and-cleanup

merge-and-cleanup is a skill for Claude Code from ericboehs/claude-plugins. It costs 57 tokens per session (1,116 once invoked), scanned A, original, MIT.

A Git workflow command for merging a pull request, which is a proposed set of code changes, and then removing the related branch and worktree. A worktree is a separate local directory linked to the same Git repository.

In plain words
What is it for?
Use it to squash-merge a pull request, delete its branch, switch to the default branch, pull the latest changes, and remove an associated worktree when appropriate.
Why use it?
It gathers several cleanup steps into one guided workflow after code review is complete.

Skill for Claude Code

Written for Claude Code: disable-model-invocation in frontmatter. Also seen: names the AskUserQuestion tool.

Part of the git-utils plugin — 2 skills 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/ericboehs/claude-plugins/merge-and-cleanup
Any agent
npx skills add ericboehs/claude-plugins --skill merge-and-cleanup
Clone the repo
git clone --depth 1 https://github.com/ericboehs/claude-plugins

Made for: Claude Code.

Or install git-utils, the plugin that ships this one along with the rest of its 2 skills.

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 merge-and-cleanup

README.md
[![agentmods](https://agentmods.dev/badge/skills/ericboehs/claude-plugins/merge-and-cleanup.svg)](https://agentmods.dev/skills/ericboehs/claude-plugins/merge-and-cleanup)
Your own site
<a href="https://agentmods.dev/skills/ericboehs/claude-plugins/merge-and-cleanup"><img src="https://agentmods.dev/badge/skills/ericboehs/claude-plugins/merge-and-cleanup.svg" alt="Measured on agentmods" height="20"></a>
Per session 57 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,116 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.00057 $0.01116
Opus 5 $0.00028 $0.00558
Sonnet 5 $0.00011 $0.00223
Haiku 4.5 $0.00006 $0.00112

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

Security

Grade A, and why

merge-and-cleanup 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.

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/git-utils/skills/merge-and-cleanup/SKILL.md · 118 lines

How it starts

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

Merge and Cleanup

Merge the current branch's PR via squash merge, delete the remote branch, switch to main, pull, and clean up the worktree if applicable.

Workflow

Step 1: Detect context

Run these commands to understand the current state:

# Get current branch
BRANCH=$(git branch --show-current)
echo "Branch: $BRANCH"

# Check if on main/master
DEFAULT_BRANCH=$(git remote show origin | sed -n 's/.*HEAD branch: //p')
if [ -z "$DEFAULT_BRANCH" ]; then
  DEFAULT_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's|refs/remotes/origin/||')
fi
echo "Default branch: $DEFAULT_BRANCH"

# Check for uncommitted changes
git status --porcelain

# Check if in a worktree
GIT_DIR=$(git rev-parse --git-dir)
GIT_COMMON_DIR=$(git rev-parse --git-common-dir)
echo "git-dir: $GIT_DIR"
echo "git-common-dir: $GIT_COMMON_DIR"
  • If DEFAULT_BRANCH is empty, report "Could not determine the default branch — check that the origin remote is configured" and stop.
  • If BRANCH equals DEFAULT_BRANCH (main/master), report "Already on the default branch, nothing to merge" and stop.
  • If git status --porcelain has output, warn the user about uncommitted changes and ask whether to proceed.
  • If GIT_DIR != GIT_COMMON_DIR, we're in a worktree. Note the current worktree path (pwd) and the main repo path (parent of GIT_COMMON_DIR).

Step 2: Find and merge the PR

# Look up PR for this branch
gh pr view --json state,number,title,mergeStateStatus,statusCheckRollup
  • If no PR exists, tell the user and suggest creating one with gh pr create. Stop.
  • If the PR state is not OPEN, tell the user the PR is already closed/merged. Stop.
  • If mergeStateStatus is BLOCKED or status checks are failing, warn the user and ask whether to proceed anyway.
  • If everything looks good, merge:
gh pr merge --squash --delete-branch

If the merge fails, report the error and stop. Note: when in a worktree, --delete-branch may warn about failing to delete the local branch (since it's checked out). This is expected — the local branch will be cleaned up when the worktree is removed in Step 4. Only treat it as a failure if the merge itself fails.

Read the full file on GitHub · 118 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. 6d ago First seen · 118 lines · 57 tokens per session scan A 2c37c132b1f4

Subscribe to this mod's changes

merge-and-cleanup is a skill published in the GitHub repository ericboehs/claude-plugins (2 stars, last pushed 12d ago), licensed MIT. It adds 57 tokens to every session and 1,116 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-31.