mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-05 01:50:27 +08:00
docs: add CLI tools collaboration mode to Workflow Decision Guide
Add comprehensive section on multi-model CLI collaboration (Gemini/Qwen/Codex): - Three execution modes: serial, parallel, and hybrid - Semantic invocation vs command invocation patterns - Integration examples with Lite and Full workflows - Best practices for tool selection and execution strategies Updates both Chinese and English versions with practical examples showing how to leverage ultra-long context models (Gemini/Qwen) for analysis and Codex for precise code implementation.
This commit is contained in:
@@ -253,6 +253,180 @@ flowchart TD
|
||||
|
||||
---
|
||||
|
||||
### 7️⃣ **CLI 工具协作模式 - 多模型智能协同**
|
||||
|
||||
本项目集成了三种 CLI 工具,支持灵活的串联、并行和混合执行方式:
|
||||
|
||||
| 工具 | 核心能力 | 上下文长度 | 适用场景 |
|
||||
|------|---------|-----------|---------|
|
||||
| **Gemini** | 深度分析、架构设计、规划 | 超长上下文 | 代码理解、执行流追踪、技术方案评估 |
|
||||
| **Qwen** | 代码审查、模式识别 | 超长上下文 | Gemini 备选、多维度分析 |
|
||||
| **Codex** | 精确代码撰写、Bug定位 | 标准上下文 | 功能实现、测试生成、代码重构 |
|
||||
|
||||
#### 📋 三种执行模式
|
||||
|
||||
**1. 串联执行(Serial Execution)** - 顺序依赖
|
||||
|
||||
适用场景:后续任务依赖前一任务的结果
|
||||
|
||||
```bash
|
||||
# 示例:分析后实现
|
||||
# Step 1: Gemini 分析架构
|
||||
使用 gemini 分析认证模块的架构设计,识别关键组件和数据流
|
||||
|
||||
# Step 2: Codex 基于分析结果实现
|
||||
让 codex 根据上述架构分析,实现 JWT 认证中间件
|
||||
```
|
||||
|
||||
**执行流程**:
|
||||
```
|
||||
Gemini 分析 → 输出架构报告 → Codex 读取报告 → 实现代码
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**2. 并行执行(Parallel Execution)** - 同时进行
|
||||
|
||||
适用场景:多个独立任务,无依赖关系
|
||||
|
||||
```bash
|
||||
# 示例:多维度分析
|
||||
用 gemini 分析认证模块的安全性,关注 JWT、密码存储、会话管理
|
||||
用 qwen 分析认证模块的性能瓶颈,识别慢查询和优化点
|
||||
让 codex 为认证模块生成单元测试,覆盖所有核心功能
|
||||
```
|
||||
|
||||
**执行流程**:
|
||||
```
|
||||
┌─ Gemini: 安全分析 ─┐
|
||||
并行 ───┼─ Qwen: 性能分析 ──┼─→ 汇总结果
|
||||
└─ Codex: 测试生成 ─┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**3. 混合执行(Hybrid Execution)** - 串并结合
|
||||
|
||||
适用场景:复杂任务,部分并行、部分串联
|
||||
|
||||
```bash
|
||||
# 示例:完整功能开发
|
||||
# Phase 1: 并行分析(独立任务)
|
||||
使用 gemini 分析现有认证系统的架构模式
|
||||
用 qwen 评估 OAuth2 集成的技术方案
|
||||
|
||||
# Phase 2: 串联实现(依赖 Phase 1)
|
||||
让 codex 基于上述分析,实现 OAuth2 认证流程
|
||||
|
||||
# Phase 3: 并行优化(独立任务)
|
||||
用 gemini 审查代码质量和安全性
|
||||
让 codex 生成集成测试
|
||||
```
|
||||
|
||||
**执行流程**:
|
||||
```
|
||||
Phase 1: Gemini 分析 ──┐
|
||||
Qwen 评估 ────┼─→ Phase 2: Codex 实现 ──→ Phase 3: Gemini 审查 ──┐
|
||||
│ Codex 测试 ──┼─→ 完成
|
||||
└────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### 🎯 语义调用 vs 命令调用
|
||||
|
||||
**方式一:自然语言语义调用**(推荐)
|
||||
|
||||
```bash
|
||||
# 用户只需自然描述,Claude Code 自动调用工具
|
||||
"使用 gemini 分析这个模块的依赖关系"
|
||||
→ Claude Code 自动生成:cd src && gemini -p "分析依赖关系"
|
||||
|
||||
"让 codex 实现用户注册功能"
|
||||
→ Claude Code 自动生成:codex -C src/auth --full-auto exec "实现注册"
|
||||
```
|
||||
|
||||
**方式二:直接命令调用**
|
||||
|
||||
```bash
|
||||
# 通过 Slash 命令精准调用
|
||||
/cli:chat --tool gemini "解释这个算法"
|
||||
/cli:analyze --tool qwen "分析性能瓶颈"
|
||||
/cli:execute --tool codex "优化查询性能"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### 🔄 工作流集成示例
|
||||
|
||||
**集成到 Lite 工作流**:
|
||||
|
||||
```bash
|
||||
# 1. 规划阶段:Gemini 分析
|
||||
/workflow:lite-plan -e "重构支付模块"
|
||||
→ 三维确认选择 "CLI 工具执行"
|
||||
|
||||
# 2. 执行阶段:选择执行方式
|
||||
# 选项 A: 串联执行
|
||||
→ "使用 gemini 分析支付流程" → "让 codex 重构代码"
|
||||
|
||||
# 选项 B: 并行分析 + 串联实现
|
||||
→ "用 gemini 分析架构" + "用 qwen 评估方案"
|
||||
→ "让 codex 基于分析结果重构"
|
||||
```
|
||||
|
||||
**集成到 Full 工作流**:
|
||||
|
||||
```bash
|
||||
# 1. 规划阶段
|
||||
/workflow:plan "实现分布式缓存"
|
||||
/workflow:action-plan-verify
|
||||
|
||||
# 2. 分析阶段(并行)
|
||||
使用 gemini 分析现有缓存架构
|
||||
用 qwen 评估 Redis 集群方案
|
||||
|
||||
# 3. 实现阶段(串联)
|
||||
/workflow:execute # 或使用 CLI
|
||||
让 codex 实现 Redis 集群集成
|
||||
|
||||
# 4. 测试阶段(并行)
|
||||
/workflow:test-gen WFS-cache
|
||||
→ 内部使用 gemini 分析 + codex 生成测试
|
||||
|
||||
# 5. 审查阶段(串联)
|
||||
用 gemini 审查代码质量
|
||||
/workflow:review --type architecture
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### 💡 最佳实践
|
||||
|
||||
**何时使用串联**:
|
||||
- 实现依赖设计方案
|
||||
- 测试依赖代码实现
|
||||
- 优化依赖性能分析
|
||||
|
||||
**何时使用并行**:
|
||||
- 多维度分析(安全+性能+架构)
|
||||
- 多模块独立开发
|
||||
- 同时生成代码和测试
|
||||
|
||||
**何时使用混合**:
|
||||
- 复杂功能开发(分析→设计→实现→测试)
|
||||
- 大规模重构(评估→规划→执行→验证)
|
||||
- 技术栈迁移(调研→方案→实施→优化)
|
||||
|
||||
**工具选择建议**:
|
||||
1. **需要理解代码** → Gemini(首选)或 Qwen
|
||||
2. **需要编写代码** → Codex
|
||||
3. **复杂分析** → Gemini + Qwen 并行(互补验证)
|
||||
4. **精确实现** → Codex(基于 Gemini 分析)
|
||||
5. **快速原型** → 直接使用 Codex
|
||||
|
||||
---
|
||||
|
||||
## 🔄 典型场景完整流程
|
||||
|
||||
### 场景A:新功能开发(知道怎么做)
|
||||
|
||||
@@ -253,6 +253,180 @@ flowchart TD
|
||||
|
||||
---
|
||||
|
||||
### 7️⃣ **CLI Tools Collaboration Mode - Multi-Model Intelligent Coordination**
|
||||
|
||||
This project integrates three CLI tools supporting flexible serial, parallel, and hybrid execution:
|
||||
|
||||
| Tool | Core Capabilities | Context Length | Use Cases |
|
||||
|------|------------------|----------------|-----------|
|
||||
| **Gemini** | Deep analysis, architecture design, planning | Ultra-long context | Code understanding, execution flow tracing, technical solution evaluation |
|
||||
| **Qwen** | Code review, pattern recognition | Ultra-long context | Gemini alternative, multi-dimensional analysis |
|
||||
| **Codex** | Precise code writing, bug location | Standard context | Feature implementation, test generation, code refactoring |
|
||||
|
||||
#### 📋 Three Execution Modes
|
||||
|
||||
**1. Serial Execution** - Sequential dependency
|
||||
|
||||
Use case: Subsequent tasks depend on previous results
|
||||
|
||||
```bash
|
||||
# Example: Analyze then implement
|
||||
# Step 1: Gemini analyzes architecture
|
||||
Use gemini to analyze the authentication module's architecture design, identify key components and data flow
|
||||
|
||||
# Step 2: Codex implements based on analysis
|
||||
Have codex implement JWT authentication middleware based on the above architecture analysis
|
||||
```
|
||||
|
||||
**Execution flow**:
|
||||
```
|
||||
Gemini analysis → Output architecture report → Codex reads report → Implement code
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**2. Parallel Execution** - Concurrent processing
|
||||
|
||||
Use case: Multiple independent tasks with no dependencies
|
||||
|
||||
```bash
|
||||
# Example: Multi-dimensional analysis
|
||||
Use gemini to analyze authentication module security, focus on JWT, password storage, session management
|
||||
Use qwen to analyze authentication module performance bottlenecks, identify slow queries and optimization points
|
||||
Have codex generate unit tests for authentication module, covering all core features
|
||||
```
|
||||
|
||||
**Execution flow**:
|
||||
```
|
||||
┌─ Gemini: Security analysis ─┐
|
||||
Parallel ┼─ Qwen: Performance analysis ┼─→ Aggregate results
|
||||
└─ Codex: Test generation ────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
**3. Hybrid Execution** - Combined serial and parallel
|
||||
|
||||
Use case: Complex tasks with both parallel and serial phases
|
||||
|
||||
```bash
|
||||
# Example: Complete feature development
|
||||
# Phase 1: Parallel analysis (independent tasks)
|
||||
Use gemini to analyze existing authentication system architecture patterns
|
||||
Use qwen to evaluate OAuth2 integration technical solutions
|
||||
|
||||
# Phase 2: Serial implementation (depends on Phase 1)
|
||||
Have codex implement OAuth2 authentication flow based on above analysis
|
||||
|
||||
# Phase 3: Parallel optimization (independent tasks)
|
||||
Use gemini to review code quality and security
|
||||
Have codex generate integration tests
|
||||
```
|
||||
|
||||
**Execution flow**:
|
||||
```
|
||||
Phase 1: Gemini analysis ──┐
|
||||
Qwen evaluation ──┼─→ Phase 2: Codex implementation ──→ Phase 3: Gemini review ──┐
|
||||
│ Codex tests ───┼─→ Complete
|
||||
└──────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### 🎯 Semantic Invocation vs Command Invocation
|
||||
|
||||
**Method 1: Natural Language Semantic Invocation** (Recommended)
|
||||
|
||||
```bash
|
||||
# Users simply describe naturally, Claude Code auto-invokes tools
|
||||
"Use gemini to analyze this module's dependencies"
|
||||
→ Claude Code auto-generates: cd src && gemini -p "Analyze dependencies"
|
||||
|
||||
"Have codex implement user registration feature"
|
||||
→ Claude Code auto-generates: codex -C src/auth --full-auto exec "Implement registration"
|
||||
```
|
||||
|
||||
**Method 2: Direct Command Invocation**
|
||||
|
||||
```bash
|
||||
# Precise invocation via Slash commands
|
||||
/cli:chat --tool gemini "Explain this algorithm"
|
||||
/cli:analyze --tool qwen "Analyze performance bottlenecks"
|
||||
/cli:execute --tool codex "Optimize query performance"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### 🔄 Workflow Integration Examples
|
||||
|
||||
**Integration with Lite Workflow**:
|
||||
|
||||
```bash
|
||||
# 1. Planning phase: Gemini analysis
|
||||
/workflow:lite-plan -e "Refactor payment module"
|
||||
→ Three-dimensional confirmation selects "CLI Tools execution"
|
||||
|
||||
# 2. Execution phase: Choose execution method
|
||||
# Option A: Serial execution
|
||||
→ "Use gemini to analyze payment flow" → "Have codex refactor code"
|
||||
|
||||
# Option B: Parallel analysis + Serial implementation
|
||||
→ "Use gemini to analyze architecture" + "Use qwen to evaluate solution"
|
||||
→ "Have codex refactor based on analysis results"
|
||||
```
|
||||
|
||||
**Integration with Full Workflow**:
|
||||
|
||||
```bash
|
||||
# 1. Planning phase
|
||||
/workflow:plan "Implement distributed cache"
|
||||
/workflow:action-plan-verify
|
||||
|
||||
# 2. Analysis phase (parallel)
|
||||
Use gemini to analyze existing cache architecture
|
||||
Use qwen to evaluate Redis cluster solution
|
||||
|
||||
# 3. Implementation phase (serial)
|
||||
/workflow:execute # Or use CLI
|
||||
Have codex implement Redis cluster integration
|
||||
|
||||
# 4. Testing phase (parallel)
|
||||
/workflow:test-gen WFS-cache
|
||||
→ Internally uses gemini analysis + codex test generation
|
||||
|
||||
# 5. Review phase (serial)
|
||||
Use gemini to review code quality
|
||||
/workflow:review --type architecture
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### 💡 Best Practices
|
||||
|
||||
**When to use serial**:
|
||||
- Implementation depends on design solution
|
||||
- Testing depends on code implementation
|
||||
- Optimization depends on performance analysis
|
||||
|
||||
**When to use parallel**:
|
||||
- Multi-dimensional analysis (security + performance + architecture)
|
||||
- Multi-module independent development
|
||||
- Simultaneous code and test generation
|
||||
|
||||
**When to use hybrid**:
|
||||
- Complex feature development (analysis → design → implementation → testing)
|
||||
- Large-scale refactoring (evaluation → planning → execution → verification)
|
||||
- Tech stack migration (research → solution → implementation → optimization)
|
||||
|
||||
**Tool selection guidelines**:
|
||||
1. **Need to understand code** → Gemini (preferred) or Qwen
|
||||
2. **Need to write code** → Codex
|
||||
3. **Complex analysis** → Gemini + Qwen parallel (complementary verification)
|
||||
4. **Precise implementation** → Codex (based on Gemini analysis)
|
||||
5. **Quick prototype** → Direct Codex usage
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Complete Flow for Typical Scenarios
|
||||
|
||||
### Scenario A: New Feature Development (Know How to Build)
|
||||
|
||||
Reference in New Issue
Block a user