Agent skill branch tombs

From diegopacheco/ai-playground · View interactive version

Agent skill branch tombs is an AI agent skill from the GitHub repository diegopacheco/ai-playground. Builds a branch graveyard for a git repository. Reads every local and remote branch, records who last touched it and when, computes age, ahead/behind, and whether it is merged into the trunk, then renders a light-theme website that shows the stale branches as headstones and lists the ones that are s

How to use this skill

Skill file

Branch Graveyard

When invoked, you find the branches a repository has stopped touching and render a light-theme website that buries them. Each stale branch becomes a headstone showing its last-touch date and the author who last touched it. The report also lists the stale branches that are already merged into the trunk — the ones safe to delete — with the exact git command to remove each.

Global Context

Rules

Step 1 — Choose the target

The scan runs against either the current repository or a GitHub repository the skill clones into a temporary folder. Decide from $ARGUMENTS:

If both a number and a GitHub repo are given, use the number as the threshold for that repo.

Step 2 — Clone the GitHub repository (GitHub mode only)

A branch graveyard needs every remote branch, so clone with all branches but no working blobs to keep it fast:

tmp_root="$(mktemp -d)"
name="$(basename "<URL>" .git)"
git clone --no-checkout --filter=blob:none "<URL>" "$tmp_root/$name"

If the clone fails (bad URL, private repo with no access, no network), report the git error to the user and stop.

Step 3 — Run the analysis engine

In current-repo mode, confirm a git repository first; GitHub mode skips this because the fresh clone is already one:

git rev-parse --show-toplevel

If this fails, tell the user the current directory is not a git repository and stop.

The engine detects the trunk (origin/HEAD, else main, else master, else the current branch), lists every branch under refs/heads and refs/remotes, collapses each local/remote pair into one branch, and for each computes the last-touch date, the author who made that commit, the age in days, ahead/behind versus the trunk, and whether it is merged. It then renders the website by injecting the data into the template. It always writes branch-graveyard-report/ into the current working directory and finds its own template, so invoke it by its installed absolute path.

```bash

python3 "$HOME/.claude/skills/branch-tombs/scripts/branch_tombs.py" $ARGUMENTS

```

```bash

( cd "$tmp_root/$name" && python3 "$HOME/.claude/skills/branch-tombs/scripts/branch_tombs.py" <days-if-any> )

cp -R "$tmp_root/$name/branch-graveyard-report" .

rm -rf "$tmp_root"

```

Notes:

Step 4 — Open the report

open branch-graveyard-report/index.html

On Linux use xdg-open branch-graveyard-report/index.html instead.

Step 5 — Summarize for the user

The engine prints a text summary to stdout. Relay the key signals in your reply:

Keep it short. The website carries the detail; your reply points the user at the oldest graves and the safe-to-delete count.

How the website reads

Staleness model (for reference)

Age is days since the branch tip's commit. Tiers: active (≤30 days), stale (≤90), abandoned (≤365), ancient (>365). A branch counts as a grave when its age exceeds the threshold (default 30 days) and it is not the trunk. A grave is safe when it is fully merged into the trunk, and an unmerged grave when it still has commits ahead of the trunk.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.