ccg-workflow 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +175 -408
- package/bin/codeagent-wrapper-linux-arm64 +0 -0
- package/bin/codeagent-wrapper-windows-arm64.exe +0 -0
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +1 -1
- package/dist/shared/{ccg-workflow.CjatSnB0.mjs → ccg-workflow.BtBr1Jpn.mjs} +194 -286
- package/package.json +1 -1
- package/templates/commands/analyze.md +113 -56
- package/templates/commands/backend.md +83 -152
- package/templates/commands/clean-branches.md +81 -66
- package/templates/commands/commit.md +81 -117
- package/templates/commands/debug.md +89 -85
- package/templates/commands/feat.md +62 -283
- package/templates/commands/frontend.md +83 -154
- package/templates/commands/init.md +100 -36
- package/templates/commands/optimize.md +110 -67
- package/templates/commands/review.md +107 -62
- package/templates/commands/rollback.md +86 -60
- package/templates/commands/test.md +116 -51
- package/templates/commands/workflow.md +198 -0
- package/templates/commands/worktree.md +78 -226
- package/templates/commands/bugfix.md +0 -114
- package/templates/commands/code.md +0 -255
- package/templates/commands/dev.md +0 -179
- package/templates/commands/think.md +0 -102
package/package.json
CHANGED
|
@@ -1,77 +1,134 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
2
|
+
description: '多模型技术分析(并行执行):Codex 后端视角 + Gemini 前端视角,交叉验证后综合见解'
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
`/analyze <QUESTION_OR_TASK>`
|
|
5
|
+
# Analyze - 多模型技术分析
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
使用双模型并行分析,交叉验证得出综合技术见解。**仅分析,不修改代码。**
|
|
8
|
+
|
|
9
|
+
## 使用方法
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
/analyze <分析问题或任务>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 多模型调用语法
|
|
16
|
+
|
|
17
|
+
**必须使用 heredoc 语法调用外部模型**:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
codeagent-wrapper --backend <codex|gemini> - $PWD <<'EOF'
|
|
21
|
+
ROLE_FILE: ~/.claude/.ccg/prompts/<model>/<role>.md
|
|
22
|
+
<TASK>
|
|
23
|
+
任务描述
|
|
24
|
+
</TASK>
|
|
25
|
+
OUTPUT: 期望输出格式
|
|
26
|
+
EOF
|
|
27
|
+
```
|
|
12
28
|
|
|
13
29
|
## 你的角色
|
|
14
|
-
You are the **Analysis Coordinator** orchestrating multi-model research. You direct:
|
|
15
|
-
1. **ace-tool** – for codebase context retrieval
|
|
16
|
-
2. **Configured Models** – for comprehensive multi-perspective analysis
|
|
17
|
-
3. **Claude (Self)** – for synthesizing insights
|
|
18
30
|
|
|
19
|
-
|
|
31
|
+
你是**分析协调者**,编排多模型分析流程:
|
|
32
|
+
- **ace-tool** – 代码上下文检索
|
|
33
|
+
- **Codex** – 后端/系统视角(**后端权威**)
|
|
34
|
+
- **Gemini** – 前端/用户视角(**前端权威**)
|
|
35
|
+
- **Claude (自己)** – 综合见解
|
|
20
36
|
|
|
21
|
-
|
|
37
|
+
---
|
|
22
38
|
|
|
23
|
-
|
|
24
|
-
- `project_root_path`: Project root directory absolute path
|
|
25
|
-
- `query`: Natural language description of what to analyze
|
|
26
|
-
5. Identify key files, patterns, and architecture
|
|
39
|
+
## 执行工作流
|
|
27
40
|
|
|
28
|
-
|
|
41
|
+
**分析任务**:$ARGUMENTS
|
|
29
42
|
|
|
30
|
-
|
|
43
|
+
### 🔍 阶段 1:上下文检索
|
|
31
44
|
|
|
32
|
-
|
|
45
|
+
`[模式:研究]`
|
|
33
46
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
47
|
+
1. 调用 `mcp__ace-tool__search_context` 检索相关代码
|
|
48
|
+
2. 识别分析范围和关键组件
|
|
49
|
+
3. 列出已知约束和假设
|
|
50
|
+
|
|
51
|
+
### 💡 阶段 2:并行分析
|
|
39
52
|
|
|
40
|
-
|
|
41
|
-
for model in $ALL_MODELS; do
|
|
42
|
-
codeagent-wrapper --backend $model - $PROJECT_DIR <<'EOF' &
|
|
43
|
-
ROLE_FILE: ~/.claude/.ccg/prompts/$model/analyzer.md
|
|
53
|
+
`[模式:分析]`
|
|
44
54
|
|
|
55
|
+
**并行调用两个模型**:
|
|
56
|
+
|
|
57
|
+
**执行步骤**:
|
|
58
|
+
1. 在**同一个 Bash 调用**中启动两个后台进程(不加 wait,立即返回):
|
|
59
|
+
```bash
|
|
60
|
+
codeagent-wrapper --backend codex - $PWD <<'EOF' &
|
|
61
|
+
ROLE_FILE: ~/.claude/.ccg/prompts/codex/analyzer.md
|
|
45
62
|
<TASK>
|
|
46
|
-
|
|
47
|
-
Context:
|
|
63
|
+
分析需求: $ARGUMENTS
|
|
64
|
+
Context: <阶段1检索到的上下文>
|
|
48
65
|
</TASK>
|
|
66
|
+
OUTPUT: 技术可行性、架构影响、性能考量
|
|
67
|
+
EOF
|
|
49
68
|
|
|
50
|
-
|
|
69
|
+
codeagent-wrapper --backend gemini - $PWD <<'EOF' &
|
|
70
|
+
ROLE_FILE: ~/.claude/.ccg/prompts/gemini/analyzer.md
|
|
71
|
+
<TASK>
|
|
72
|
+
分析需求: $ARGUMENTS
|
|
73
|
+
Context: <阶段1检索到的上下文>
|
|
74
|
+
</TASK>
|
|
75
|
+
OUTPUT: UI/UX 影响、用户体验、视觉设计考量
|
|
51
76
|
EOF
|
|
52
|
-
done
|
|
53
|
-
wait # 等待所有后台任务完成
|
|
54
77
|
```
|
|
78
|
+
2. 使用 `TaskOutput` 监控并获取 2 个模型的分析结果。
|
|
79
|
+
|
|
80
|
+
**⚠️ 强制规则:必须等待 TaskOutput 返回两个模型的完整结果后才能进入下一阶段,禁止跳过或提前继续!**
|
|
81
|
+
|
|
82
|
+
### 🔀 阶段 3:交叉验证
|
|
83
|
+
|
|
84
|
+
`[模式:验证]`
|
|
85
|
+
|
|
86
|
+
1. 对比双方分析结果
|
|
87
|
+
2. 识别:
|
|
88
|
+
- **一致观点**(强信号)
|
|
89
|
+
- **分歧点**(需权衡)
|
|
90
|
+
- **互补见解**(各自领域洞察)
|
|
91
|
+
3. 按信任规则权衡:后端以 Codex 为准,前端以 Gemini 为准
|
|
92
|
+
|
|
93
|
+
### 📊 阶段 4:综合输出
|
|
94
|
+
|
|
95
|
+
`[模式:总结]`
|
|
96
|
+
|
|
97
|
+
```markdown
|
|
98
|
+
## 🔬 技术分析:<主题>
|
|
99
|
+
|
|
100
|
+
### 一致观点(强信号)
|
|
101
|
+
1. <双方都认同的点>
|
|
102
|
+
|
|
103
|
+
### 分歧点(需权衡)
|
|
104
|
+
| 议题 | Codex 观点 | Gemini 观点 | 建议 |
|
|
105
|
+
|------|------------|-------------|------|
|
|
106
|
+
|
|
107
|
+
### 核心结论
|
|
108
|
+
<1-2 句话总结>
|
|
109
|
+
|
|
110
|
+
### 推荐方案
|
|
111
|
+
**首选**:<方案>
|
|
112
|
+
- 理由 / 风险 / 缓解措施
|
|
113
|
+
|
|
114
|
+
### 后续行动
|
|
115
|
+
1. [ ] <具体步骤>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## 适用场景
|
|
121
|
+
|
|
122
|
+
| 场景 | 示例 |
|
|
123
|
+
|------|------|
|
|
124
|
+
| 技术选型 | "比较 Redux vs Zustand" |
|
|
125
|
+
| 架构评估 | "评估微服务拆分方案" |
|
|
126
|
+
| 性能分析 | "分析 API 响应慢的原因" |
|
|
127
|
+
| 安全审计 | "评估认证模块安全性" |
|
|
128
|
+
|
|
129
|
+
## 关键规则
|
|
55
130
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
3. Evaluate trade-offs objectively
|
|
61
|
-
4. Weight opinions based on model strengths
|
|
62
|
-
|
|
63
|
-
### Step 4: 综合输出
|
|
64
|
-
Present unified analysis combining all perspectives.
|
|
65
|
-
|
|
66
|
-
## 输出格式
|
|
67
|
-
1. **Configuration** – models used for analysis
|
|
68
|
-
2. **Context Overview** – relevant codebase elements
|
|
69
|
-
3. **Model Perspectives** – analysis from each configured model
|
|
70
|
-
4. **Synthesis** – combined insights and trade-offs
|
|
71
|
-
5. **Recommendations** – actionable next steps
|
|
72
|
-
|
|
73
|
-
## 注意事项
|
|
74
|
-
- This command is for analysis only, no code changes
|
|
75
|
-
- **Use `run_in_background: true` for parallel execution** to avoid blocking
|
|
76
|
-
- 多模型结果交叉验证,取长补短
|
|
77
|
-
- Use HEREDOC syntax (`<<'EOF'`) to avoid shell escaping issues
|
|
131
|
+
1. **仅分析不修改** – 本命令不执行任何代码变更
|
|
132
|
+
2. **使用后台进程 `&` + `TaskOutput` 获取结果**
|
|
133
|
+
3. **必须等待所有模型返回完整结果后才能进入下一阶段**,禁止跳过或提前继续
|
|
134
|
+
4. **信任规则** – 后端以 Codex 为准,前端以 Gemini 为准
|
|
@@ -1,198 +1,129 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
2
|
+
description: '后端专项工作流(研究→构思→计划→执行→优化→评审),Codex主导'
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
# Backend - 后端专项开发
|
|
6
|
+
|
|
7
|
+
## 使用方法
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
/backend <后端任务描述>
|
|
11
|
+
```
|
|
7
12
|
|
|
8
13
|
## 上下文
|
|
9
|
-
- Backend/logic task to implement: $ARGUMENTS
|
|
10
|
-
- This command routes to your configured backend models.
|
|
11
|
-
- Default authority for algorithms, APIs, and business logic.
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
- 后端任务:$ARGUMENTS
|
|
16
|
+
- Codex 主导,Gemini 辅助参考
|
|
17
|
+
- 适用:API设计、算法实现、数据库优化、业务逻辑
|
|
18
|
+
|
|
19
|
+
## 你的角色
|
|
14
20
|
|
|
15
|
-
|
|
21
|
+
你是**后端编排者**,协调多模型完成服务端任务(研究 → 构思 → 计划 → 执行 → 优化 → 评审),用中文协助用户。
|
|
16
22
|
|
|
17
|
-
|
|
23
|
+
**协作模型**:
|
|
24
|
+
- **Codex** – 后端逻辑、算法(**后端权威,可信赖**)
|
|
25
|
+
- **Gemini** – 前端视角(**后端意见仅供参考**)
|
|
26
|
+
- **Claude (自己)** – 编排、计划、执行、交付
|
|
18
27
|
|
|
19
|
-
|
|
20
|
-
- Step 1: 上下文检索(MCP)
|
|
21
|
-
- Step 2: **多模型后端分析**(Codex + Gemini 并行) ← 新增
|
|
22
|
-
- Step 3: **多模型原型生成**(所有后端模型并行) ← 增强
|
|
23
|
-
- Step 4: 重构与实施(Claude 综合各模型优势)
|
|
24
|
-
- Step 5: **多模型审计交付**(Codex + Gemini 交叉验证) ← 新增
|
|
28
|
+
[沟通守则]
|
|
25
29
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
- Gemini 提供现代架构视角
|
|
29
|
-
- Claude 综合各家所长,重构为生产级代码
|
|
30
|
+
1. 响应以模式标签 `[模式:X]` 开始,初始为 `[模式:研究]`
|
|
31
|
+
2. 严格按 `研究 → 构思 → 计划 → 执行 → 优化 → 评审` 顺序流转
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
- Step 2 分析完成后,会询问"是否继续执行此方案?(Y/N)"
|
|
33
|
-
- 避免盲目执行,确保用户对方案满意
|
|
33
|
+
---
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
## 多模型调用语法
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
| **Prompt 增强** | ❌ 不包含 | ✅ Phase 0 |
|
|
42
|
-
| **工作流阶段** | 5 阶段 | 6 阶段(含 Prompt 增强)|
|
|
43
|
-
| **推荐用户** | 后端开发者 | 全栈开发者 |
|
|
37
|
+
```bash
|
|
38
|
+
# Codex 调用(后端主力)
|
|
39
|
+
~/.claude/bin/codeagent-wrapper --backend codex - "$PWD" <<'EOF'
|
|
40
|
+
[角色提示词内容]
|
|
44
41
|
|
|
45
|
-
|
|
42
|
+
[任务内容]
|
|
43
|
+
EOF
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
-
|
|
49
|
-
|
|
45
|
+
# Gemini 调用(前端参考)
|
|
46
|
+
~/.claude/bin/codeagent-wrapper --backend gemini - "$PWD" <<'EOF'
|
|
47
|
+
[任务内容]
|
|
48
|
+
EOF
|
|
49
|
+
```
|
|
50
50
|
|
|
51
51
|
---
|
|
52
52
|
|
|
53
|
-
##
|
|
54
|
-
You are the **Backend Orchestrator** specializing in server-side logic. You coordinate:
|
|
55
|
-
1. **ace-tool** – for retrieving existing backend code and architecture
|
|
56
|
-
2. **Configured Backend Models** – for generating logic, algorithms, and API implementations
|
|
57
|
-
3. **Claude (Self)** – for refactoring prototypes into production code
|
|
53
|
+
## 核心工作流
|
|
58
54
|
|
|
59
|
-
|
|
55
|
+
### 🔍 阶段 1:研究
|
|
60
56
|
|
|
61
|
-
|
|
62
|
-
1. Call `mcp__ace-tool__search_context` to understand existing architecture:
|
|
63
|
-
- `project_root_path`: Project root directory absolute path
|
|
64
|
-
- `query`: Natural language description of the backend task
|
|
65
|
-
2. Identify API patterns, data models, services, and dependencies
|
|
66
|
-
3. 如需求仍不清晰,提出澄清问题
|
|
57
|
+
`[模式:研究]` - 理解需求并收集上下文
|
|
67
58
|
|
|
68
|
-
|
|
59
|
+
1. 检索现有 API、数据模型、服务架构
|
|
60
|
+
2. 需求完整性评分(0-10 分):≥7 继续,<7 停止补充
|
|
69
61
|
|
|
70
|
-
|
|
62
|
+
### 💡 阶段 2:构思
|
|
71
63
|
|
|
72
|
-
|
|
73
|
-
- 每个模型使用对应的 `~/.claude/.ccg/prompts/<模型名>/analyzer.md`
|
|
74
|
-
- 输出:`Structured analysis/diagnostic report`
|
|
64
|
+
`[模式:构思]` - Codex 主导分析
|
|
75
65
|
|
|
76
|
-
|
|
66
|
+
**调用示例**:
|
|
77
67
|
|
|
78
|
-
调用示例:
|
|
79
68
|
```bash
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
- 数据模型和关系设计
|
|
91
|
-
- 业务逻辑复杂度
|
|
92
|
-
- 性能瓶颈和优化点
|
|
93
|
-
- 安全风险和防护措施
|
|
94
|
-
</TASK>
|
|
95
|
-
|
|
96
|
-
OUTPUT: Structured analysis/diagnostic report.
|
|
69
|
+
~/.claude/bin/codeagent-wrapper --backend codex - "$PWD" <<'EOF'
|
|
70
|
+
你是后端分析专家,擅长 API 设计、算法、数据库优化。
|
|
71
|
+
|
|
72
|
+
任务:分析以下后端需求,提供设计方案
|
|
73
|
+
- API 接口设计
|
|
74
|
+
- 数据模型结构
|
|
75
|
+
- 性能与安全考虑
|
|
76
|
+
- 错误处理策略
|
|
77
|
+
|
|
78
|
+
需求:[具体任务描述]
|
|
97
79
|
EOF
|
|
98
|
-
done
|
|
99
80
|
```
|
|
100
81
|
|
|
101
|
-
|
|
82
|
+
**⚠️ 等待 Codex 返回后继续**
|
|
102
83
|
|
|
103
|
-
|
|
84
|
+
输出方案(至少 2 个),等待用户选择。
|
|
104
85
|
|
|
105
|
-
###
|
|
86
|
+
### 📋 阶段 3:计划
|
|
106
87
|
|
|
107
|
-
|
|
88
|
+
`[模式:计划]` - Codex 主导规划
|
|
108
89
|
|
|
109
|
-
|
|
110
|
-
- 每个模型使用对应的 `~/.claude/.ccg/prompts/<模型名>/architect.md`
|
|
111
|
-
- 输出:`Unified Diff Patch ONLY`
|
|
90
|
+
调用 Codex(`architect.md`)→ 文件结构、函数/类设计、依赖
|
|
112
91
|
|
|
113
|
-
|
|
92
|
+
**⚠️ 等待 Codex 返回后继续**
|
|
114
93
|
|
|
115
|
-
|
|
116
|
-
```bash
|
|
117
|
-
# 遍历后端模型生成原型
|
|
118
|
-
for model in $(echo '{{BACKEND_MODELS}}' | jq -r '.[]'); do
|
|
119
|
-
codeagent-wrapper --backend $model - $PROJECT_DIR <<'EOF' &
|
|
120
|
-
ROLE_FILE: ~/.claude/.ccg/prompts/$model/architect.md
|
|
121
|
-
|
|
122
|
-
<TASK>
|
|
123
|
-
生成后端原型: {{后端任务描述}}
|
|
124
|
-
Context: {{相关代码和架构}}
|
|
125
|
-
实现要点:
|
|
126
|
-
- 遵循现有 API 设计模式
|
|
127
|
-
- 实现完整的错误处理
|
|
128
|
-
- 添加必要的参数验证
|
|
129
|
-
- 考虑并发和性能
|
|
130
|
-
</TASK>
|
|
131
|
-
|
|
132
|
-
OUTPUT: Unified Diff Patch ONLY. Strictly prohibit any actual modifications.
|
|
133
|
-
EOF
|
|
134
|
-
done
|
|
135
|
-
```
|
|
94
|
+
Claude 综合规划,请求用户批准后存入 `.claude/plan/任务名.md`
|
|
136
95
|
|
|
137
|
-
|
|
96
|
+
### ⚡ 阶段 4:执行
|
|
138
97
|
|
|
139
|
-
|
|
140
|
-
1. 将所有模型的原型视为"脏原型" – 仅作参考
|
|
141
|
-
2. **交叉验证所有模型结果,集各家所长**:
|
|
142
|
-
- 分析每个模型的优势和不足
|
|
143
|
-
- Codex 通常在算法和调试上更强
|
|
144
|
-
- Gemini 可能提供更现代的架构思路
|
|
145
|
-
- 选择最佳实现方案或综合创新点
|
|
146
|
-
3. 重构为干净的生产级代码
|
|
147
|
-
4. 确保正确的错误处理和安全性
|
|
148
|
-
5. 验证变更不会引入副作用
|
|
98
|
+
`[模式:执行]` - 代码开发
|
|
149
99
|
|
|
150
|
-
|
|
100
|
+
- 严格按批准的计划实施
|
|
101
|
+
- 遵循项目现有代码规范
|
|
102
|
+
- 确保错误处理、安全性、性能优化
|
|
151
103
|
|
|
152
|
-
|
|
104
|
+
### 🚀 阶段 5:优化
|
|
153
105
|
|
|
154
|
-
|
|
155
|
-
- 每个模型使用对应的 `~/.claude/.ccg/prompts/<模型名>/reviewer.md`
|
|
156
|
-
- 输出:`Review comments only`
|
|
106
|
+
`[模式:优化]` - Codex 主导审查
|
|
157
107
|
|
|
158
|
-
|
|
108
|
+
调用 Codex(`reviewer.md`)→ 安全性、性能、错误处理、API规范
|
|
159
109
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
for model in $(echo '{{BACKEND_MODELS}}' | jq -r '.[]'); do
|
|
164
|
-
codeagent-wrapper --backend $model - $PROJECT_DIR <<'EOF' &
|
|
165
|
-
ROLE_FILE: ~/.claude/.ccg/prompts/$model/reviewer.md
|
|
166
|
-
|
|
167
|
-
<TASK>
|
|
168
|
-
审查后端代码: {{实施的代码变更}}
|
|
169
|
-
关注点:
|
|
170
|
-
- 安全性(SQL 注入、XSS、CSRF 等)
|
|
171
|
-
- 性能(N+1 查询、缓存策略)
|
|
172
|
-
- 错误处理(异常捕获、日志记录)
|
|
173
|
-
- 代码质量(可读性、可维护性)
|
|
174
|
-
- API 规范(RESTful 设计、HTTP 状态码)
|
|
175
|
-
</TASK>
|
|
176
|
-
|
|
177
|
-
OUTPUT: Review comments only. No code modifications.
|
|
178
|
-
EOF
|
|
179
|
-
done
|
|
180
|
-
```
|
|
110
|
+
**⚠️ 等待 Codex 返回后继续**
|
|
111
|
+
|
|
112
|
+
整合审查意见,用户确认后执行优化。
|
|
181
113
|
|
|
182
|
-
|
|
114
|
+
### ✅ 阶段 6:评审
|
|
183
115
|
|
|
184
|
-
|
|
116
|
+
`[模式:评审]` - 最终评估
|
|
117
|
+
|
|
118
|
+
- 对照计划检查完成情况
|
|
119
|
+
- 运行测试验证功能
|
|
120
|
+
- 报告问题与建议
|
|
121
|
+
|
|
122
|
+
---
|
|
185
123
|
|
|
186
|
-
##
|
|
187
|
-
1. **Configuration** – 使用的模型和策略 ({{BACKEND_MODELS}})
|
|
188
|
-
2. **Architecture Analysis** – 现有模式和依赖关系
|
|
189
|
-
3. **Multi-Model Analysis** – 所有后端模型的分析报告(交叉验证)
|
|
190
|
-
4. **Multi-Model Prototypes** – 所有后端模型的原型(交叉验证)
|
|
191
|
-
5. **Refined Implementation** – 综合各模型优势的生产级代码
|
|
192
|
-
6. **Multi-Model Audit** – 所有后端模型的审计反馈(交叉验证)
|
|
124
|
+
## 关键规则
|
|
193
125
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
- Use HEREDOC syntax (`<<'EOF'`) to avoid shell escaping issues
|
|
126
|
+
1. **Codex 后端意见可信赖**
|
|
127
|
+
2. **Gemini 后端意见仅供参考**
|
|
128
|
+
3. 外部模型对文件系统**零写入权限**
|
|
129
|
+
4. Claude 负责所有代码写入和文件操作
|
|
@@ -1,102 +1,117 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
3
|
-
allowed-tools: Read(**), Exec(git fetch, git config, git branch, git remote, git push, git for-each-ref, git log), Write()
|
|
4
|
-
argument-hint: [--base <branch>] [--stale <days>] [--remote] [--force] [--dry-run] [--yes]
|
|
5
|
-
# examples:
|
|
6
|
-
# - /git-cleanBranches --dry-run
|
|
7
|
-
# - /git-cleanBranches --base release/v2.1 --stale 90
|
|
8
|
-
# - /git-cleanBranches --remote --yes
|
|
2
|
+
description: '清理 Git 分支:安全清理已合并或过期分支,默认 dry-run 模式'
|
|
9
3
|
---
|
|
10
4
|
|
|
11
|
-
#
|
|
5
|
+
# Clean-Branches - 清理 Git 分支
|
|
12
6
|
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
安全识别并清理已合并或长期未更新的分支。
|
|
8
|
+
|
|
9
|
+
## 使用方法
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
/clean-branches [options]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 选项
|
|
16
|
+
|
|
17
|
+
| 选项 | 说明 |
|
|
18
|
+
|------|------|
|
|
19
|
+
| `--base <branch>` | 基准分支(默认 main/master) |
|
|
20
|
+
| `--stale <days>` | 清理超过 N 天未更新的分支 |
|
|
21
|
+
| `--remote` | 同时清理远程分支 |
|
|
22
|
+
| `--dry-run` | 只预览,不执行(**默认**) |
|
|
23
|
+
| `--yes` | 跳过确认直接删除 |
|
|
24
|
+
| `--force` | 强制删除未合并分支 |
|
|
15
25
|
|
|
16
26
|
---
|
|
17
27
|
|
|
18
|
-
##
|
|
28
|
+
## 执行工作流
|
|
19
29
|
|
|
20
|
-
|
|
21
|
-
# [最安全] 预览将要清理的分支,不执行任何删除
|
|
22
|
-
/git-cleanBranches --dry-run
|
|
30
|
+
### 🔍 阶段 1:预检
|
|
23
31
|
|
|
24
|
-
|
|
25
|
-
/git-cleanBranches --stale 90
|
|
32
|
+
`[模式:准备]`
|
|
26
33
|
|
|
27
|
-
|
|
28
|
-
|
|
34
|
+
1. 同步远端:`git fetch --all --prune`
|
|
35
|
+
2. 读取保护分支配置
|
|
36
|
+
3. 确定基准分支
|
|
29
37
|
|
|
30
|
-
|
|
31
|
-
/git-cleanBranches --force outdated-feature
|
|
32
|
-
```
|
|
38
|
+
### 📋 阶段 2:分析识别
|
|
33
39
|
|
|
34
|
-
|
|
40
|
+
`[模式:分析]`
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
- `--
|
|
38
|
-
- `--remote`:同时清理远程已合并/过期的分支。
|
|
39
|
-
- `--dry-run`:**默认行为**。仅列出将要删除的分支,不执行任何操作。
|
|
40
|
-
- `--yes`:跳过逐一确认的步骤,直接删除所有已识别的分支(适合 CI/CD)。
|
|
41
|
-
- `--force`:使用 `-D` 强制删除本地分支(即使未合并)。
|
|
42
|
+
**已合并分支**:
|
|
43
|
+
- 已完全合并到 `--base` 的分支
|
|
42
44
|
|
|
43
|
-
|
|
45
|
+
**过期分支**(如指定 `--stale`):
|
|
46
|
+
- 最后提交在 N 天前的分支
|
|
44
47
|
|
|
45
|
-
|
|
48
|
+
**排除**:
|
|
49
|
+
- 从待清理列表中移除保护分支
|
|
46
50
|
|
|
47
|
-
|
|
48
|
-
- **更新信息**:自动执行 `git fetch --all --prune`,确保分支状态最新。
|
|
49
|
-
- **读取保护分支**:从 Git 配置读取不应被清理的分支列表(见下文“Configuration”)。
|
|
50
|
-
- **确定基准**:使用 `--base` 参数或自动识别的 `main`/`master` 作为比较基准。
|
|
51
|
+
### 📊 阶段 3:报告预览
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
- **已合并分支**:找出已完全合并到 `--base` 的本地(及远程,如加 `--remote`)分支。
|
|
54
|
-
- **过期分支**:如指定 `--stale <days>`,找出最后一次提交在 N 天前的分支。
|
|
55
|
-
- **排除保护分支**:从待清理列表中移除所有已配置的保护分支。
|
|
53
|
+
`[模式:报告]`
|
|
56
54
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
- 若无 `--yes` 参数,**命令到此结束**,等待用户确认后再次执行(不带 `--dry-run`)。
|
|
55
|
+
```markdown
|
|
56
|
+
## 将要删除的分支
|
|
60
57
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
- 本地用 `git branch -d <branch>`;远程用 `git push origin --delete <branch>`。
|
|
65
|
-
- 若指定 `--force`,本地删除会改用 `git branch -D <branch>`。
|
|
58
|
+
### 已合并分支
|
|
59
|
+
- feature/old-feature (合并于 3 天前)
|
|
60
|
+
- bugfix/fixed-issue (合并于 7 天前)
|
|
66
61
|
|
|
67
|
-
|
|
62
|
+
### 过期分支
|
|
63
|
+
- experiment/old-test (最后更新 90 天前)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### ✅ 阶段 4:执行清理
|
|
68
67
|
|
|
69
|
-
|
|
68
|
+
`[模式:执行]`
|
|
70
69
|
|
|
71
|
-
|
|
70
|
+
仅在不带 `--dry-run` 且确认后执行:
|
|
72
71
|
|
|
73
72
|
```bash
|
|
74
|
-
#
|
|
75
|
-
git
|
|
73
|
+
# 本地分支
|
|
74
|
+
git branch -d <branch>
|
|
76
75
|
|
|
77
|
-
#
|
|
76
|
+
# 远程分支(如果 --remote)
|
|
77
|
+
git push origin --delete <branch>
|
|
78
|
+
|
|
79
|
+
# 强制删除(如果 --force)
|
|
80
|
+
git branch -D <branch>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 保护分支配置
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# 添加保护分支
|
|
89
|
+
git config --add branch.cleanup.protected develop
|
|
78
90
|
git config --add branch.cleanup.protected 'release/*'
|
|
79
91
|
|
|
80
|
-
#
|
|
92
|
+
# 查看保护分支
|
|
81
93
|
git config --get-all branch.cleanup.protected
|
|
82
94
|
```
|
|
83
95
|
|
|
84
96
|
---
|
|
85
97
|
|
|
86
|
-
##
|
|
98
|
+
## 示例
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# 预览将清理的分支
|
|
102
|
+
/clean-branches --dry-run
|
|
87
103
|
|
|
88
|
-
|
|
89
|
-
-
|
|
90
|
-
- **谨慎 `--force`**:除非你百分百确定某个未合并分支是无用功,否则不要强制删除。
|
|
91
|
-
- **团队协作**:在清理共享的远程分支前,先在团队频道通知一声。
|
|
92
|
-
- **定期运行**:每月或每季度运行一次,保持仓库清爽。
|
|
104
|
+
# 清理已合并且超过 90 天未动的分支
|
|
105
|
+
/clean-branches --stale 90
|
|
93
106
|
|
|
94
|
-
|
|
107
|
+
# 清理已合并到 release/v2.1 的分支
|
|
108
|
+
/clean-branches --base release/v2.1 --remote --yes
|
|
109
|
+
```
|
|
95
110
|
|
|
96
|
-
##
|
|
111
|
+
## 最佳实践
|
|
97
112
|
|
|
98
|
-
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
113
|
+
1. **优先 dry-run** – 先预览再执行
|
|
114
|
+
2. **活用 --base** – 适配 release 工作流
|
|
115
|
+
3. **谨慎 --force** – 除非确定无用
|
|
116
|
+
4. **团队协作** – 清理远程分支前先通知
|
|
117
|
+
5. **定期运行** – 每月/季度一次保持清爽
|