본문으로 건너뛰기
cccskills
무료GitHub에 공개

git-clean-branches

Find Git branches that have been merged or inactive for a chosen period. Preview cleanup candidates, exclude protected branches, and delete local or remote branches using a selected base branch and confirmation options.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

원문원문 설명 보기

Safely find and clean up merged or stale Git branches with dry-run mode and custom base/protected branches support

설치 방법 보기

이럴 때 유용합니다

  • Find merged branches to clean up
  • Review branches with no recent commits
  • Clean up branches merged into a release
  • Exclude important branches from cleanup

포함된 파일(1)

  • SKILL.md4.5 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Claude Command: Clean Branches

This command safely identifies and cleans up merged or stale Git branches. Runs in read-only preview (--dry-run) mode by default, requiring explicit instructions to perform deletions.


Usage

# [Safest] Preview branches to be cleaned without executing any deletions
/git-cleanBranches --dry-run

# Clean local branches merged to main and inactive for over 90 days (requires individual confirmation)
/git-cleanBranches --stale 90

# Clean local and remote branches merged to release/v2.1 (auto-confirm)
/git-cleanBranches --base release/v2.1 --remote --yes

# [Dangerous] Force delete an unmerged local branch
/git-cleanBranches --force outdated-feature

Options

  • --base <branch>: Specify the base branch for cleanup (defaults to repository's main/master).
  • --stale <days>: Clean branches with no commits for specified days (disabled by default).
  • --remote: Also clean remote merged/stale branches.
  • --dry-run: Default behavior. Only list branches to be deleted without executing any operations.
  • --yes: Skip individual confirmations and delete all identified branches directly (suitable for CI/CD).
  • --force: Use -D to force delete local branches (even if unmerged).

What This Command Does

  1. Configuration and Safety Checks

    • Update Information: Automatically executes git fetch --all --prune to ensure branch status is current.
    • Read Protected Branches: Reads the list of branches that should not be cleaned from Git config (see "Configuration" below).
    • Determine Base: Uses --base parameter or auto-detected main/master as comparison baseline.
  2. Analysis and Identification (Find)

    • Merged Branches: Find local (and remote if --remote is added) branches fully merged to --base.
    • Stale Branches: If --stale <days> is specified, find branches with last commit N days ago.
    • Exclude Protected Branches: Remove all configured protected branches from cleanup list.
  3. Report and Preview (Report)

    • Clearly list "merged branches to be deleted" and "stale branches to be deleted".
    • Without --yes parameter, command ends here, waiting for user confirmation to re-execute (without --dry-run).
  4. Execute Cleanup (Execute)

    • Only executed without --dry-run and after user confirmation (or with --yes).
    • Delete identified branches one by one, unless user chooses to skip in interactive confirmation.
    • Local: git branch -d <branch>; Remote: git push origin --delete <branch>.
    • If --force is specified, local deletion uses git branch -D <branch>.

Configuration (Configure Once, Use Forever)

To prevent accidental deletion of important branches (e.g., develop, release/*), add protection rules to the repository's Git config. The command reads them automatically.

# Protect develop branch
git config --add branch.cleanup.protected develop

# Protect all branches starting with release/ (wildcard)
git config --add branch.cleanup.protected 'release/*'

# View all configured protected branches
git config --get-all branch.cleanup.protected

Best Practices for Embedded Devs

  • Prioritize --dry-run: Develop the habit of previewing before executing.
  • Leverage --base: When maintaining long-term release branches, use it to clean feature or hotfix branches merged to that release.
  • Careful with --force: Don't force delete unless you're 100% certain an unmerged branch is useless.
  • Team Collaboration: Notify the team channel before cleaning shared remote branches.
  • Regular Runs: Run monthly or quarterly to keep the repository clean.

Why This Version Is Better

  • ✅ Safer: Default read-only preview with configurable protected branch list.
  • ✅ More Flexible: Supports custom base branches, perfectly fits release / develop workflows.
  • ✅ More Compatible: Avoids commands with inconsistent behavior across systems like date -d.
  • ✅ More Intuitive: Condenses complex 16-step checklist into a single command with safety options.
  • ✅ Consistent Style: Shares similar parameter design and documentation structure with /commit command.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

bmad-init

무료

Install or update BMad-Method (V6) in a project after checking existing installations. The skill also fixes a known output-folder issue, updates Git ignore rules, and provides next steps for using the installed workflows.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Set up BMad-Method (V6) for Claude Code
  • Run a quick update on an existing V6 installation
  • Check for an older V4 installation before setup
UfoMiao/zcf6.1천2026년 8월 31일 업데이트

bmad-init

무료

Set up or update BMad-Method V6 in a project, detect older installations, fix a known output folder issue, and adjust Git ignore rules, with guidance on what to do next.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Installing BMad-Method V6 in a project
  • Updating an existing V6 installation
  • Checking for an older V4 installation
UfoMiao/zcf6.1천2026년 8월 31일 업데이트

feat

무료

Guide new feature work from requirements and planning through revisions and implementation. Create Markdown plans with acceptance criteria, track progress, and ensure frontend tasks have a UI design before development begins.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Turn a feature idea into an implementation plan
  • Revise a plan based on feedback
  • Start implementation from an agreed plan
UfoMiao/zcf6.1천2026년 8월 31일 업데이트

feat

무료

Turn feature requests into documented plans, revise them through discussion, and carry out implementation with progress tracking. Frontend work includes checking for a UI design and arranging design work when needed.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Turning a feature idea into a development plan
  • Revising a plan after feedback
  • Implementing tasks from an agreed plan
UfoMiao/zcf6.1천2026년 8월 31일 업데이트

Find merged or inactive Git branches, preview cleanup candidates, and delete selected branches after confirmation. Choose a comparison branch, protect important branches with configurable rules, and optionally include remote branches.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Previewing branch cleanup candidates
  • Removing branches already merged into a release branch
  • Finding branches with no recent commits
UfoMiao/zcf6.1천2026년 8월 31일 업데이트

Use Git changes to generate Conventional Commits messages, a format that labels each change by type, and create commits. The skill suggests splitting unrelated changes and supports explicit scope, type, sign-off, and amendments to the previous commit.

한국어 요약은 준비 중입니다. 영어 요약을 표시하고 있습니다.

  • Generate a commit message from staged changes
  • Split unrelated changes into separate commits
  • Specify a commit type and scope
UfoMiao/zcf6.1천2026년 8월 31일 업데이트

UfoMiao의 스킬 모두 보기

이 스킬의 문제 신고