cleanup-local-branches

cleanup-local-branches is a skill for Claude Code, Codex from pekral/cursor-rules. It costs 65 tokens per session (2,036 once invoked), scanned A, original, MIT.

A cleanup procedure for local Git branches that are no longer active. Git branches are separate lines of work; this removes local ones whose remote branch was deleted or that have been inactive for over six months.

In plain words
What is it for?
Use it after remote branch pruning to preview and delete obsolete local branches. It never deletes branches from the shared remote repository.
Why use it?
It reduces clutter in a developer's working copy while protecting the current branch and important branches such as main and release branches.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it after remote branch pruning to preview and delete obsolete local…

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/pekral/cursor-rules/cleanup-local-branches
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 pekral/cursor-rules --skill cleanup-local-branches
Clone the repo
git clone --depth 1 https://github.com/pekral/cursor-rules

Made for: Claude Code, Codex.

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-local-branches

README.md
[![agentmods](https://agentmods.dev/badge/skills/pekral/cursor-rules/cleanup-local-branches.svg)](https://agentmods.dev/skills/pekral/cursor-rules/cleanup-local-branches)
Your own site
<a href="https://agentmods.dev/skills/pekral/cursor-rules/cleanup-local-branches"><img src="https://agentmods.dev/badge/skills/pekral/cursor-rules/cleanup-local-branches.svg" alt="Measured on agentmods" height="20"></a>
Per session 65 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,036 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.
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.00065 $0.02036
Opus 5 $0.00032 $0.01018
Sonnet 5 $0.00013 $0.00407
Haiku 4.5 $0.00006 $0.00204

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

Security

Grade A, and why

cleanup-local-branches 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.

skills/cleanup-local-branches/SKILL.md · 145 lines

How it starts

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

Cleanup Local Branches

Purpose

Prune dead local branches so the working copy only keeps branches that are still alive on origin or still recently active.

Two deletion categories:

  • Gone — local branches whose upstream tracking branch was deleted on origin (e.g. the PR was merged and the origin branch removed).
  • Stale — local branches that have no counterpart on origin and have not received a commit for more than six months.

Constraints

  • Apply @rules/git/general.mdc
  • Output must be in English
  • This skill deletes local refs only — it never deletes, force-pushes, or modifies any branch on origin
  • Never delete the currently checked-out branch
  • Never delete protected branches: main, master, develop, development, production, staging, or any branch matching release/* or hotfix/*
  • Always print the full deletion preview (branch, category, last commit date, integration status, planned action) before deleting anything
  • Never rewrite history, force-push, or run git gc / git reflog expire
  • Determine integration status by patch identity against the default branch (git cherry), so squash- and rebase-merged branches are recognized as integrated
  • Never delete a stale branch that is not integrated into the default branch automatically — keep it and report it unless the user explicitly authorizes force deletion (its commits never reached origin and are unrecoverable)

Use when

  • The user asks to clean up, prune, or "pročistit" local branches that no longer exist on origin
  • Local branches piled up after their pull requests were merged and the origin branches were deleted
  • The repository accumulated old experiment branches that were never pushed and are no longer needed

Execution

1. Refresh remote state

Update remote-tracking refs and prune deleted ones so the gone markers and origin counterparts are accurate:

git fetch --prune origin

If the repository has no origin remote, stop and report that the skill needs an origin remote to decide which branches are alive.

Read the full file on GitHub · 145 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 · 145 lines · 65 tokens per session scan A dd4256a27fb7

Subscribe to this mod's changes

cleanup-local-branches is a skill published in the GitHub repository pekral/cursor-rules (6 stars, last pushed 6d ago), licensed MIT. It adds 65 tokens to every session and 2,036 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.

Related

Other skills, from other repositories

git-advanced-workflows

Master advanced Git workflows including rebasing, cherry-picking, bisect, worktrees, and reflog to maintain clean history and recover from any situation. Use when managing complex Git histories, collaborating on feature branches, or troubleshooting repository issues.

wshobson/agents · 54 tokens

workflow-patterns

Use this skill when implementing tasks according to Conductor's TDD workflow, handling phase checkpoints, managing git commits for tasks, or understanding the verification protocol.

wshobson/agents · 35 tokens

chinese-commit-conventions

A Chinese-language guide to Conventional Commits, a format for writing consistent Git commit messages, plus related changelog, commit-checking, and commit-helper configuration.

jnMetaCode/superpowers-zh · 65 tokens

managing-git

Manages Git workflows including branching, commits, and pull requests. Use when working with Git, creating commits, opening PRs, managing branches, resolving conflicts, or when asked about version control best practices.

CloudAI-X/claude-workflow-v2 · 46 tokens

share-a-library

Use when a managed library is ready to publish to GitHub and hand to teammates as an install command. Run the GitHub publishing steps, then return the exact shareable install command.

MoizIbnYousaf/Ai-Agent-Skills · 41 tokens

devops/changelog-generation

A method for creating a CHANGELOG, a document that records what changed in each software release. It reads Git commit history and release-pipeline reports, then groups changes using common commit and changelog conventions.

echoVic/boss-skill · 36 tokens