
branch-cleanup
Report stale git branches with a keep, archive, or delete recommendation, and propose enabling delete-branch-on-merge. Use for "clean up stale branches", "delete merged branches", "delete branch on merge", "which branches are dead", or /branch-cleanup. Checks age, author, ahead/behind counts, merged status, open pull requests, and ruleset protection, then prints exact deletion commands that require explicit per-batch authorization before any push. Do NOT use for local git worktree management (worktree add, list, or prune) — that stays out of scope. One-time repository merge defaults and branch-protection rulesets belong to /gh-bootstrap; this skill reads and reports on that state but does not set it up.
- Installs
- 53
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/paulnsorensen/git-gouda --skill branch-cleanup- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads branch-cleanup automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
branch-cleanup
Report stale remote branches and propose safe deletion. Never delete a branch without explicit authorization for that batch.
What this skill is NOT for
- Local git worktree management (
git worktree add,list,prune) — out of scope. - One-time repository merge-default and branch-protection setup — use
/gh-bootstrap. This skill only readsdelete_branch_on_mergeand existing rulesets; it proposes turning the setting on but the write happens throughgh api -X PATCH, the same endpoint/gh-bootstrapuses in its step 2.
Protocol
1. Check delete-branch-on-merge
REPO="$(gh repo view --json nameWithOwner --jq '.nameWithOwner')"
gh api "repos/$REPO" --jq '.delete_branch_on_merge'
If false, propose enabling it and explain the effect: GitHub deletes a branch's remote
ref automatically once its pull request merges. Ask for explicit authorization before
running the gh api -X PATCH repos/{owner}/{repo} -F delete_branch_on_merge=true write —
see /gh-bootstrap step 2 for the full merge-defaults PATCH, which this skill does not
duplicate.
2. Report stale branches
Run the bundled script from the repository root:
python3 "$BRANCH_CLEANUP_HELPER" --days 90 --github "$REPO"
Resolve BRANCH_CLEANUP_HELPER from the loaded SKILL.md directory
(scripts/stale_branches.py), resolving symlinks first. For each remote branch the script
reports:
- Last commit date and author (
git log -1). - Ahead/behind counts against the default branch (
git rev-list --left-right --count). - Merged status (
git branch -r --merged <default>). - Whether an open pull request targets the branch (
gh pr list --head <branch> --state open --json number), when--githubis passed. - Whether a ruleset protects the branch (
gh api repos/{owner}/{repo}/rules/branches/ {branch}), when--githubis passed.
The output is a table sorted by age (oldest first) with a recommendation column of
keep, archive, or delete. See references/policy.md for the exact classification
rule.
3. Local hygiene
Report-only, no deletion:
git fetch --prune
git branch --merged <default>
List the locally merged branches for the user. Do not delete local branches without the same per-batch authorization required in step 4.
4. Deletion is never automatic
For every branch classified delete, print the exact command:
git push origin --delete <branch>
Always exclude the default branch, any protected branch, and any branch with an open pull
request from deletion — the script enforces this by classifying those branches keep
regardless of age. Require explicit user authorization before running any printed command,
and confirm the authorized batch matches the printed list exactly.
5. Optional scheduled report workflow
Copy assets/stale-branch-report.yml to .github/workflows/stale-branch-report.yml if the
user wants a recurring report. It only writes a job summary — it never deletes a branch.
actions/checkout is pinned by SHA.
6. Verify
Re-run the script and confirm the printed table matches the branches actually present on
the remote (git branch -r). Confirm no delete recommendation includes the default
branch, a protected branch, or a branch with an open pull request.
Cross-references
/gh-bootstrap— one-time repository merge defaults and branch-protection rulesets./prek— local pre-commit hook checks, unrelated to branch lifecycle./oss-hygiene— broader repository health, including community-standards files.
FAQ
What does the branch-cleanup skill do?
Report stale git branches with a keep, archive, or delete recommendation, and propose enabling delete-branch-on-merge. Use for "clean up stale branches", "delete merged branches", "delete branch on merge", "which branches are dead", or /branch-cleanup. Checks age, author, ahead/behind counts, merged status, open pull requests, and ruleset protection, then prints exact deletion commands that require explicit per-batch authorization before any push. Do NOT use for local git worktree management (worktree add, list, or prune) — that stays out of scope. One-time repository merge defaults and branch-protection rulesets belong to /gh-bootstrap; this skill reads and reports on that state but does not set it up.
How do I install branch-cleanup?
Run npx skills add https://github.com/paulnsorensen/git-gouda --skill branch-cleanup in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/branch-cleanup/ (personal) or .claude/skills/branch-cleanup/ (project).
Which AI agents can use branch-cleanup?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is branch-cleanup safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains branch-cleanup?
It is published by paulnsorensen in paulnsorensen/git-gouda. It has 53 recorded installs.
More from paulnsorensen/git-gouda
config-review-bot
paulnsorensen/git-gouda
Audit or configure CodeRabbit repository review policy from effective sources. Use for CodeRabbit setup, configuration review, path coverage, or a specific pull-request review audit. Trigger on "configure CodeRabbit", "review .coderabbit.yaml", "set up CodeRabbit", "audit CodeRabbit settings", or "is CodeRabbit covering X". Keep audits read-only by default and separate schema validity, rule quality, and completed-review evidence. Do not use it to run a CodeRabbit CLI review or autofix, or to fix review comments on a pull request.
safe-settings
paulnsorensen/git-gouda
Set up GitHub's safe-settings (a Probot-based GitHub App from the github org) for declarative, org-wide repository policy as code. Use when the user says "settings as code", "safe-settings", "manage repos declaratively", "centralize repo settings", "org-level branch protection", "scaffold an admin repo", "github settings app", or invokes /safe-settings on an org that wants to manage repo settings, branch protection, rulesets, labels, teams, environments, and collaborators from one admin repo. Scaffolds the admin-repo layout (settings.yml + suborgs/ + repos/), the GitHub App installation steps, and a scheduled full-sync GitHub Actions workflow. Distinct from /gh-bootstrap (one-shot gh api config of a single repo) — this skill is for org-scale settings as code that reconciles continuously. Not for per-task GitHub ops (PRs, issues, CI status) or local git work — those are out of this catalog's scope.
gh-bootstrap
paulnsorensen/git-gouda
One-time GitHub repository configuration via the gh CLI: lock the default branch with PR and CI rules, optionally enable a supported merge queue, lock merging to squash-only with PR-title commit messages, scaffold automatically-generated release notes (.github/release.yml), and optionally add a tag-driven release workflow. Use when the user says "set up the repo", "configure the merge queue", "enable squash merging", "lock down main", "set up branch protection", "configure release notes", "scaffold releases", "set up release tagging", or invokes /gh-bootstrap on a fresh or loosely-configured GitHub repository. Idempotent — safe to re-run on already-configured repos to bring missing pieces in line. This skill covers one-time repo policy, not per-task GitHub operations, local git commands, or project task running.
prek
paulnsorensen/git-gouda
Onboard prek (Rust-powered pre-commit) into any project and suggest hooks tailored to the language/framework. Use when the user says "add prek", "set up pre-commit hooks", "configure prek", "what hooks should I use", or when you notice a project without a prek.toml that would benefit from pre-commit checks. Also trigger when the user wants to add new hooks to an existing prek.toml, audit their hook config, or migrate from pre-commit to prek. Covers Rust, Python, TypeScript/JavaScript, Go, Ruby, and Shell projects. Do NOT use for husky, lint-staged, or CI pipeline hook configuration — this skill is specifically for prek.
oss-hygiene
paulnsorensen/git-gouda
Bring an open-source GitHub repository up to community-standards and supply-chain hygiene baseline: scaffold the GitHub Community Standards files (README check, LICENSE, CODEOFCONDUCT, CONTRIBUTING, SECURITY, issue + PR templates), wire Dependabot version updates, the Dependency Review action, OpenSSF Scorecard, and CodeQL (when applicable), check Dependabot alerts and secret scanning, and add the OpenSSF Best Practices Badge link. Use when the user says "set up OSS hygiene", "make this repo open-source-ready", "add community health files", "wire dependabot", "add scorecard", "OSSF badge", "supply chain hardening", or invokes /oss-hygiene on a public repo. Idempotent — safe to re-run; diffs against templates and asks before overwriting. Distinct from /gh-bootstrap (merge-button + branch protection) and /safe-settings (org-scale settings as code): focuses on the contributor-facing and supply-chain surface, not merge or org policy. Run after /gh-bootstrap; before announcing the repo.
github-copilot-repo-instructions
paulnsorensen/git-gouda
Add, audit, or fix GitHub Copilot repository custom instructions — .github/copilot-instructions.md (repo-wide) and .github/instructions/.instructions.md (path-specific) — so Copilot Chat, Copilot code review, and the Copilot coding agent all pick up project-wide guidance. Also covers AGENTS.md, CLAUDE.md, and GEMINI.md as alternate agent instruction files. Use when the user says "add Copilot instructions", "set up copilot-instructions.md", "audit our Copilot config", "make Copilot follow our conventions", "configure Copilot code review", "add path-specific Copilot rules", "applyTo glob", "excludeAgent", "Copilot is ignoring our guidance", or invokes /github-copilot-repo-instructions. Do NOT use for personal (per-user) Copilot instructions; those are out of scope for this skill. For AGENTS.md authoring guidance beyond file layout, see the agents-md skill.
Popular code quality & workflow skills
grill-me
mattpocock/skills
A relentless interview to sharpen a plan or design.
improve-codebase-architecture
mattpocock/skills
Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
handoff
mattpocock/skills
Compact the current conversation into a handoff document for another agent to pick up.
domain-modeling
mattpocock/skills
Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.
codebase-design
mattpocock/skills
Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.
diagnosing-bugs
mattpocock/skills
Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.