rubenflamshepherd/ruben-agent-skills

soft-delete-git

Safely soft-delete a merged Git branch by switching to the default branch, pulling latest, and running `git branch -d`.

First seen Jul 15, 2026

Installation

$ npx skills add rubenflamshepherd/ruben-agent-skills --skill soft-delete-git

Summary

  • Safely soft-delete a merged Git branch by switching to the default branch, pulling latest, and running `git branch -d`.
  • Use when the user wants to clean up, remove, or delete a local branch after merging, or says "soft delete this branch" / "delete my branch".
  • Escalates to the user instead of force-deleting if the branch is unmerged, except squash-merged PRs verified via `gh`.

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from rubenflamshepherd/ruben-agent-skills.

npx skills add rubenflamshepherd/ruben-agent-skills

Browse all from rubenflamshepherd/ruben-agent-skills

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Default branch main
Open issues 0
Status Active

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 2,712 B
  • docs SUMMARY.md 402 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 54 installs

SKILL.md

Soft Delete Git Branch Workflow

Invocation behavior

When this skill is invoked without an explicit branch name, target the currently checked-out branch. Invocation of the skill is authorization to begin the workflow immediately: inspect the working tree and determine the current branch without asking which branch to delete.

Only ask the user how to proceed when:

  • The working tree is dirty.
  • The current branch is the default branch.
  • Safe deletion fails and force deletion would require confirmation.

Do not ask the user to name or confirm the current branch before starting.

Steps:

  1. Check for uncommitted changes

``bash git status --porcelain `` If the working tree is dirty, stop and ask the user how to proceed (commit, stash, or discard) before switching branches.

  1. Get current branch name

``bash git branch --show-current `` If already on the default branch, there is no branch to delete — stop and ask the user which branch they meant.

  1. Determine the default branch

``bash git symbolic-ref --short refs/remotes/origin/HEAD ` This returns e.g. origin/main — the default branch is the part after origin/. If the ref is unset, fall back to main`.

  1. Check out the default branch

``bash git checkout <default-branch> ``

  1. Pull latest changes

``bash git pull ``

  1. Soft delete the previous branch

``bash git branch -d <branch-name> ``

  1. If soft delete fails, check for a squash merge

git branch -d fails for branches merged via GitHub's "Squash and merge", because the branch tip is never an ancestor of the default branch. Check whether the branch's PR was actually merged: ``bash gh pr view <branch-name> --json state,mergedAt ` - If the PR state is MERGED, confirm with the user, then delete with git branch -D <branch-name>`. - Otherwise, escalate to the user rather than force-deleting.

Notes:

  • Uses lowercase -d for soft delete (safe delete that prevents deletion of unmerged branches)
  • Never use uppercase -D (hard delete) except in the verified-squash-merge case above, and only after confirming with the user
  • The workflow ensures the default branch is up to date before attempting the delete