Skip to content
Agent Orchestration
Command

/clean-branches

清理 Git 分支:安全清理已合并或过期分支,默认 dry-run 模式

From plugin
ccg
6k19 skills19 commands
> /plugin marketplace add fengshao1227/ccg-workflow
> /plugin install ccg@ccg

Command definition

clean-branches.md
description: '清理 Git 分支:安全清理已合并或过期分支,默认 dry-run 模式'

Clean-Branches - 清理 Git 分支

安全识别并清理已合并或长期未更新的分支。

使用方法

/clean-branches [options]

选项

| 选项 | 说明 | |------|------| | `--base <branch>` | 基准分支(默认 main/master) | | `--stale <days>` | 清理超过 N 天未更新的分支 | | `--remote` | 同时清理远程分支 | | `--dry-run` | 只预览,不执行(**默认**) | | `--yes` | 跳过确认直接删除 | | `--force` | 强制删除未合并分支 |

---

执行工作流

🔍 阶段 1:预检

`[模式:准备]`

1. 同步远端:`git fetch --all --prune` 2. 读取保护分支配置 3. 确定基准分支

📋 阶段 2:分析识别

`[模式:分析]`

**已合并分支**:

  • 已完全合并到 `--base` 的分支

**过期分支**(如指定 `--stale`):

  • 最后提交在 N 天前的分支

**排除**:

  • 从待清理列表中移除保护分支

📊 阶段 3:报告预览

`[模式:报告]`

## 将要删除的分支

### 已合并分支
- feature/old-feature (合并于 3 天前)
- bugfix/fixed-issue (合并于 7 天前)

### 过期分支
- experiment/old-test (最后更新 90 天前)

✅ 阶段 4:执行清理

`[模式:执行]`

仅在不带 `--dry-run` 且确认后执行:

# 本地分支
git branch -d <branch>

# 远程分支(如果 --remote)
git push origin --delete <branch>

# 强制删除(如果 --force)
git branch -D <branch>

---

保护分支配置

# 添加保护分支
git config --add branch.cleanup.protected develop
git config --add branch.cleanup.protected 'release/*'

# 查看保护分支
git config --get-all branch.cleanup.protected

---

示例

# 预览将清理的分支
/clean-branches --dry-run

# 清理已合并且超过 90 天未动的分支
/clean-branches --stale 90

# 清理已合并到 release/v2.1 的分支
/clean-branches --base release/v2.1 --remote --yes

最佳实践

1. **优先 dry-run** – 先预览再执行 2. **活用 --base** – 适配 release 工作流 3. **谨慎 --force** – 除非确定无用 4. **团队协作** – 清理远程分支前先通知 5. **定期运行** – 每月/季度一次保持清爽

Read more
@fengshao1227
Ships withccg

多模型协作工作流引擎 — /ccg:go 一个命令,AI 自动分析意图、选择策略、编排 Codex + Gemini + Claude 协作执行

Stars on GitHub

Momentum

stars in total
6.0k
Star history of fengshao1227/ccg-workflow on GitHub, a chart by star-history.com

Other commands on ccg.

init-architect

init-architect

Command

自适应初始化:根级简明 + 模块级详尽;分阶段遍历并回报覆盖率

@fengshao1227@fengshao1227Install Command
planner

planner

Command

📋 任务规划师 - 使用 WBS 方法论分解功能需求为可执行任务

@fengshao1227@fengshao1227Install Command
team-architect

team-architect

Command

🏗 架构师 - 扫描代码库,综合多模型分析,输出架构蓝图和文件分配矩阵

@fengshao1227@fengshao1227Install Command
team-qa

team-qa

Command

🧪 QA 工程师 - 检测测试框架,编写测试,运行全量测试 + lint + typecheck

@fengshao1227@fengshao1227Install Command
team-reviewer

team-reviewer

Command

🔬 代码审查员 - 综合 Codex/Gemini 审查结果,分级输出 Critical/Warning/Info

@fengshao1227@fengshao1227Install Command

More commands from other plugins.

COMMAND_COMPLIANCE_REPORT

COMMAND_COMPLIANCE_REP…

Command

Reviewed all command files in `.claude/commands/analysis/` directory to ensure proper usage of: - `mcp__claude-flow__*` tools…

@ruvnet@ruvnetInstall Command
ask

ask

Command

This compatibility command keeps `/oh-my-claudecode:ask` available without loading the full `ask` skill description in every…

@yeachan-heo@yeachan-heoInstall Command