All skills
asyrafhussin avatar

/git-workflow

@b02a263

Git best practices, branching strategies, commit conventions, and PR workflows. Use when reviewing git history, writing commits, setting up branching strategy, or improving git practices. Triggers on "git best practices", "commit message", "branching strategy", or "PR workflow".

Use this Skill: https://skilld.dev/gh/asyrafhussin/agent-skills/git-workflow

This session only. Nothing lands on disk.

rulesbranch-delete-merged.md

≈717 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Delete Merged Branches

Clean up branches after they've been merged to keep the repository tidy and navigable.

Bad Example

# Accumulating merged branches
git branch -a
# feature/user-login (merged 6 months ago)
# feature/payment-v1 (merged 1 year ago)
# feature/old-dashboard (merged 2 years ago)
# fix/ancient-bug (merged 18 months ago)
# ... 200 more stale branches

# Keeping "just in case"
git checkout -b feature/backup-of-merged-branch
# The history is already in main!

# Never cleaning up remotes
git fetch
# Fetching hundreds of stale remote branches

# Reusing merged branch names
git checkout feature/login  # old merged branch
git commit -m "new changes"
# Confusing history, unclear what belongs to which PR

Good Example

# Delete local branch after merge
git checkout main
git pull origin main
git branch -d feature/user-auth
# -d is safe, won't delete unmerged branches

# Delete remote branch after merge
git push origin --delete feature/user-auth

# Combined cleanup after merge
git checkout main
git pull origin main
git branch -d feature/user-auth
git push origin --delete feature/user-auth

# Clean up all merged local branches
git checkout main
git branch --merged | grep -v "main\|master" | xargs git branch -d

# Clean up stale remote tracking branches
git fetch --prune
# or
git remote prune origin

# Enable auto-delete on GitHub
# Settings > General > Automatically delete head branches

# Periodic cleanup script
git checkout main
git pull --prune
git branch --merged | grep -v "main\|master\|develop" | xargs git branch -d
# Note: xargs -r (skip if empty) is Linux/GNU only — omit on macOS

Why

Cleaning up merged branches maintains repository health:

  1. Clarity: Easy to see active work vs. completed work
  2. Performance: Fewer branches means faster git operations
  3. Navigation: Finding the right branch is easier
  4. Reduced Confusion: No ambiguity about branch status
  5. Professionalism: Clean repository reflects well on the team

When to delete:

  • Immediately after PR is merged
  • During regular repository maintenance
  • As part of sprint cleanup

Safe deletion commands:

  • git branch -d - Only deletes if fully merged
  • git branch -D - Force delete (use cautiously)
  • git push origin --delete - Delete remote branch

Automation options:

  • GitHub: Enable "Automatically delete head branches" in repo settings
  • GitLab: Enable "Delete source branch when merge request is accepted"
  • CI/CD: Add cleanup step to merge pipelines

Exceptions (branches to keep):

  • main / master
  • develop (if using GitFlow)
  • release/* branches (until end of support)
  • Protected environment branches

Source: SKILL.md on GitHub

1 alert16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    This skill provides a comprehensive and secure set of guidelines for managing Git workflows, including commit message standards, branching strategies, and pull request best practices. It promotes industry-standard tools and safety measures, such as protected branches and automated linting, with no malicious patterns detected.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer6mo

    19/32 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at b02a263. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 7 months ago
metadata
{
  "author": "AsyrafHussin",
  "version": "1.2.0"
}

README badge

README badge for asyrafhussin/agent-skills/git-workflow