ralph-loop by belumume/claude-skills
npx skills add https://github.com/belumume/claude-skills --skill ralph-loop此模式以《辛普森一家》中“即使困惑也永不停止”的角色命名,它让 Claude Code 在循环中运行,其中提示保持不变,但代码库会累积变更。每次迭代都会读取先前的工作并持续进行,直至任务完成。
适用于:
不适用于:
激活前,请确认:
创建 .claude/ralph-loop.local.md,结构如下:
---
active: true
iteration: 0
max_iterations: 20
completion_promise: null
---
# 你的任务提示写在这里
## 目标
[需要完成事项的清晰陈述]
## 完成标准
当 TODO.md 显示 [x] ALL_TASKS_COMPLETE 时完成
## 验证命令
运行以下命令检查进度:
- `[测试命令]`
- `[构建命令]`
## 上下文
- 阅读 [相关文件] 以了解规范
- 遵循 [约定文件] 的代码风格
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
在你的项目根目录创建 TODO.md:
# 任务清单
## 任务
- [ ] 任务 1
- [ ] 任务 2
- [ ] 任务 3
## 完成情况
- [ ] ALL_TASKS_COMPLETE
只需正常运行 Claude。Stop 钩子将检测到状态文件并保持循环运行,直到检测到完成。
claude
钩子会检查 TODO.md 中是否存在 [x] ALL_TASKS_COMPLETE。这种方法更可靠,因为:
在状态文件中设置 completion_promise,并在完成时输出 <promise>YOUR_TEXT</promise>。
---
active: true
iteration: 0
max_iterations: 20
completion_promise: "feature implemented"
---
当 Claude 输出 <promise>feature implemented</promise> 时,循环结束。
在 .claude/ralph-loop.local.md 的 frontmatter 中:
| 选项 | 默认值 | 描述 |
|---|---|---|
active | true | 设置为 false 以禁用循环 |
iteration | 0 | 当前迭代次数(自动递增) |
max_iterations | 20 | 安全上限(0 = 无限制) |
completion_promise | null | 用于匹配承诺完成的文本 |
每次迭代显示:
每 5 次迭代,你会看到一个检查点提醒,以便:
git log --oneline -10暂停循环:
# 编辑状态文件
# 将 active: true 改为 active: false
立即停止:
rm .claude/ralph-loop.local.md
恢复:
# 重新创建或编辑状态文件
# 设置 active: true
claude
---
active: true
iteration: 0
max_iterations: 25
completion_promise: null
---
# MetricFlow 第 7-8 阶段:教育者代理
## 目标
实现教育者代理,该代理使用 Claude API 为代码指标生成教育性解释。
## 完成标准
当 TODO.md 显示 [x] ALL_TASKS_COMPLETE 时完成
## 验证命令
- `cd backend && python -m pytest tests/test_educator.py -v`
- `cd backend && python -c "from app.agents.educator import EducatorAgent; print('OK')"`
## 上下文
- 阅读 docs/plans/MASTER_PLAN.md 第 5.3 节(教育者代理)
- 遵循 CLAUDE.md 中的项目约定
- 分析器和模式代理已完成(使用它们的输出格式)
## 说明
1. 检查 TODO.md 获取当前任务列表
2. 实现下一个未完成的任务
3. 边开发边编写测试
4. 每次更改后运行验证
5. 完成后标记 [x] ALL_TASKS_COMPLETE
以及对应的 TODO.md:
# 第 7-8 阶段:教育者代理
## 任务
- [ ] 在 backend/app/agents/educator.py 中创建 EducatorAgent 类骨架
- [ ] 添加 Claude API 客户端初始化
- [ ] 实现 explain_complexity() 方法
- [ ] 实现 explain_maintainability() 方法
- [ ] 实现 explain_code_smells() 方法
- [ ] 添加课程概念映射
- [ ] 为所有方法编写单元测试
- [ ] 与 Analyzer 输出的集成测试
## 完成情况
- [ ] ALL_TASKS_COMPLETE
循环无法启动:
.claude/ralph-loop.local.md 是否存在active: true循环无法停止:
[x] ALL_TASKS_COMPLETE(不区分大小写)completion_promise 是否与你的输出标签匹配max_iterations 是否未设置为 0(无限制)rm .claude/ralph-loop.local.md卡在同一个错误上:
成本过高:
max_iterations| 任务复杂度 | 迭代次数 | 估算成本 |
|---|---|---|
| 简单(单一功能) | 5-10 | $5-15 |
| 中等(多文件更改) | 10-20 | $15-30 |
| 复杂(完整阶段) | 20-50 | $30-75 |
# 1. 创建状态文件
mkdir -p .claude
cat > .claude/ralph-loop.local.md << 'EOF'
---
active: true
iteration: 0
max_iterations: 20
completion_promise: null
---
# 你的任务
## 目标
[你想要完成什么]
## 完成情况
检查 TODO.md 中的 [x] ALL_TASKS_COMPLETE
EOF
# 2. 创建 TODO.md
cat > TODO.md << 'EOF'
# 任务
- [ ] 第一个任务
- [ ] 第二个任务
## 完成情况
- [ ] ALL_TASKS_COMPLETE
EOF
# 3. 启动 Ralph 循环
claude
每周安装次数
71
代码仓库
GitHub 星标数
43
首次出现时间
2026年1月23日
安全审计
安装于
gemini-cli64
opencode63
codex63
cursor61
github-copilot59
kimi-cli52
Named after the Simpsons character who "never stops despite being confused," this technique runs Claude Code in a loop where the prompt stays the same but the codebase accumulates changes. Each iteration reads previous work and continues until completion.
Ideal for:
Not ideal for:
Before activating, confirm:
Create .claude/ralph-loop.local.md with the following structure:
---
active: true
iteration: 0
max_iterations: 20
completion_promise: null
---
# Your Task Prompt Here
## Objective
[Clear statement of what needs to be accomplished]
## Completion Criteria
Complete when TODO.md shows [x] ALL_TASKS_COMPLETE
## Verification Commands
Run these to check progress:
- `[test command]`
- `[build command]`
## Context
- Read [relevant files] for specifications
- Follow [conventions file] for code style
Create TODO.md in your project root:
# Task Checklist
## Tasks
- [ ] Task 1
- [ ] Task 2
- [ ] Task 3
## Completion
- [ ] ALL_TASKS_COMPLETE
Simply run Claude normally. The Stop hook will detect the state file and keep the loop running until completion is detected.
claude
The hook checks TODO.md for [x] ALL_TASKS_COMPLETE. This is more reliable because:
Set completion_promise in the state file and output <promise>YOUR_TEXT</promise> when complete.
---
active: true
iteration: 0
max_iterations: 20
completion_promise: "feature implemented"
---
When Claude outputs <promise>feature implemented</promise>, the loop ends.
In .claude/ralph-loop.local.md frontmatter:
| Option | Default | Description |
|---|---|---|
active | true | Set to false to disable loop |
iteration | 0 | Current iteration count (auto-incremented) |
max_iterations | 20 | Safety cap (0 = unlimited) |
Every iteration shows:
Every 5 iterations, you'll see a checkpoint reminder to:
git log --oneline -10To pause the loop:
# Edit the state file
# Change active: true → active: false
To stop immediately:
rm .claude/ralph-loop.local.md
To resume:
# Re-create or edit the state file
# Set active: true
claude
---
active: true
iteration: 0
max_iterations: 25
completion_promise: null
---
# MetricFlow Phase 7-8: Educator Agent
## Objective
Implement the Educator Agent that uses Claude API to generate educational
explanations for code metrics.
## Completion Criteria
Complete when TODO.md shows [x] ALL_TASKS_COMPLETE
## Verification Commands
- `cd backend && python -m pytest tests/test_educator.py -v`
- `cd backend && python -c "from app.agents.educator import EducatorAgent; print('OK')"`
## Context
- Read docs/plans/MASTER_PLAN.md sections 5.3 (Educator Agent)
- Follow CLAUDE.md for project conventions
- Analyzer and Pattern agents already complete (use their output formats)
## Instructions
1. Check TODO.md for current task list
2. Implement next incomplete task
3. Write tests as you go
4. Run verification after each change
5. Mark [x] ALL_TASKS_COMPLETE when done
And corresponding TODO.md:
# Phase 7-8: Educator Agent
## Tasks
- [ ] Create EducatorAgent class skeleton in backend/app/agents/educator.py
- [ ] Add Claude API client initialization
- [ ] Implement explain_complexity() method
- [ ] Implement explain_maintainability() method
- [ ] Implement explain_code_smells() method
- [ ] Add course concept mapping
- [ ] Write unit tests for all methods
- [ ] Integration test with Analyzer output
## Completion
- [ ] ALL_TASKS_COMPLETE
Loop won't start:
.claude/ralph-loop.local.md existsactive: true is set in frontmatterLoop won't stop:
[x] ALL_TASKS_COMPLETE (case-insensitive)completion_promise matches your output tagmax_iterations isn't set to 0 (unlimited)rm .claude/ralph-loop.local.mdStuck on same error:
Costs too high:
max_iterations| Task Complexity | Iterations | Estimated Cost |
|---|---|---|
| Simple (single feature) | 5-10 | $5-15 |
| Medium (multi-file changes) | 10-20 | $15-30 |
| Complex (full phase) | 20-50 | $30-75 |
# 1. Create state file
mkdir -p .claude
cat > .claude/ralph-loop.local.md << 'EOF'
---
active: true
iteration: 0
max_iterations: 20
completion_promise: null
---
# Your Task
## Objective
[What you want to accomplish]
## Completion
Check TODO.md for [x] ALL_TASKS_COMPLETE
EOF
# 2. Create TODO.md
cat > TODO.md << 'EOF'
# Tasks
- [ ] First task
- [ ] Second task
## Completion
- [ ] ALL_TASKS_COMPLETE
EOF
# 3. Start Ralph loop
claude
Weekly Installs
71
Repository
GitHub Stars
43
First Seen
Jan 23, 2026
Security Audits
Gen Agent Trust HubFailSocketPassSnykPass
Installed on
gemini-cli64
opencode63
codex63
cursor61
github-copilot59
kimi-cli52
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
157,400 周安装
SceneKit转RealityKit完整API参考与迁移指南 | 3D图形渲染开发必备
103 周安装
reclaude:渐进式披露重构CLAUDE.md文件,优化AI助手配置与工作流
103 周安装
popo-document-browser - 开源文档浏览器工具,支持多平台集成与高效文档管理
103 周安装
设计令牌生成器:基于数学公式自动创建字体比例、色彩调色板与间距系统,支持CSS/Tailwind输出
103 周安装
canghe-post-to-wechat:自动化微信公众号文章发布工具,支持API与浏览器发布
103 周安装
Blender网络管线:glTF 2.0导出、Python自动化与Web 3D优化工作流
103 周安装
completion_promise | null | Text to match for promise completion |