mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-04 01:40:45 +08:00
docs: add CLI results as memory/context section
Add comprehensive explanation of how CLI tool results can be saved and reused as context for subsequent operations: - Result persistence in workflow sessions (.chat/ directory) - Using analysis results as planning basis - Using analysis results as implementation basis - Cross-session references - Memory update loops with iterative optimization - Visual memory flow diagram showing phase-to-phase context passing - Best practices for maintaining continuity and quality This enables intelligent workflows where Gemini/Qwen analysis informs Codex implementation, and all results accumulate as project memory for future decision-making. Integrates with /workflow:plan and /workflow:lite-plan commands.
This commit is contained in:
@@ -357,6 +357,126 @@ Phase 1: Gemini 分析 ──┐
|
||||
|
||||
---
|
||||
|
||||
#### 🔗 CLI 结果作为上下文(Memory)
|
||||
|
||||
CLI 工具的分析结果可以被保存并作为后续操作的上下文(memory),实现智能化的工作流程:
|
||||
|
||||
**1. 结果持久化**
|
||||
|
||||
```bash
|
||||
# CLI 执行结果自动保存到会话目录
|
||||
/cli:chat --tool gemini "分析认证模块架构"
|
||||
→ 保存到:.workflow/active/WFS-xxx/.chat/chat-[timestamp].md
|
||||
|
||||
/cli:analyze --tool qwen "评估性能瓶颈"
|
||||
→ 保存到:.workflow/active/WFS-xxx/.chat/analyze-[timestamp].md
|
||||
|
||||
/cli:execute --tool codex "实现功能"
|
||||
→ 保存到:.workflow/active/WFS-xxx/.chat/execute-[timestamp].md
|
||||
```
|
||||
|
||||
**2. 结果作为规划依据**
|
||||
|
||||
```bash
|
||||
# Step 1: 分析现状(生成 memory)
|
||||
使用 gemini 深度分析认证系统的架构、安全性和性能问题
|
||||
→ 输出:详细分析报告(自动保存)
|
||||
|
||||
# Step 2: 基于分析结果规划
|
||||
/workflow:plan "根据上述 Gemini 分析报告重构认证系统"
|
||||
→ 系统自动读取 .chat/ 中的分析报告作为上下文
|
||||
→ 生成精准的实施计划
|
||||
```
|
||||
|
||||
**3. 结果作为实现依据**
|
||||
|
||||
```bash
|
||||
# Step 1: 并行分析(生成多个 memory)
|
||||
使用 gemini 分析现有代码结构
|
||||
用 qwen 评估技术方案可行性
|
||||
→ 输出:多份分析报告
|
||||
|
||||
# Step 2: 基于所有分析结果实现
|
||||
让 codex 综合上述 Gemini 和 Qwen 的分析,实现最优方案
|
||||
→ Codex 自动读取前序分析结果
|
||||
→ 生成符合架构设计的代码
|
||||
```
|
||||
|
||||
**4. 跨会话引用**
|
||||
|
||||
```bash
|
||||
# 引用历史会话的分析结果
|
||||
/cli:execute --tool codex "参考 WFS-2024-001 中的架构分析,实现新的支付模块"
|
||||
→ 系统自动加载指定会话的上下文
|
||||
→ 基于历史分析进行实现
|
||||
```
|
||||
|
||||
**5. Memory 更新循环**
|
||||
|
||||
```bash
|
||||
# 迭代优化流程
|
||||
使用 gemini 分析当前实现的问题
|
||||
→ 生成问题报告(memory)
|
||||
|
||||
让 codex 根据问题报告优化代码
|
||||
→ 实现改进(更新 memory)
|
||||
|
||||
用 qwen 验证优化效果
|
||||
→ 验证报告(追加 memory)
|
||||
|
||||
# 所有结果累积为完整的项目 memory
|
||||
→ 支持后续决策和实现
|
||||
```
|
||||
|
||||
**Memory 流转示例**:
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ Phase 1: 分析阶段(生成 Memory) │
|
||||
├─────────────────────────────────────────────────────────────┤
|
||||
│ Gemini 分析 → 架构分析报告 (.chat/analyze-001.md) │
|
||||
│ Qwen 评估 → 方案评估报告 (.chat/analyze-002.md) │
|
||||
└─────────────────────┬───────────────────────────────────────┘
|
||||
│ 作为 Memory 输入
|
||||
↓
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ Phase 2: 规划阶段(使用 Memory) │
|
||||
├─────────────────────────────────────────────────────────────┤
|
||||
│ /workflow:plan → 读取分析报告 → 生成实施计划 │
|
||||
│ (.task/IMPL-*.json) │
|
||||
└─────────────────────┬───────────────────────────────────────┘
|
||||
│ 作为 Memory 输入
|
||||
↓
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ Phase 3: 实现阶段(使用 Memory) │
|
||||
├─────────────────────────────────────────────────────────────┤
|
||||
│ Codex 实现 → 读取计划+分析 → 生成代码 │
|
||||
│ (.chat/execute-001.md) │
|
||||
└─────────────────────┬───────────────────────────────────────┘
|
||||
│ 作为 Memory 输入
|
||||
↓
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ Phase 4: 验证阶段(使用 Memory) │
|
||||
├─────────────────────────────────────────────────────────────┤
|
||||
│ Gemini 审查 → 读取实现代码 → 质量报告 │
|
||||
│ (.chat/review-001.md) │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
↓
|
||||
完整的项目 Memory 库
|
||||
支持未来所有决策和实现
|
||||
```
|
||||
|
||||
**最佳实践**:
|
||||
|
||||
1. **保持连续性**:在同一会话中执行相关任务,自动共享 memory
|
||||
2. **显式引用**:跨会话时明确引用历史分析(如"参考 WFS-xxx 的分析")
|
||||
3. **增量更新**:每次分析和实现都追加到 memory,形成完整的决策链
|
||||
4. **定期整理**:使用 `/memory:update-related` 将 CLI 结果整合到 CLAUDE.md
|
||||
5. **质量优先**:高质量的分析 memory 能显著提升后续实现质量
|
||||
|
||||
---
|
||||
|
||||
#### 🔄 工作流集成示例
|
||||
|
||||
**集成到 Lite 工作流**:
|
||||
|
||||
@@ -357,6 +357,126 @@ Phase 1: Gemini analysis ──┐
|
||||
|
||||
---
|
||||
|
||||
#### 🔗 CLI Results as Context (Memory)
|
||||
|
||||
CLI tool analysis results can be saved and used as context (memory) for subsequent operations, enabling intelligent workflows:
|
||||
|
||||
**1. Result Persistence**
|
||||
|
||||
```bash
|
||||
# CLI execution results automatically saved to session directory
|
||||
/cli:chat --tool gemini "Analyze authentication module architecture"
|
||||
→ Saved to: .workflow/active/WFS-xxx/.chat/chat-[timestamp].md
|
||||
|
||||
/cli:analyze --tool qwen "Evaluate performance bottlenecks"
|
||||
→ Saved to: .workflow/active/WFS-xxx/.chat/analyze-[timestamp].md
|
||||
|
||||
/cli:execute --tool codex "Implement feature"
|
||||
→ Saved to: .workflow/active/WFS-xxx/.chat/execute-[timestamp].md
|
||||
```
|
||||
|
||||
**2. Results as Planning Basis**
|
||||
|
||||
```bash
|
||||
# Step 1: Analyze current state (generate memory)
|
||||
Use gemini to deeply analyze authentication system architecture, security, and performance issues
|
||||
→ Output: Detailed analysis report (auto-saved)
|
||||
|
||||
# Step 2: Plan based on analysis results
|
||||
/workflow:plan "Refactor authentication system based on above Gemini analysis report"
|
||||
→ System automatically reads analysis reports from .chat/ as context
|
||||
→ Generate precise implementation plan
|
||||
```
|
||||
|
||||
**3. Results as Implementation Basis**
|
||||
|
||||
```bash
|
||||
# Step 1: Parallel analysis (generate multiple memories)
|
||||
Use gemini to analyze existing code structure
|
||||
Use qwen to evaluate technical solution feasibility
|
||||
→ Output: Multiple analysis reports
|
||||
|
||||
# Step 2: Implement based on all analysis results
|
||||
Have codex synthesize above Gemini and Qwen analyses to implement optimal solution
|
||||
→ Codex automatically reads prior analysis results
|
||||
→ Generate code conforming to architecture design
|
||||
```
|
||||
|
||||
**4. Cross-Session References**
|
||||
|
||||
```bash
|
||||
# Reference historical session analysis results
|
||||
/cli:execute --tool codex "Refer to architecture analysis in WFS-2024-001, implement new payment module"
|
||||
→ System automatically loads specified session context
|
||||
→ Implement based on historical analysis
|
||||
```
|
||||
|
||||
**5. Memory Update Loop**
|
||||
|
||||
```bash
|
||||
# Iterative optimization flow
|
||||
Use gemini to analyze problems in current implementation
|
||||
→ Generate problem report (memory)
|
||||
|
||||
Have codex optimize code based on problem report
|
||||
→ Implement improvements (update memory)
|
||||
|
||||
Use qwen to verify optimization effectiveness
|
||||
→ Verification report (append to memory)
|
||||
|
||||
# All results accumulate as complete project memory
|
||||
→ Support subsequent decisions and implementation
|
||||
```
|
||||
|
||||
**Memory Flow Example**:
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ Phase 1: Analysis Phase (Generate Memory) │
|
||||
├─────────────────────────────────────────────────────────────┤
|
||||
│ Gemini analysis → Architecture report (.chat/analyze-001.md)│
|
||||
│ Qwen evaluation → Solution report (.chat/analyze-002.md) │
|
||||
└─────────────────────┬───────────────────────────────────────┘
|
||||
│ As Memory Input
|
||||
↓
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ Phase 2: Planning Phase (Use Memory) │
|
||||
├─────────────────────────────────────────────────────────────┤
|
||||
│ /workflow:plan → Read analysis reports → Generate plan │
|
||||
│ (.task/IMPL-*.json) │
|
||||
└─────────────────────┬───────────────────────────────────────┘
|
||||
│ As Memory Input
|
||||
↓
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ Phase 3: Implementation Phase (Use Memory) │
|
||||
├─────────────────────────────────────────────────────────────┤
|
||||
│ Codex implement → Read plan+analysis → Generate code │
|
||||
│ (.chat/execute-001.md) │
|
||||
└─────────────────────┬───────────────────────────────────────┘
|
||||
│ As Memory Input
|
||||
↓
|
||||
┌─────────────────────────────────────────────────────────────┐
|
||||
│ Phase 4: Verification Phase (Use Memory) │
|
||||
├─────────────────────────────────────────────────────────────┤
|
||||
│ Gemini review → Read implementation code → Quality report│
|
||||
│ (.chat/review-001.md) │
|
||||
└─────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
↓
|
||||
Complete Project Memory Library
|
||||
Supporting All Future Decisions and Implementation
|
||||
```
|
||||
|
||||
**Best Practices**:
|
||||
|
||||
1. **Maintain Continuity**: Execute related tasks in the same session to automatically share memory
|
||||
2. **Explicit References**: Explicitly reference historical analyses when crossing sessions (e.g., "Refer to WFS-xxx analysis")
|
||||
3. **Incremental Updates**: Each analysis and implementation appends to memory, forming complete decision chain
|
||||
4. **Regular Organization**: Use `/memory:update-related` to consolidate CLI results into CLAUDE.md
|
||||
5. **Quality First**: High-quality analysis memory significantly improves subsequent implementation quality
|
||||
|
||||
---
|
||||
|
||||
#### 🔄 Workflow Integration Examples
|
||||
|
||||
**Integration with Lite Workflow**:
|
||||
|
||||
Reference in New Issue
Block a user