agentleFS
Miyamura80Miyamura80/MCP-Template/.claude/skills/cleanup/SKILL.md

cleanup

Skill1 starsChanged 5 months agoMITView on GitHub

Git branch hygiene - delete merged/closed branch, prune stale refs, sync dependencies

  • Installs packages

71 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use chips, react-query-best-practices and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • udecodeSkill

    chips

    Run the project's suggested-task ledger, the chips. /chips alone brings this session's open tasks up to date: it applies what the ledger helper says, settles stale and split tasks, cards what can start and reports the board, and /chips all also takes the ship-list tasks and the ones no live session owns, and merges duplicate tasks across the board. Use for /chips, /chips offer, start or drop, \"what chips are open\", \"suggest a task for X\", \"update the chips\", \"clean up the chips\", \"which chips are stale\", \"is this chip still worth doing\", \"merge duplicate chips\", at the last hand-back of a run that offered a task, and whenever pstack would file a tracked issue, a follow-up, a reflect Backlog item or an out-of-band PR.

    Also in 3 projects that use this

  • bibektimilsina00Skill

    react-query-best-practices

    Audit and fix React Query usage in apps/web — enforce query key factories, signal forwarding, staleTime, and proper mutation patterns. Use when reviewing or fixing server-state code.

    Also in 3 projects that use this

  • bibektimilsina00Skill

    you-might-not-need-a-callback

    Analyze and fix useCallback anti-patterns in your code

    Also in 3 projects that use this

  • Scylla23Skill

    redo

    Re-run the last routed task one model tier up (haiku → sonnet → opus → fable). User-invoked escalation when the previous result missed. Pass --dry-run to preview without running.

    Also in 3 projects that use this

  • Aetheria-Labs1Skill

    plan-page

    Plan one storefront page from strategy through final copy, section order, proof, offers, template direction, responsive layout, and production asset requirements. Stops at an approved execution-ready specification.

    Also in 3 projects that use this

  • SocialKit-APISkill

    video-transcripts

    Extract transcripts from social videos through SocialKit across YouTube, TikTok, Instagram, Facebook, X/Twitter, LinkedIn, and direct video file URLs. Use when the user asks to transcribe, get captions or subtitles, pull the spoken text, or read what a video says, including one video or many at once. Returns full text plus timestamped segments. Not for posting, private accounts, or unrelated website scraping.

    Also in 3 projects that use this

  • +3 more from bibektimilsina00

The file

Show its rules and text

We split this skill into the rules it gives an agent

14 rules. 0 are common, 8 are distinctive, and 6 are very specific to this project.

  • 0

    Common

    Most of the 61 edited versions we read keep these.

  • 8

    Distinctive

    This author's own choices. Worth a look.

  • 6

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If CURRENT_BRANCH is main or master:

    line 27
  2. Distinctive:

    If output is non-empty:

    line 37
  3. Distinctive:

    Stop and do not proceed.

    line 39
  4. Distinctive:

    If merged, proceed to step 5.

    line 48
  5. Distinctive:

    If not merged, check for closed PRs:

    line 50
  6. Distinctive:

    If closed (result is non-empty):

    line 55
  7. Distinctive:

    If neither merged nor closed:

    line 59
  8. Very specific:

    Check if the branch is merged locally: git branch --merged main | grep -w CURRENT_BRANCH

    line 60
  9. Very specific:

    If not merged anywhere, warn: "Branch 'CURRENT_BRANCH' does not appear to be merged or closed.

    line 61
  10. Very specific:

    If branch was MERGED:

    line 74
  11. Very specific:

    If branch was CLOSED (PR closed without merging):

    line 79
  12. Very specific:

    If uv.lock exists: uv sync

    line 116
  13. Distinctive:

    Dirty working tree: Stop immediately and ask user to commit/stash

    line 138
  14. Distinctive:

    No remote: If git pull fails due to no remote, continue with local operations

    line 142

“Common” is measured: kept by at least 6 in 10 of the 61 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

Git Cleanup Skill

Automates git branch hygiene after merging or closing PRs. Safely deletes merged branches (and force-deletes closed/abandoned branches), prunes stale remote tracking refs, syncs dependencies, and runs garbage collection.

Workflow

Execute these steps in order:

1. Check current branch

git branch --show-current

Store the result as CURRENT_BRANCH.

2. Guard against main/master

If CURRENT_BRANCH is main or master:

  • Report: "Already on main branch. No branch to clean up."
  • Skip to step 7 (pull latest) and continue from there.

3. Check for uncommitted changes

git status --porcelain

If output is non-empty:

  • Warn the user: "You have uncommitted changes. Please commit or stash them first."
  • Stop and do not proceed.

4. Check if branch is merged or closed

First check for merged PRs:

gh pr list --state merged --head CURRENT_BRANCH --json number

If merged, proceed to step 5.

If not merged, check for closed PRs:

gh pr list --state closed --head CURRENT_BRANCH --json number

If closed (result is non-empty):

  • Report: "Branch 'CURRENT_BRANCH' has a closed (unmerged) PR. Proceeding with deletion."
  • Proceed to step 5 (will use force delete in step 6).

If neither merged nor closed:

  • Check if the branch is merged locally: git branch --merged main | grep -w CURRENT_BRANCH
  • If not merged anywhere, warn: "Branch 'CURRENT_BRANCH' does not appear to be merged or closed. Use git branch -D manually if you want to force delete."
  • Stop and do not proceed.

Store whether the branch was MERGED or CLOSED for use in step 6.

5. Switch to main

git checkout main

6. Delete the branch

If branch was MERGED:

git branch -d CURRENT_BRANCH

If branch was CLOSED (PR closed without merging):

git branch -D CURRENT_BRANCH

Report: "Deleted branch CURRENT_BRANCH." (mention if force-deleted due to closed PR)

7. Pull latest

git pull origin main

8. Prune remote tracking refs

git fetch --prune

9. Delete stale local branches

Find and delete local branches whose upstream is gone:

git for-each-ref --format '%(refname:short) %(upstream:track)' refs/heads | while read branch track; do
  if [ "$track" = "[gone]" ]; then
    git branch -d "$branch" 2>/dev/null && echo "Deleted stale branch: $branch"
  fi
done

Report any branches deleted.

10. Sync dependencies

Detect package manager and sync:

  • If uv.lock exists: uv sync
  • Else if bun.lockb exists: bun install
  • Else if package-lock.json exists: npm install
  • Else if requirements.txt exists: pip install -r requirements.txt
  • Else: Skip dependency sync

11. Git garbage collection

git gc --prune=now

12. Summary

Report completion:

  • Branch deleted (if applicable)
  • Number of stale branches pruned
  • Dependencies synced (which package manager)
  • Garbage collection complete

Error Handling

  • Dirty working tree: Stop immediately and ask user to commit/stash
  • Branch not merged or closed: Warn and stop - never force delete without explicit user request
  • Branch closed (not merged): Force delete with -D since branch is abandoned
  • Already on main: Skip branch deletion, continue with pull/prune/gc
  • No remote: If git pull fails due to no remote, continue with local operations
  • gh CLI not available: Fall back to git branch --merged check

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.