Skip to content
Back to skills

Sweep Branches

ASecurity

Reclaim merged-but-undeleted local and remote branches. Deletes by default; --dry-run to preview.

  • 3 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 7, 2026
ai-agentsbashgitapi

Works with

  • api

Security analysis

A100/100

Scanned November 7, 2026

npx -y skills add nirecom/agents --skill sweep-branches --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Sweep Branches?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Sweep Branches
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nirecom-sweep-branches/badge)](https://www.skillsdirectory.com/skills/nirecom-sweep-branches)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: sweep-branches
description: Reclaim merged-but-undeleted local and remote branches. Deletes by default; --dry-run to preview.
user-invocable: true
model: sonnet
context: fork
---

Reclaims merged-but-undeleted local and remote branches. Local branches are
age-gated (default 24 h); remote branches are only PR-merged checked. Protected
branches (`main`, `master`, `develop`, `release/*`) are never deleted.

## Procedure

SB-1. Resolve `$AGENTS_MAIN_ROOT` from the environment; abort with a clear error
   if unset.
SB-2. Invoke the sweeper script (no flag = deletes; `--dry-run` = preview):
   `bash "$AGENTS_MAIN_ROOT/bin/sweep-branches.sh" [--dry-run] [--min-age-hours N] [--ci-mode]`
SB-3. Print the script's stdout verbatim. Do not summarize or filter.

Forward the user's flags verbatim. Add no flags of your own.

## Rules

- Deletes by default; `--dry-run` must be explicit to preview only.
- `--delete-no-pr` alone deletes no-PR local branches; add `--dry-run` to preview.
- Remote branches use `gh api -X DELETE` (REST API); local branches use `git branch -D` with `SWEEP_BRANCHES_SKILL=1` guard.
- Remote branches are not age-gated (only PR-merged check); local branches are age-gated via `--min-age-hours`.
- `main`, `master`, `develop`, `release/*` are never deleted.
- Non-GitHub remotes are skipped (non-fatal).
- Per-branch failures are non-fatal: warning printed, sweep continues.
- After remote deletion, local tracking refs (`origin/<branch>`) persist until `git fetch --prune`.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.