git-delete-branch
Use when deleting local or remote branches with safety checks for unmerged work.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Use when deleting local or remote branches with safety checks for unmerged work.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Use when designing component interaction specs with visual states, transitions, and accessibility requirements. Covers state matrices, responsive behavior, ARIA compliance, and content constraints. Do not use for multi-step user journey mapping (use journey-mapping).
Use when mapping complete user journeys through multi-step flows, onboarding sequences, or feature workflows. Covers entry points, happy paths, alternate paths, error states, friction analysis, and delight opportunities. Do not use for individual component interaction specs (use interaction-design).
Use when analyzing an existing codebase for architecture, tech stack, conventions, and infrastructure. Covers project structure mapping, data model discovery, integration point cataloging, and constraint identification. Do not use for schema changes (use schema-design) or API contract definition (use api-design).
Use when designing documentation architecture for a project or team. Covers audience mapping, Diataxis framework classification, onboarding path design, format and location decisions, documentation testing, and maintenance scheduling. Do not use for recording individual architecture decisions (use adr-template) or creating versioned changelogs (use changelog-design).
Use when auditing codebase patterns or evaluating proposed changes for convention consistency. Covers file naming, component patterns, data fetching, state management, and type conventions. Do not use for test plan design or coverage targets (use testing-strategy).
Use when classifying data elements by sensitivity tier and defining per-tier handling requirements. Covers data inventory, sensitivity classification, PII flow mapping, encryption and masking specifications, and cross-boundary transfer documentation. Do not use for regulatory gap analysis (use compliance-review) or audit logging design (use audit-trail-design).
| name | git-delete-branch |
| description | Use when deleting local or remote branches with safety checks for unmerged work. |
| triggers | ["git delete branch","delete branch","remove branch","cleanup branch","git branch -d"] |
| version | 1.0.0 |
| user_invocable | true |
--force.., shell metacharacters, or null bytes.--merged, --stale, --remote, --force accepted. Reject arbitrary strings.Delete local and/or remote branches with safety checks.
/git-delete-branch feat/old-feature # Delete local branch
/git-delete-branch feat/old-feature --remote # Also delete remote
/git-delete-branch --merged # Delete all merged branches
/git-delete-branch --stale # Delete branches with gone remotes
/git-delete-branch --force feat/unmerged # Force delete unmerged
BRANCH="$1"
# Cannot delete current branch
CURRENT=$(git branch --show-current)
if [ "$BRANCH" = "$CURRENT" ]; then
echo "Cannot delete current branch. Switch first:"
echo " /git-switch main"
exit 1
fi
# Check if branch exists
if ! git show-ref --verify --quiet "refs/heads/$BRANCH"; then
echo "Branch '$BRANCH' does not exist locally."
exit 1
fi
# Check if branch is merged
if ! git merge-base --is-ancestor "$BRANCH" main 2>/dev/null; then
echo "Warning: Branch is NOT fully merged into main."
echo "Commits that would be lost:"
git log main.."$BRANCH" --oneline
# Require --force for unmerged branches
if [ "$FORCE" != true ]; then
echo "Use --force to delete anyway."
exit 1
fi
fi
# Check for unpushed commits
UPSTREAM=$(git rev-parse --abbrev-ref "$BRANCH@{u}" 2>/dev/null)
if [ -n "$UPSTREAM" ]; then
UNPUSHED=$(git rev-list --count "$UPSTREAM..$BRANCH" 2>/dev/null || echo "0")
if [ "$UNPUSHED" -gt 0 ]; then
echo "Warning: Branch has $UNPUSHED unpushed commits."
fi
fi
# Safe delete (fails if not merged)
git branch -d "$BRANCH"
# Force delete (even if not merged)
git branch -D "$BRANCH"
if [ "$DELETE_REMOTE" = true ]; then
# Check if remote exists
if git show-ref --verify --quiet "refs/remotes/origin/$BRANCH"; then
git push origin --delete "$BRANCH"
echo "Deleted remote branch: origin/$BRANCH"
else
echo "No remote branch to delete."
fi
fi
Deleted branch: feat/old-feature
Branch was merged into main.
Local branch removed.
Remote branch: Not deleted (use --remote to delete)
Deleted branch: feat/old-feature
Local: Deleted
Remote: Deleted (origin/feat/old-feature)
Branch fully cleaned up.
Cannot delete: feat/wip-feature
This branch is NOT merged into main.
You would lose these commits:
abc1234 Work in progress
def5678 More changes
ghi9012 Almost done
Options:
/git-delete-branch --force feat/wip-feature # Delete anyway
/git-switch feat/wip-feature # Continue working
/git-merge-main # Merge main into it first
Finding branches merged into main...
Branches to delete:
fix/login-bug
feat/completed-feature
chore/old-cleanup
Delete these 3 branches? (y/n)
Deleted:
fix/login-bug
feat/completed-feature
chore/old-cleanup
Kept (current or protected):
main
develop
Finding stale branches (remote deleted)...
Stale branches:
feat/abandoned [origin: gone]
fix/obsolete [origin: gone]
Delete these 2 stale local branches? (y/n)
Deleted:
feat/abandoned
fix/obsolete
These branches cannot be deleted without explicit --force:
mainmasterdevelopproductionCannot delete protected branch: main
Use --force if you really mean it (not recommended).
# After PR is merged
/git-switch main
/git-pull
/git-delete-branch feat/merged-pr --remote
# Cleanup old branches
/git-branches --merged
/git-delete-branch --merged
# Clean stale tracking
/git-delete-branch --stale
/git-branches to see all branches and their status/git-switch to change to a different branch first/gh-pr-merge to clean up the merged branch