agentleFS
OpenRouterLabsOpenRouterLabs/spawn/.claude/skills/pcl/SKILL.md

pcl

Skill251 starsChanged 5 months agoApache-2.0View on GitHub

Delete stale git branches (local + remote) that have no open PR, and prune worktrees.

  • Deletes or force-pushes
  • Commits and pushes

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 1

    1. OpenRouterTeam/spawn★ 251100% same

    Edited · 0

    None found.

    Wrote their own version · 0

    None found.

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository9 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    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 local and remote git branches that no longer have an open PR, and prune stale worktrees.

    line 10
  2. Very specific:

    If --dry-run was passed, print [dry-run] would delete origin/BRANCH_NAME instead.

    line 61
  3. Very specific:

    If --dry-run, print [dry-run] would delete local BRANCH_NAME instead.

    line 77
  4. Distinctive:

    Remove any leftover worktree directories:

    line 85
  5. Distinctive:

    Ensure we're on main branch:

    line 93

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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 Stale Branches

Delete local and remote git branches that no longer have an open PR, and prune stale worktrees.

Arguments

  • --dry-run — List what would be deleted without actually deleting anything.

$ARGUMENTS

Procedure

Step 1: Checkout main branch

Switch to main and update to latest:

git checkout main
git pull --rebase origin main

Critical: This ensures we're not on a branch that's about to be deleted, and that we're working from the latest main.

Step 2: Fetch and prune remote refs

git fetch --prune origin

Step 3: Identify stale remote branches

List all remote branches except main and HEAD:

git branch -r --format='%(refname:short) %(committerdate:relative)' | grep -v 'origin/main\|origin/HEAD\|^origin '

Step 4: Get branches with open PRs (protected)

gh pr list --repo OpenRouterLabs/spawn --state open --json headRefName --jq '.[].headRefName'

Any branch with an open PR MUST be skipped. Never delete a branch that has an open PR.

Step 5: Delete stale remote branches

For each remote branch that is NOT in the open PR list:

git push origin --delete BRANCH_NAME

If --dry-run was passed, print [dry-run] would delete origin/BRANCH_NAME instead.

Step 6: Delete stale local branches

List local branches (excluding the current branch and main):

git branch --list | grep -v '^\*' | grep -v '^ *main$' | tr -d ' '

For each, check if it's already merged into main or has no remote:

git branch -d BRANCH_NAME 2>/dev/null || git branch -D BRANCH_NAME

If --dry-run, print [dry-run] would delete local BRANCH_NAME instead.

Step 7: Prune worktrees

git worktree prune

Remove any leftover worktree directories:

rm -rf /tmp/spawn-worktrees 2>/dev/null || true

Step 8: Verify final state

Ensure we're on main branch:

git branch --show-current

Should output: main

Step 9: Summary

Print a summary:

  • Number of remote branches deleted
  • Number of local branches deleted
  • Number of branches skipped (had open PRs)
  • Worktree prune status

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.