agentleFS
dmzoneilldmzoneill/skills/cleanup-branches/SKILL.md

cleanup-branches

Skill2 starsChanged 19 days agoApache-2.0View on GitHub

Delete merged and stale feature branches. Use when cleaning up after closed issues/MRs, or when you have many old local branches. Fetches, lists branches, identifies candidates, deletes with confirmation.

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Delete merged/stale feature branches.

    line 8
  2. Very specific:

    Use repo or cwd; verify .git exists

    line 28
  3. Very specific:

    If dry run: skill_run("cleanup_branches", '{"dry_run": false}') to delete

    line 71
  4. Distinctive:

    Only first 3 branches deleted per run

    line 79

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Cleanup Branches

Delete merged/stale feature branches. Default: dry run (show only).

Inputs

InputTypeDefaultPurpose
repostringcwdRepository path
dry_runbooltrueShow what would be deleted (safety)
include_remoteboolfalseAlso delete remote branches
older_than_daysint30Stale threshold
protected_branchesstringmain,master,develop,releaseNever delete

Workflow

1. Load Persona

  • persona_load("developer")

2. Resolve Repository

  • Use repo or cwd; verify .git exists
  • Parse protected list from protected_branches

3. Fetch and List

  • git_fetch(repo, all=true, prune=true)
  • git_branch_list(repo, all=false) — local
  • git_branch_list(repo, all=true) — all (for remote refs)

4. Identify Candidates

  • Parse local branches, exclude current (*)
  • Exclude protected (main, master, develop, release)
  • Remote: remotes/origin/* excluding protected
  • Result: {candidates, candidate_count, remote_branches, current_branch}

5. Delete (if not dry_run)

  • git_branch_delete(repo, branch="{name}", force=false) — up to 3 per run for safety
  • Parse results: success vs error

6. Memory

  • If deleted > 0: memory_session_log("Cleaned up branches", "Deleted {count} in {repo}")
  • Learn pattern for branch_cleanups

7. Learn from Failures

  • Permission denied: learn_tool_fix("git_fetch", "permission denied", "SSH/creds", "ssh-add or check credentials")

MCP Tools

  • persona_load
  • git_fetch
  • git_branch_list
  • git_branch_delete
  • memory_session_log
  • learn_tool_fix

Output

  • Repository, current branch, mode (Dry Run / Delete)
  • Candidate branches list
  • If dry run: skill_run("cleanup_branches", '{"dry_run": false}') to delete
  • Deletion results (count, errors)
  • Protected branches list
  • Branch naming conventions, known issues

Safety

  • dry_run=true by default
  • Only first 3 branches deleted per run
  • Protected branches never touched

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.