ralph-methodology

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Ralph Loop Mechanics

Ralph循环机制

How It Works

工作原理

  1. Start: User runs
    /majestic-ralph:start "<prompt>" --max-iterations N --completion-promise "WORD"
  2. Loop: Stop hook intercepts session exit, re-feeds same prompt
  3. Exit: Output
    <promise>WORD</promise>
    to signal genuine completion
  1. 启动: 用户运行
    /majestic-ralph:start "<prompt>" --max-iterations N --completion-promise "WORD"
  2. 循环: 停止钩子拦截会话退出,重新传入相同的提示词
  3. 退出: 输出
    <promise>WORD</promise>
    以表示真正完成

State File

状态文件

Location:
.claude/ralph-loop.local.yml
yaml
iteration: 1
max_iterations: 50
completion_promise: DONE
started_at: 2024-01-15T10:30:00Z
prompt: |
  Your prompt here.
  Can be multiline.
位置:
.claude/ralph-loop.local.yml
yaml
iteration: 1
max_iterations: 50
completion_promise: DONE
started_at: 2024-01-15T10:30:00Z
prompt: |
  你的提示词在此处。
  可以是多行。

Completion Signal

完成信号

Output exactly:
<promise>YOUR_PHRASE</promise>
  • Only output when genuinely complete
  • Lying restarts the loop
  • Max iterations is a hard stop
精确输出:
<promise>YOUR_PHRASE</promise>
  • 仅在真正完成时输出
  • 若提前输出会重启循环
  • 最大迭代次数是强制停止条件

Safety Rules

安全规则

RuleReason
Idempotent operationsMigrations with
IF NOT EXISTS
, etc.
Non-interactive commandsNo
-i
flags, no prompts
Clear exit criteriaVague goals loop forever
规则原因
幂等操作迁移时使用
IF NOT EXISTS
等语句
非交互式命令不使用
-i
参数,不出现提示
明确的退出条件模糊的目标会导致无限循环

Monitoring

监控

bash
undefined
bash
undefined

Check iteration

查看迭代次数

grep '^iteration:' .claude/ralph-loop.local.yml
grep '^iteration:' .claude/ralph-loop.local.yml

Cancel loop

取消循环

/majestic-ralph:cancel
undefined
/majestic-ralph:cancel
undefined