一键导入
git-clean-branches
Safely find and clean up merged or stale Git branches with dry-run mode and custom base/protected branches support
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Safely find and clean up merged or stale Git branches with dry-run mode and custom base/protected branches support
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Professional AI programming assistant with structured workflow (Research -> Ideate -> Plan -> Execute -> Optimize -> Review) for developers
专业AI编程助手,提供结构化六阶段开发工作流(研究→构思→计划→执行→优化→评审),适用于专业开发者
Quickly add a new corporate sponsor to ZCF — sponsor list by default, with optional API preset and documentation ad placements
Create pull request based on current branch changes
Automate version release and code commit using changeset
Automatically check code changes since last tag and update documentation in docs/ directory (en, zh-CN, ja-JP) and CLAUDE.md to ensure consistency with actual code implementation
| name | git-clean-branches |
| description | Safely find and clean up merged or stale Git branches with dry-run mode and custom base/protected branches support |
| disable-model-invocation | true |
| allowed-tools | Read(**), Exec(git fetch, git config, git branch, git remote, git push, git for-each-ref, git log), Write() |
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.
# [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
--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).Configuration and Safety Checks
git fetch --all --prune to ensure branch status is current.--base parameter or auto-detected main/master as comparison baseline.Analysis and Identification (Find)
--remote is added) branches fully merged to --base.--stale <days> is specified, find branches with last commit N days ago.Report and Preview (Report)
--yes parameter, command ends here, waiting for user confirmation to re-execute (without --dry-run).Execute Cleanup (Execute)
--dry-run and after user confirmation (or with --yes).git branch -d <branch>; Remote: git push origin --delete <branch>.--force is specified, local deletion uses git branch -D <branch>.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
--dry-run: Develop the habit of previewing before executing.--base: When maintaining long-term release branches, use it to clean feature or hotfix branches merged to that release.--force: Don't force delete unless you're 100% certain an unmerged branch is useless.release / develop workflows.date -d./commit command.