Org Branch Cleanup logo

Org Branch Cleanup

Community
vincentkoc
org-branch-cleanup

Audit and safely prune stale branches across a GitHub organization with immutable snapshots, conservative merged-PR classification, live SHA/protection/open-PR revalidation, resumable deletion ledgers, and post-delete verification. Use when a maintainer asks to clean up old, dead, merged, bot-created, or abandoned organization branches without risking default, protected, release, security-advisory, state, or active pull-request refs.

Overview

Publishervincentkoc
Repositorydotskills
Skill nameorg-branch-cleanup
Stars
112
Forks
9
Bundled files
4
LicenseMIT
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.

  • 4 bundled files

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

  • Open source

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

Installation

Install the Org Branch 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/vincentkoc/dotskills/tree/main/skills/org-branch-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/vincentkoc/dotskills.git /tmp/dotskills
mkdir -p .claude/skills
cp -r /tmp/dotskills/skills/org-branch-cleanup .claude/skills/org-branch-cleanup
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Org Branch 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 Org Branch 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 Org Branch 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.

Org Branch Cleanup

Purpose

Remove organization branch clutter without guessing which refs are safe to delete.

The bundled scripts/org_branch_cleanup.py separates the work into read-only audit, explicit apply, and full verification phases. Dry-run evidence is the default; deletion requires an exact organization confirmation.

When to use

  • A GitHub organization has accumulated old or merged development branches.
  • Bot, agent, migration, or dependency branches remain after pull requests merge.
  • A maintainer wants an evidence-backed cleanup ledger rather than broad git push --delete.
  • Branch-heavy security, state, archive, or generated-data repositories need to be separated from ordinary development repos.
  • A previous cleanup stopped midway and must resume without repeating completed deletions.

Workflow

  1. Read the target repository or organization instructions before mutation.
  2. Confirm GitHub authentication and rate-limit headroom:
    • gh auth status
    • gh api rate_limit --jq '.resources | {core,graphql}'
  3. Run a read-only audit:
    bash
    python3 scripts/org_branch_cleanup.py audit \
      --org example-org \
      --output /tmp/example-org-branch-audit
    Start with --include-repo-regex '^one-repo$' when proving access or policy. Audit output is immutable by default; use a new directory rather than --overwrite.
  4. Inspect audit-summary.json, audit-errors.tsv, and delete-candidates.jsonl.
    • Do not apply a partial audit. Fix failed repository queries or explicitly justify --allow-partial.
    • Default candidates are same-repository PR heads merged at least 14 days ago.
    • Closed-unmerged branches and unassociated stale branches are report-only.
    • Default, fork, archived, protected, and release-like refs are excluded.
    • Repositories matching GHSA, state, or archive patterns are excluded by default. Audit them separately under an explicit retention policy.
  5. Apply only after the candidate set is reviewed:
    bash
    python3 scripts/org_branch_cleanup.py apply \
      --candidates /tmp/example-org-branch-audit/delete-candidates.jsonl \
      --confirm-org example-org \
      --output /tmp/example-org-branch-apply
    apply requires the clean sibling audit-summary.json. Do not bypass this with --allow-unverified-candidates or --allow-partial-audit without an explicit operator decision.
  6. Treat each preflight skip as a safety result, not a failure.
    • moved: branch SHA changed after the snapshot.
    • protected: REST or ruleset protection blocked deletion.
    • open-pr: a live pull request now uses the branch.
    • missing: GitHub or another operator already removed it.
  7. Verify every deletion:
    bash
    python3 scripts/org_branch_cleanup.py verify \
      --ledger /tmp/example-org-branch-apply/deleted.tsv \
      --output /tmp/example-org-branch-apply/verification-rerun.tsv
  8. Report exact deleted, skipped, retained, excluded-repository, and verification counts. Preserve the ledger until the cleanup is accepted.

Safety rules

  • Never delete default, protected, release, pages, stable, or active-PR branches.
  • Never infer safety from branch age or naming alone.
  • Require a same-repository PR whose head name matches the current branch tip.
  • Re-read the live SHA, protection status, and open PRs immediately before deletion.
  • Refuse organization mismatch between the candidate ledger and --confirm-org.
  • Keep closed-unmerged deletion disabled unless the operator explicitly passes --allow-closed-unmerged.
  • Stop broad scans when generated or security repos contain thousands of refs; define retention policy first.
  • If a proxy or wrapper stalls, preserve ledgers and resume with the real GitHub CLI. Do not restart shared daemons owned by other sessions.

Inputs

  • GitHub organization login.
  • Authenticated gh CLI with repository administration permission.
  • Output directory for snapshots and ledgers.
  • Optional retention windows and repository or branch exclusion regexes.
  • Optional --gh-bin override for a compatible GitHub CLI wrapper.

Outputs

  • snapshot.jsonl: immutable branch and PR-tip evidence.
  • delete-candidates.jsonl: old merged branches eligible for live preflight.
  • closed-unmerged-review.jsonl: abandoned PR heads requiring explicit approval.
  • stale-unassociated.tsv: old branches with insufficient deletion proof.
  • deleted.tsv and skipped.tsv: resumable mutation ledger.
  • verification.tsv: post-delete ref state.
  • JSON audit and apply summaries with exact counts and timestamps.

Flow

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 Org Branch Cleanup AI skill do?

Audit and safely prune stale branches across a GitHub organization with immutable snapshots, conservative merged-PR classification, live SHA/protection/open-PR revalidation, resumable deletion ledgers, and post-delete verification. Use when a maintainer asks to clean up old, dead, merged, bot-created, or abandoned organization branches without risking default, protected, release, security-advisory, state, or active pull-request refs.

Why use Org Branch Cleanup on TypingMind?

Because you install it once and use it with any model. Org Branch 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 Org Branch Cleanup in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/vincentkoc/dotskills/tree/main/skills/org-branch-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 Org Branch 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 Org Branch Cleanup?

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

Is the Org Branch Cleanup AI skill free?

Yes. It is published on GitHub by vincentkoc under the MIT 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 👇