Git Cleanup logo

Git Cleanup

Organization
SpecterOps
git-cleanup

Repository hygiene — prune merged/stale branches, detect orphans, repo health checks. Use when cleaning up branches, checking repo health, or scanning projects.

Overview

PublisherSpecterOps
Repositoryskills
Skill namegit-cleanup
Stars
706
Forks
80
Bundled files
3
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 3 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by SpecterOps on GitHub. Read the source before you install it.

Installation

Install the Git Cleanup AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/SpecterOps/skills/tree/main/plugins/workflows-development/skills/git-cleanup
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/SpecterOps/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/plugins/workflows-development/skills/git-cleanup .claude/skills/git-cleanup
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Git Cleanup in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Git Cleanup on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Git Cleanup is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Git Repository Cleanup

Repository hygiene: prune branches, detect stale work, and check repo health.

Parse the user's input to determine the action:

  • $git-cleanup or $git-cleanup branches — find and prune merged/stale branches
  • $git-cleanup stale [days] — branches with no commits in N days (default 30)
  • $git-cleanup health — large files, dangling refs, worktrees, repo size
  • $git-cleanup all — scan all git repos under ~/Projects/

Prerequisites

  1. Verify we're in a git repository (git rev-parse --is-inside-work-tree) — except for all action which scans directories
  2. If not in a git repo (and not using all), tell the user and stop

Protected Branches

The following branches are NEVER suggested for deletion: main, master, develop

Action: branches (default)

  1. Fetch latest remote state: git fetch --prune
  2. Identify the default branch (git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null or fall back to main/master)
  3. Find merged branches:
    • git branch --merged <default> — local branches already merged into default
    • Exclude protected branches and current branch
  4. Find branches with deleted remotes:
    • git branch -vv — look for [origin/...: gone] entries
  5. Present findings as a dry-run preview:
    • List branches that can be safely deleted (merged)
    • List branches whose remote is gone
    • Show last commit date and message for each
  6. Ask the user which branches to delete (or "all listed")
  7. On confirmation, delete with git branch -d <branch> (safe delete)
  8. If a branch fails -d (unmerged), warn the user and offer -D with explicit explanation that commits may be lost — only proceed with user confirmation

Action: stale [days]

  1. Default to 30 days if no argument provided
  2. For each local branch (excluding protected branches):
    • Get last commit date: git log -1 --format='%ci' <branch>
    • Calculate age in days
  3. List branches older than the threshold, sorted by age (oldest first)
  4. Show for each: branch name, last commit date, last commit message, age in days
  5. Present as dry-run preview — ask before deleting
  6. On confirmation, use git branch -d first; offer -D only with warning if unmerged

Action: health

Run a comprehensive repository health check:

  1. Repository size:

    • .git directory size: du -sh .git
    • Working tree size: du -sh . --exclude=.git (or equivalent)
    • Object count: git count-objects -vH
  2. Large files (top 10 by size in history):

    • git rev-list --objects --all | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | awk '/^blob/ {print $3, $4}' | sort -rn | head -10
    • Flag files over 10MB
  3. Dangling objects:

    • git fsck --no-reflogs 2>&1 — look for dangling commits, blobs, trees
    • Report count and suggest git gc if significant
  4. Worktrees:

    • git worktree list — show active worktrees
  5. Remote status:

    • git remote -v — list remotes
    • Check if local is ahead/behind remote
  6. Stale tracking branches:

    • git remote prune origin --dry-run — branches that would be pruned
  7. Present findings with recommendations

  8. If cleanup is recommended (gc, prune), show the commands but always ask before running them

Action: all

  1. Find all git repositories under ~/Projects/:
    • find ~/Projects -maxdepth 3 -name .git -type d
  2. For each repository found: a. Show repo name and path b. Run the branches check (merged + gone remotes) c. Show summary: N merged branches, M gone-remote branches
  3. Per-repo confirmation — ask before deleting branches in each repo
  4. Show overall summary at the end

Safety Rules

  1. Never delete without confirmation — always preview first
  2. Never delete protected branches (main, master, develop)
  3. Never git push origin --delete on protected branches
  4. Never run git gc without asking
  5. Always preview first — every action starts as a dry run
  6. Per-repo confirmation for all — don't batch-delete across repos
  7. Use git branch -d (safe delete) first; only offer -D with explicit warning

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Git Cleanup AI skill do?

Repository hygiene — prune merged/stale branches, detect orphans, repo health checks. Use when cleaning up branches, checking repo health, or scanning projects.

Why use Git Cleanup on TypingMind?

Because you install it once and use it with any model. Git Cleanup is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Git Cleanup in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/SpecterOps/skills/tree/main/plugins/workflows-development/skills/git-cleanup. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Git Cleanup?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Git Cleanup?

As many as you like. As long as a model supports skills, you can use Git Cleanup with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Git Cleanup AI skill free?

Yes. It is published on GitHub by SpecterOps under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇