Logo di Clean Gone

Clean Gone

Community
rlajous
clean-gone

Delete local Git branches whose upstream was deleted on the remote ("[gone]"), and remove any worktrees attached to them. Use when the user asks to clean up merged/stale branches, prune gone branches, tidy local branches after merging PRs, or "delete branches that are gone on the remote".

Panoramica

Autorerlajous
Repositoryclaude-code-commands
Nome della skillclean-gone
Stelle
30
Fork
2
File inclusi
Solo istruzioni
LicenzaMIT
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • Tutto nelle istruzioni

    Tutto ciò che serve al modello è nelle istruzioni: nessun file aggiuntivo da sincronizzare.

  • Open source

    Pubblicata da rlajous su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Clean Gone in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/rlajous/claude-code-commands/tree/main/skills/clean-gone
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Nuova skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella nella cartella delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/rlajous/claude-code-commands.git /tmp/claude-code-commands
mkdir -p .claude/skills
cp -r /tmp/claude-code-commands/skills/clean-gone .claude/skills/clean-gone
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Clean Gone in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Clean Gone non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Clean Gone non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Cross-runtime: follow runtime compatibility for invocation, delegation, configuration precedence, state paths, and permissions.

You are cleaning up local Git branches whose remote tracking branch has been deleted (shown as [gone] by Git), along with any worktrees checked out to them. This is destructive, so it is designed to be safe by default: it never discards uncommitted work or unmerged commits without explicit, informed confirmation. Follow each step in order.

Step 1: Parse Arguments

  • --dry-run → show exactly what would be removed and stop. In dry-run, make no changes to Git state at all (no fetch/prune, no deletion).

Default (no args): proceed through confirmation (Step 4) before any deletion.

Step 2: Refresh Remote State (skip on --dry-run)

Only when NOT --dry-run, prune stale remote-tracking refs so [gone] is accurate:

bash
git fetch --prune
  • On --dry-run, do NOT run this (it mutates local refs). Use the current tracking state and note in the output that it may be stale — the user can re-run without --dry-run to refresh.
  • If fetch fails (offline, no remote), warn and continue with the current state.

Step 3: Identify Gone Branches

List local branches whose upstream is marked [gone]:

bash
git for-each-ref --format '%(refname:short) %(upstream:track)' refs/heads \
  | awk '$2 == "[gone]" { print $1 }'

Resolve the protected branches (never delete these) from .git-workflow/config.yaml, then .claude/config.yaml as a legacy read-only fallback, then defaults:

  • workflow.developmentBranch — default staging
  • workflow.productionBranch — default main
  • Also always protect: the current branch (git branch --show-current), and master.

Exclude every protected branch from the deletion list even if it is marked [gone] (a gone staging/main is a config/remote quirk, not a signal to delete it).

Step 4: Assess Safety and Confirm

For each candidate branch, gather safety signals to show the user:

  • Merged? Whether the branch's commits are already integrated (see Step 6 — prefer git branch -d, which refuses unmerged branches).
  • Attached worktree? And whether that worktree is dirty (see Step 5).

Present a table: branch → merged/unmerged → worktree path (clean/dirty). Then:

  • On --dry-run: print the table and stop (no changes).
  • Otherwise, ask the user to confirm. Call out any unmerged branches and any dirty worktrees explicitly — these lose data if removed. Default to NOT removing those unless the user explicitly opts in.

Step 5: Remove Associated Worktrees (safely)

A branch checked out in a linked worktree cannot be deleted until the worktree is removed. Map worktrees to branches:

bash
git worktree list --porcelain

For each gone branch with a worktree, check for uncommitted work first:

bash
git -C "{worktree_path}" status --porcelain --untracked-files=all
  • If the output is empty (clean): remove it with git worktree remove "{worktree_path}" (no --force needed for a clean worktree).
  • If non-empty (dirty/untracked files): do NOT remove it unless the user explicitly confirmed discarding its contents in Step 4. Only then use git worktree remove --force "{worktree_path}". Otherwise skip the branch and report why.

Then prune administrative leftovers: git worktree prune.

Step 6: Delete the Branches (merged-safe)

For each confirmed branch, try the safe delete first:

bash
git branch -d "{branch_name}"
  • -d succeeds only if the branch is already merged (into HEAD or its upstream). This is the desired path for the common "PR merged, remote branch deleted" case.

  • If -d fails because the branch is not merged, the branch has local commits that exist nowhere else. Show them:

    bash
    git log --oneline "{branch_name}" --not --remotes

    Report these commits and ask the user for explicit confirmation before force-deleting. Only on explicit confirmation:

    bash
    git branch -D "{branch_name}"

Never force-delete (-D) unmerged branches without showing the commits and getting a clear yes.

Step 7: Report

Print a summary:

text
Pruned gone branches:
  ✓ feature/eng-123-old-thing    (merged; worktree removed: ../wt-eng-123)
  ✓ fix/proj-456-done            (merged)
  ⚠ spike/experiment             (skipped: 3 unmerged commits — not deleted)
  ⚠ feature/wip                  (skipped: worktree has uncommitted changes)

Removed: 2 branches, 1 worktree. Skipped: 2.

If nothing was gone, say so plainly: "No gone branches to clean up."

Error Handling

ScenarioAction
git fetch failsWarn, continue with current tracking state
Branch is protected (current/dev/prod/master)Skip it, note it is protected
Branch is unmergedSkip by default; only force-delete after showing commits + explicit confirmation
Worktree is dirtySkip by default; only --force remove after explicit confirmation
Worktree path is missing/lockedReport the error, skip that branch, continue
git branch -d/-D failsReport and continue with the rest

Domande frequenti

Cosa fa la skill IA Clean Gone?

Delete local Git branches whose upstream was deleted on the remote ("[gone]"), and remove any worktrees attached to them. Use when the user asks to clean up merged/stale branches, prune gone branches, tidy local branches after merging PRs, or "delete branches that are gone on the remote".

Perché usare Clean Gone su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Clean Gone è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Clean Gone in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/rlajous/claude-code-commands/tree/main/skills/clean-gone. TypingMind legge il file SKILL.md e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Clean Gone?

Qualsiasi modello che colleghi in TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Clean Gone?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Clean Gone: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Clean Gone è gratuita?

Sì. È pubblicata su GitHub da rlajous con licenza MIT. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, modelli o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇