ralph-multimodel
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRalph Wiggum Multi-Model Persistence Loop
Ralph Wiggum多模型持久化循环
LIBRARY-FIRST PROTOCOL (MANDATORY)
【库优先协议(强制要求)】
Before writing ANY code, you MUST check:
在编写任何代码之前,你必须完成以下检查:
Step 1: Library Catalog
步骤1:库目录
- Location:
.claude/library/catalog.json - If match >70%: REUSE or ADAPT
- 位置:
.claude/library/catalog.json - 若匹配度>70%:复用或适配
Step 2: Patterns Guide
步骤2:模式指南
- Location:
.claude/docs/inventories/LIBRARY-PATTERNS-GUIDE.md - If pattern exists: FOLLOW documented approach
- 位置:
.claude/docs/inventories/LIBRARY-PATTERNS-GUIDE.md - 若模式已存在:遵循文档中记录的方法
Step 3: Existing Projects
步骤3:现有项目
- Location:
D:\Projects\* - If found: EXTRACT and adapt
- 位置:
D:\Projects\* - 若找到相关内容:提取并适配
Decision Matrix
决策矩阵
| Match | Action |
|---|---|
| Library >90% | REUSE directly |
| Library 70-90% | ADAPT minimally |
| Pattern exists | FOLLOW pattern |
| In project | EXTRACT |
| No match | BUILD (add to library after) |
| 匹配度 | 操作 |
|---|---|
| 库匹配度>90% | 直接复用 |
| 库匹配度70-90% | 最小程度适配 |
| 模式已存在 | 遵循模式 |
| 项目中存在 | 提取 |
| 无匹配项 | 构建(完成后添加到库中) |
Purpose
目标
Extend the Ralph Wiggum persistence pattern with intelligent model routing:
- Gemini for research phases (search, megacontext, media)
- Codex for autonomous iteration (yolo, full-auto, sandbox)
- Claude for complex reasoning
- LLM Council for critical decisions
为Ralph Wiggum持久化模式扩展智能模型路由功能:
- Gemini 用于研究阶段(搜索、超大上下文、媒体处理)
- Codex 用于自主迭代(yolo、全自动、沙箱模式)
- Claude 用于复杂推理
- LLM Council 用于关键决策
Unique Capability
独特能力
What This Adds:
- Automatic model selection based on task phase
- Best-of-breed capabilities per iteration
- Fire-and-forget with optimal tool selection
- Multi-model consensus for critical decisions
新增功能包括:
- 根据任务阶段自动选择模型
- 每个迭代环节选用最优能力模型
- 无需干预的最优工具选择
- 关键决策的多模型共识机制
When to Use
使用场景
Perfect For:
适用场景:
- Complex tasks requiring multiple model strengths
- Overnight autonomous development
- Tasks mixing research + implementation + testing
- Critical decisions needing consensus
- Large codebase refactoring with validation
- 需要结合多种模型优势的复杂任务
- 夜间自主开发任务
- 混合了研究+实现+测试的任务
- 需要共识支持的关键决策
- 带验证环节的大型代码库重构
Don't Use When:
不适用场景:
- Simple single-model tasks
- Time-critical (model switching adds latency)
- Need human oversight at each step
- 简单的单模型任务
- 时间敏感型任务(模型切换会增加延迟)
- 需要在每个步骤都进行人工监督的任务
How It Works
工作原理
ITERATION N:
|
+---> Detect Task Phase
| |
| +---> Research? --> Gemini (search/megacontext)
| +---> Media? --> Gemini (imagen/veo)
| +---> Iterate? --> Codex (yolo/full-auto)
| +---> Decide? --> LLM Council (consensus)
| +---> Reason? --> Claude (agents)
|
+---> Execute with Optimal Model
|
+---> Check Completion Promise
| |
| +---> Found? --> EXIT SUCCESS
| +---> Not found? --> CONTINUE
|
+---> ITERATION N+1 (until max)第N次迭代:
|
+---> 检测任务阶段
| |
| +---> 研究阶段? --> Gemini(搜索/超大上下文)
| +---> 媒体处理? --> Gemini(Imagen/Veo)
| +---> 迭代开发? --> Codex(yolo/全自动)
| +---> 决策环节? --> LLM Council(共识决策)
| +---> 推理环节? --> Claude(Agent)
|
+---> 使用最优模型执行任务
|
+---> 检查完成标识
| |
| +---> 找到标识? --> 成功退出
| +---> 未找到标识? --> 继续循环
|
+---> 进入第N+1次迭代(直到达到最大次数)Usage
使用方法
Basic Multi-Model Loop
基础多模型循环
bash
/ralph-multimodel "Build REST API, research best practices, implement, test, fix failures until all pass"bash
/ralph-multimodel "构建REST API,研究最佳实践,实现功能,进行测试,修复失败项直至全部通过"With Codex Sandbox Mode
启用Codex沙箱模式
bash
CODEX_MODE=sandbox /ralph-multimodel "Experiment with auth refactoring, verify tests"bash
CODEX_MODE=sandbox /ralph-multimodel "实验认证重构,验证测试用例"With LLM Council for Decisions
启用LLM Council决策机制
bash
USE_COUNCIL=true /ralph-multimodel "Design authentication architecture with consensus"bash
USE_COUNCIL=true /ralph-multimodel "设计认证架构并达成共识"Overnight Task
夜间任务模式
bash
MAX_ITERATIONS=100 /ralph-multimodel "Complete feature X with documentation, Output <promise>DONE</promise> when finished"bash
MAX_ITERATIONS=100 /ralph-multimodel "完成功能X并编写文档,完成时输出 <promise>DONE</promise>"Command Pattern
命令模式
bash
bash scripts/multi-model/ralph-multimodel.sh "<task>" "<loop_id>"bash
bash scripts/multi-model/ralph-multimodel.sh "<任务内容>" "<循环ID>"Environment options:
环境变量选项:
MAX_ITERATIONS=30 # Maximum loop iterations
COMPLETION_PROMISE=DONE # Text signaling completion
USE_COUNCIL=false # Use LLM Council for decisions
CODEX_MODE=full-auto # Codex mode: yolo, full-auto, sandbox
undefinedMAX_ITERATIONS=30 # 最大循环迭代次数
COMPLETION_PROMISE=DONE # 标记任务完成的文本
USE_COUNCIL=false # 是否使用LLM Council进行决策
CODEX_MODE=full-auto # Codex模式:yolo、full-auto、sandbox
undefinedPhase Detection & Routing
阶段检测与路由
| Phase Detected | Keywords | Model Used |
|---|---|---|
| Research | "search", "latest", "documentation", "best practices" | Gemini |
| Megacontext | "entire codebase", "all files", "architecture overview" | Gemini --all-files |
| Media | "diagram", "mockup", "image", "video" | Gemini (Imagen/Veo) |
| Autonomous | "fix tests", "debug", "iterate", "prototype" | Codex (yolo/full-auto) |
| Decision | "decide", "choose", "architecture decision" | LLM Council |
| Reasoning | Default | Claude |
| 检测到的阶段 | 关键词 | 使用的模型 |
|---|---|---|
| 研究 | "search"、"latest"、"documentation"、"best practices" | Gemini |
| 超大上下文处理 | "entire codebase"、"all files"、"architecture overview" | Gemini --all-files |
| 媒体处理 | "diagram"、"mockup"、"image"、"video" | Gemini (Imagen/Veo) |
| 自主开发 | "fix tests"、"debug"、"iterate"、"prototype" | Codex (yolo/full-auto) |
| 决策 | "decide"、"choose"、"architecture decision" | LLM Council |
| 推理 | 默认 | Claude |
Memory Integration
内存集成
Results stored per iteration:
- Gemini:
multi-model/gemini/yolo/ralph-{iteration} - Codex:
multi-model/codex/yolo/ralph-{iteration} - Council:
multi-model/council/decisions/ralph-{iteration}
State files:
~/.claude/ralph-wiggum/loop-state.json~/.claude/ralph-wiggum/loop-history.log
每次迭代结果将存储至:
- Gemini:
multi-model/gemini/yolo/ralph-{iteration} - Codex:
multi-model/codex/yolo/ralph-{iteration} - Council:
multi-model/council/decisions/ralph-{iteration}
状态文件:
~/.claude/ralph-wiggum/loop-state.json~/.claude/ralph-wiggum/loop-history.log
Integration with Meta-Loop
与元循环的集成
Ralph Multi-Model connects to the recursive improvement system:
META-LOOP INTEGRATION:
|
+---> PROPOSE (auditors detect issues)
| |
| +---> Ralph Multi-Model for implementation
|
+---> TEST (frozen eval harness)
|
+---> COMPARE (baseline vs candidate)
|
+---> COMMIT (if improved)
|
+---> MONITOR (7-day window)
|
+---> ROLLBACK (if regressed)Ralph多模型循环可接入递归改进系统:
元循环集成流程:
|
+---> 提议(审计人员检测问题)
| |
| +---> 调用Ralph多模型循环实现改进
|
+---> 测试(冻结评估框架)
|
+---> 对比(基准版本 vs 候选版本)
|
+---> 提交(若有改进)
|
+---> 监控(7天窗口期)
|
+---> 回滚(若出现退化)Real-World Examples
实际应用示例
Example 1: Full-Stack Feature
示例1:全栈功能开发
bash
/ralph-multimodel "Build user dashboard:
1. Research React dashboard best practices (Gemini)
2. Generate UI mockup (Gemini Media)
3. Implement frontend components (Claude)
4. Build backend API (Codex yolo)
5. Write tests (Claude)
6. Fix all failing tests (Codex full-auto)
Output <promise>ALL_TESTS_PASS</promise> when done"bash
/ralph-multimodel "构建用户仪表盘:
1. 研究React仪表盘最佳实践(Gemini)
2. 生成UI原型图(Gemini Media)
3. 实现前端组件(Claude)
4. 构建后端API(Codex yolo)
5. 编写测试用例(Claude)
6. 修复所有失败测试(Codex full-auto)
完成时输出 <promise>ALL_TESTS_PASS</promise>"Example 2: Codebase Refactoring
示例2:代码库重构
bash
MAX_ITERATIONS=50 CODEX_MODE=sandbox /ralph-multimodel "
Refactor auth system:
1. Analyze entire codebase architecture (Gemini megacontext)
2. Identify all auth touchpoints
3. Implement new JWT pattern in sandbox (Codex)
4. Run tests and fix failures
Output <promise>REFACTOR_COMPLETE</promise> when all tests pass"bash
MAX_ITERATIONS=50 CODEX_MODE=sandbox /ralph-multimodel "
重构认证系统:
1. 分析整个代码库架构(Gemini超大上下文)
2. 识别所有认证相关节点
3. 在沙箱中实现新的JWT模式(Codex)
4. 运行测试并修复失败项
所有测试通过时输出 <promise>REFACTOR_COMPLETE</promise>"Example 3: Architecture Decision
示例3:架构决策
bash
USE_COUNCIL=true /ralph-multimodel "
Decide database strategy:
1. Research PostgreSQL vs MongoDB for our use case (Gemini)
2. Get multi-model consensus on approach (Council)
3. Document decision
Output <promise>DECISION_MADE</promise>"bash
USE_COUNCIL=true /ralph-multimodel "
确定数据库策略:
1. 研究PostgreSQL与MongoDB在本场景的适用性(Gemini)
2. 获取多模型对方案的共识(Council)
3. 记录决策结果
完成时输出 <promise>DECISION_MADE</promise>"Success Indicators
成功指标
- Loop completes with COMPLETION_PROMISE found
- Optimal model used for each phase
- Memory contains full iteration history
- State files show successful completion
- 循环完成且检测到COMPLETION_PROMISE标识
- 每个阶段都使用了最优模型
- 内存中保存了完整的迭代历史
- 状态文件显示任务成功完成
Troubleshooting
故障排查
Loop Never Completes
循环无法完成
- Check COMPLETION_PROMISE is achievable
- Increase MAX_ITERATIONS
- Verify task includes clear completion criteria
- 检查COMPLETION_PROMISE是否可实现
- 增加MAX_ITERATIONS数值
- 确认任务包含明确的完成标准
Wrong Model Selected
模型选择错误
- Be more explicit in task description
- Use phase keywords (see routing table)
- 在任务描述中更明确地说明需求
- 使用阶段关键词(参考路由表)
Codex Failures
Codex执行失败
- Check Codex CLI is installed
- Verify ChatGPT Plus subscription active
- Try different CODEX_MODE
- 检查Codex CLI是否已安装
- 验证ChatGPT Plus订阅是否有效
- 尝试切换不同的CODEX_MODE
Related Resources
相关资源
- Ralph Wiggum Loop:
skills/orchestration/ralph-loop/SKILL.md - Multi-Model Scripts:
scripts/multi-model/ - Meta-Loop:
skills/recursive-improvement/ - Memory Namespace:
docs/MEMORY-NAMESPACE-SCHEMA.yaml
- Ralph Wiggum循环:
skills/orchestration/ralph-loop/SKILL.md - 多模型脚本:
scripts/multi-model/ - 元循环:
skills/recursive-improvement/ - 内存命名空间:
docs/MEMORY-NAMESPACE-SCHEMA.yaml