ralph

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

ralph (Ouroboros) — Specification-First AI Development

ralph (Ouroboros) — 规约优先AI开发

Stop prompting. Start specifying.
"The beginning is the end, and the end is the beginning." The serpent doesn't repeat — it evolves.

停止输入提示词,开始明确规约。
「起点即终点,终点即起点。」 衔尾蛇不会重复,只会不断演化。

When to use this skill

什么时候使用这个技能

  • Before writing any code — expose hidden assumptions with Socratic interviewing
  • Long-running tasks that need autonomous iteration until verified
  • Vague requirements — crystallize them into an immutable spec (Ambiguity ≤ 0.2)
  • Tasks requiring guaranteed completion — loop until verification passes
  • When stuck — 5 lateral thinking personas break through stagnation
  • Drift detection — measure how far execution has deviated from original spec

  • 编写任何代码之前 — 通过苏格拉底式访谈暴露隐藏的假设
  • 需要自主迭代直到通过验证的长期运行任务
  • 模糊的需求 — 将其具象化为不可变更的规约(歧义度 ≤ 0.2)
  • 需要保证完成的任务 — 循环运行直到验证通过
  • 遇到瓶颈时 — 5种横向思考角色帮你突破停滞
  • 偏差检测 — 衡量执行与原始规约的偏离程度

Core Architecture: The Loop

核心架构:循环

    Interview → Seed → Execute → Evaluate
        ↑                           ↓
        └──── Evolutionary Loop ────┘
Each cycle evolves, not repeats. Evaluation output feeds back as input for the next generation until the system converges.
    Interview → Seed → Execute → Evaluate
        ↑                           ↓
        └──── Evolutionary Loop ────┘
每个周期都是演化而非重复。评估的输出会作为下一代的输入反馈回去,直到系统收敛。

Double Diamond

双钻石模型

    ◇ Wonder          ◇ Design
   ╱  (diverge)      ╱  (diverge)
  ╱    explore      ╱    create
 ╱                 ╱
◆ ──────────── ◆ ──────────── ◆
 ╲                 ╲
  ╲    define       ╲    deliver
   ╲  (converge)     ╲  (converge)
    ◇ Ontology        ◇ Evaluation
The first diamond is Socratic: diverge into questions, converge into ontological clarity. The second diamond is pragmatic: diverge into design options, converge into verified delivery.

    ◇ Wonder          ◇ Design
   ╱  (diverge)      ╱  (diverge)
  ╱    explore      ╱    create
 ╱                 ╱
◆ ──────────── ◆ ──────────── ◆
 ╲                 ╲
  ╲    define       ╲    deliver
   ╲  (converge)     ╲  (converge)
    ◇ Ontology        ◇ Evaluation
第一个钻石是苏格拉底式的:发散提出问题,收敛获得清晰的本体定义。第二个钻石是务实导向的:发散设计方案,收敛得到验证过的交付成果。

1. Commands (Full Reference)

1. 命令(完整参考)

CommandTrigger KeywordsWhat It Does
ooo interview
ooo interview
,
interview me
,
clarify requirements
,
socratic questioning
Socratic questioning → expose hidden assumptions
ooo seed
ooo seed
,
crystallize
,
generate seed
,
freeze requirements
Crystallize interview into immutable spec (Ambiguity ≤ 0.2)
ooo run
ooo run
,
execute seed
,
ouroboros run
Execute via Double Diamond decomposition
ooo evaluate
ooo evaluate
,
3-stage check
,
evaluate this
,
verify execution
3-stage gate: Mechanical → Semantic → Multi-Model Consensus
ooo evolve
ooo evolve
,
evolutionary loop
,
iterate until converged
Evolutionary loop until ontology converges (similarity ≥ 0.95)
ooo unstuck
ooo unstuck
,
I'm stuck
,
think sideways
,
lateral thinking
5 lateral thinking personas when stuck
ooo status
ooo status
,
am I drifting?
,
drift check
,
session status
Drift detection + session tracking
ooo ralph
ooo ralph
,
ralph
,
don't stop
,
must complete
,
keep going
Persistent loop until verified — The boulder never stops
ooo setup
ooo setup
Register MCP server (one-time)
ooo help
ooo help
Full reference

CommandTrigger KeywordsWhat It Does
ooo interview
ooo interview
,
interview me
,
clarify requirements
,
socratic questioning
苏格拉底式提问 → 暴露隐藏的假设
ooo seed
ooo seed
,
crystallize
,
generate seed
,
freeze requirements
将访谈内容具象化为不可变更的规约(歧义度 ≤ 0.2)
ooo run
ooo run
,
execute seed
,
ouroboros run
通过双钻石模型拆解执行
ooo evaluate
ooo evaluate
,
3-stage check
,
evaluate this
,
verify execution
三阶段校验:机械校验 → 语义校验 → 多模型共识
ooo evolve
ooo evolve
,
evolutionary loop
,
iterate until converged
演化循环直到本体收敛(相似度 ≥ 0.95)
ooo unstuck
ooo unstuck
,
I'm stuck
,
think sideways
,
lateral thinking
遇到瓶颈时提供5种横向思考角色
ooo status
ooo status
,
am I drifting?
,
drift check
,
session status
偏差检测 + 会话追踪
ooo ralph
ooo ralph
,
ralph
,
don't stop
,
must complete
,
keep going
持续循环直到通过验证——巨石永不停歇
ooo setup
ooo setup
注册MCP服务器(仅需一次)
ooo help
ooo help
完整参考文档

2. Interview → Specification Flow

2. 访谈→规约流程

Philosophy: From Wonder to Ontology

设计理念:从疑问到本体

Wonder → "How should I live?" → "What IS 'live'?" → Ontology — Socrates
   Wonder                          Ontology
     💡                               🔬
"What do I want?"    →    "What IS the thing I want?"
"Build a task CLI"   →    "What IS a task? What IS priority?"
"Fix the auth bug"   →    "Is this the root cause, or a symptom?"
疑问 → "我应该怎么活?" → "什么是『活』?" → 本体 — 苏格拉底
   Wonder                          Ontology
     💡                               🔬
"What do I want?"    →    "What IS the thing I want?"
"Build a task CLI"   →    "What IS a task? What IS priority?"
"Fix the auth bug"   →    "Is this the root cause, or a symptom?"

Step 1: Interview (expose hidden assumptions)

步骤1:访谈(暴露隐藏假设)

ooo interview "I want to build a task management CLI"
The Socratic Interviewer asks questions until Ambiguity ≤ 0.2.
Ambiguity formula:
Ambiguity = 1 − Σ(clarityᵢ × weightᵢ)

Greenfield: Goal(40%) + Constraint(30%) + Success(30%)
Brownfield: Goal(35%) + Constraint(25%) + Success(25%) + Context(15%)

Threshold: Ambiguity ≤ 0.2 → ready for Seed
Example scoring:
Goal:       0.9 × 0.4 = 0.36
Constraint: 0.8 × 0.3 = 0.24
Success:    0.7 × 0.3 = 0.21
                        ──────
Clarity             = 0.81
Ambiguity = 1 − 0.81 = 0.19 ≤ 0.2 → ✓ Ready for Seed
ooo interview "I want to build a task management CLI"
苏格拉底式访谈者会持续提问直到歧义度 ≤ 0.2
歧义度计算公式:
Ambiguity = 1 − Σ(clarityᵢ × weightᵢ)

Greenfield: Goal(40%) + Constraint(30%) + Success(30%)
Brownfield: Goal(35%) + Constraint(25%) + Success(25%) + Context(15%)

Threshold: Ambiguity ≤ 0.2 → ready for Seed
评分示例:
Goal:       0.9 × 0.4 = 0.36
Constraint: 0.8 × 0.3 = 0.24
Success:    0.7 × 0.3 = 0.21
                        ──────
Clarity             = 0.81
Ambiguity = 1 − 0.81 = 0.19 ≤ 0.2 → ✓ 可以进入生成种子阶段

Step 2: Seed (crystallize into immutable spec)

步骤2:生成种子(具象化为不可变更的规约)

ooo seed
Generates YAML specification:
yaml
goal: Build a CLI task management tool
constraints:
  - Python 3.14+
  - No external database
  - SQLite for persistence
acceptance_criteria:
  - Tasks can be created
  - Tasks can be listed
  - Tasks can be marked complete
ontology_schema:
  name: TaskManager
  fields:
    - name: tasks
      type: array
    - name: title
      type: string
ooo seed
生成YAML格式的规约:
yaml
goal: Build a CLI task management tool
constraints:
  - Python 3.14+
  - No external database
  - SQLite for persistence
acceptance_criteria:
  - Tasks can be created
  - Tasks can be listed
  - Tasks can be marked complete
ontology_schema:
  name: TaskManager
  fields:
    - name: tasks
      type: array
    - name: title
      type: string

Step 3: Run (execute via Double Diamond)

步骤3:运行(通过双钻石模型执行)

ooo run seed.yaml
ooo run  # uses seed from conversation context
ooo run seed.yaml
ooo run  # 使用会话上下文中的种子规约

Step 4: Evaluate (3-stage verification)

步骤4:评估(三阶段验证)

ooo evaluate <session_id>
StageCostWhat It Checks
Mechanical$0Lint, build, tests, coverage
SemanticStandardAC compliance, goal alignment, drift score
ConsensusFrontier (optional)Multi-model vote, majority ratio
Drift thresholds:
  • 0.0 – 0.15
    — Excellent: on track
  • 0.15 – 0.30
    — Acceptable: monitor closely
  • 0.30+
    — Exceeded: course correction needed

ooo evaluate <session_id>
阶段成本校验内容
机械校验$0语法检查、构建、测试、覆盖率
语义校验标准验收标准合规性、目标对齐度、偏差得分
共识校验高级(可选)多模型投票,多数通过
偏差阈值:
  • 0.0 – 0.15
    — 优秀:正常推进
  • 0.15 – 0.30
    — 可接受:密切监控
  • 0.30+
    — 超出阈值:需要修正方向

3. Ralph — Persistent Loop Until Verified

3. Ralph — 持续循环直到验证通过

ooo ralph "fix all failing tests"
/ouroboros:ralph "fix all failing tests"
"The boulder never stops." Each failure is data for the next attempt. Only complete success or max iterations stops it.
ooo ralph "fix all failing tests"
/ouroboros:ralph "fix all failing tests"
「巨石永不停歇。」 每一次失败都是下一次尝试的数据输入。只有完全成功或达到最大迭代次数才会停止。

How Ralph Works

Ralph运行原理

┌─────────────────────────────────┐
│  1. EXECUTE (parallel)          │
│     Independent tasks           │
│     concurrent scheduling       │
├─────────────────────────────────┤
│  2. VERIFY                      │
│     Check completion            │
│     Validate tests pass         │
│     Measure drift vs seed       │
├─────────────────────────────────┤
│  3. LOOP (if failed)            │
│     Analyze failure             │
│     Fix identified issues       │
│     Repeat from step 1          │
├─────────────────────────────────┤
│  4. PERSIST (checkpoint)        │
│     .omc/state/ralph-state.json │
│     Resume after interruption   │
└─────────────────────────────────┘
┌─────────────────────────────────┐
│  1. EXECUTE (parallel)          │
│     Independent tasks           │
│     concurrent scheduling       │
├─────────────────────────────────┤
│  2. VERIFY                      │
│     Check completion            │
│     Validate tests pass         │
│     Measure drift vs seed       │
├─────────────────────────────────┤
│  3. LOOP (if failed)            │
│     Analyze failure             │
│     Fix identified issues       │
│     Repeat from step 1          │
├─────────────────────────────────┤
│  4. PERSIST (checkpoint)        │
│     .omc/state/ralph-state.json │
│     Resume after interruption   │
└─────────────────────────────────┘

State File

状态文件

Create
.omc/state/ralph-state.json
on start:
json
{
  "mode": "ralph",
  "session_id": "<uuid>",
  "request": "<user request>",
  "status": "running",
  "iteration": 0,
  "max_iterations": 10,
  "last_checkpoint": null,
  "verification_history": []
}
启动时创建
.omc/state/ralph-state.json
json
{
  "mode": "ralph",
  "session_id": "<uuid>",
  "request": "<user request>",
  "status": "running",
  "iteration": 0,
  "max_iterations": 10,
  "last_checkpoint": null,
  "verification_history": []
}

Loop Logic

循环逻辑

while iteration < max_iterations:
    result = execute_parallel(request, context)
    verification = verify_result(result, acceptance_criteria)
    state.verification_history.append({
        "iteration": iteration,
        "passed": verification.passed,
        "score": verification.score,
        "timestamp": <now>
    })
    if verification.passed:
        save_checkpoint("complete")
        break
    iteration += 1
    save_checkpoint("iteration_{iteration}")
while iteration < max_iterations:
    result = execute_parallel(request, context)
    verification = verify_result(result, acceptance_criteria)
    state.verification_history.append({
        "iteration": iteration,
        "passed": verification.passed,
        "score": verification.score,
        "timestamp": <now>
    })
    if verification.passed:
        save_checkpoint("complete")
        break
    iteration += 1
    save_checkpoint("iteration_{iteration}")

Progress Report Format

进度报告格式

[Ralph Iteration 1/10]
Executing in parallel...

Verification: FAILED
Score: 0.65
Issues:
- 3 tests still failing
- Type errors in src/api.py

The boulder never stops. Continuing...

[Ralph Iteration 3/10]
Executing in parallel...

Verification: PASSED
Score: 1.0

Ralph COMPLETE
==============
Request: Fix all failing tests
Duration: 8m 32s
Iterations: 3

Verification History:
- Iteration 1: FAILED (0.65)
- Iteration 2: FAILED (0.85)
- Iteration 3: PASSED (1.0)
[Ralph Iteration 1/10]
Executing in parallel...

Verification: FAILED
Score: 0.65
Issues:
- 3 tests still failing
- Type errors in src/api.py

The boulder never stops. Continuing...

[Ralph Iteration 3/10]
Executing in parallel...

Verification: PASSED
Score: 1.0

Ralph COMPLETE
==============
Request: Fix all failing tests
Duration: 8m 32s
Iterations: 3

Verification History:
- Iteration 1: FAILED (0.65)
- Iteration 2: FAILED (0.85)
- Iteration 3: PASSED (1.0)

Cancellation

取消操作

ActionCommand
Save checkpoint & exit
/ouroboros:cancel
Force clear all state
/ouroboros:cancel --force
Resume after interruption
ooo ralph continue
or
ralph continue

操作命令
保存检查点并退出
/ouroboros:cancel
强制清空所有状态
/ouroboros:cancel --force
中断后恢复
ooo ralph continue
ralph continue

4. Evolutionary Loop (Evolve)

4. 演化循环(Evolve)

ooo evolve "build a task management CLI"
ooo evolve "build a task management CLI" --no-execute  # ontology-only, fast mode
ooo evolve "build a task management CLI"
ooo evolve "build a task management CLI" --no-execute  # 仅生成本体,快速模式

Flow

流程

Gen 1: Interview → Seed(O₁) → Execute → Evaluate
Gen 2: Wonder → Reflect → Seed(O₂) → Execute → Evaluate
Gen 3: Wonder → Reflect → Seed(O₃) → Execute → Evaluate
...until ontology converges (similarity ≥ 0.95) or max 30 generations
Gen 1: Interview → Seed(O₁) → Execute → Evaluate
Gen 2: Wonder → Reflect → Seed(O₂) → Execute → Evaluate
Gen 3: Wonder → Reflect → Seed(O₃) → Execute → Evaluate
...直到本体收敛(相似度 ≥ 0.95)或达到最大30代

Convergence Formula

收敛公式

Similarity = 0.5 × name_overlap + 0.3 × type_match + 0.2 × exact_match
Threshold: Similarity ≥ 0.95 → CONVERGED

Gen 1: {Task, Priority, Status}
Gen 2: {Task, Priority, Status, DueDate}  → similarity 0.78 → CONTINUE
Gen 3: {Task, Priority, Status, DueDate}  → similarity 1.00 → CONVERGED ✓
Similarity = 0.5 × name_overlap + 0.3 × type_match + 0.2 × exact_match
Threshold: Similarity ≥ 0.95 → CONVERGED

Gen 1: {Task, Priority, Status}
Gen 2: {Task, Priority, Status, DueDate}  → similarity 0.78 → CONTINUE
Gen 3: {Task, Priority, Status, DueDate}  → similarity 1.00 → CONVERGED ✓

Stagnation Detection

停滞检测

SignalConditionMeaning
StagnationSimilarity ≥ 0.95 for 3 consecutive gensOntology has stabilized
OscillationGen N ≈ Gen N-2 (period-2 cycle)Stuck bouncing between two designs
Repetitive feedback≥ 70% question overlap across 3 gensWonder asking the same things
Hard cap30 generations reachedSafety valve
信号条件含义
停滞连续3代相似度 ≥ 0.95本体已稳定
震荡第N代 ≈ 第N-2代(周期2循环)在两个设计之间来回摇摆
重复反馈3代的问题重叠度 ≥ 70%一直在询问相同的问题
上限达到30代安全阈值触发

Ralph in Evolve Mode

演化模式下的Ralph

Ralph Cycle 1: evolve_step(lineage, seed) → Gen 1 → action=CONTINUE
Ralph Cycle 2: evolve_step(lineage)       → Gen 2 → action=CONTINUE
Ralph Cycle 3: evolve_step(lineage)       → Gen 3 → action=CONVERGED ✓
                                                └── Ralph stops.
                                                    The ontology has stabilized.
Ralph Cycle 1: evolve_step(lineage, seed) → Gen 1 → action=CONTINUE
Ralph Cycle 2: evolve_step(lineage)       → Gen 2 → action=CONTINUE
Ralph Cycle 3: evolve_step(lineage)       → Gen 3 → action=CONVERGED ✓
                                                └── Ralph stops.
                                                    The ontology has stabilized.

Rewind

回滚

ooo evolve --status <lineage_id>          # check lineage status
ooo evolve --rewind <lineage_id> <gen_N>  # roll back to generation N

ooo evolve --status <lineage_id>          # 查看谱系状态
ooo evolve --rewind <lineage_id> <gen_N>  # 回滚到第N代

5. The Nine Minds (Agents)

5. 九种思维(Agents)

Loaded on-demand — never preloaded:
AgentRoleCore Question
Socratic InterviewerQuestions-only. Never builds."What are you assuming?"
OntologistFinds essence, not symptoms"What IS this, really?"
Seed ArchitectCrystallizes specs from dialogue"Is this complete and unambiguous?"
Evaluator3-stage verification"Did we build the right thing?"
ContrarianChallenges every assumption"What if the opposite were true?"
HackerFinds unconventional paths"What constraints are actually real?"
SimplifierRemoves complexity"What's the simplest thing that could work?"
ResearcherStops coding, starts investigating"What evidence do we actually have?"
ArchitectIdentifies structural causes"If we started over, would we build it this way?"

按需加载,不会预加载:
Agent角色核心问题
苏格拉底式访谈者只提问题,从不构建「你在假设什么?」
本体专家找到本质,而非表象「这到底是什么?」
种子架构师从对话中具象化规约「这个规约完整且无歧义吗?」
评估者三阶段验证「我们构建的是正确的东西吗?」
唱反调者挑战所有假设「如果反过来是对的呢?」
黑客找到非常规路径「哪些约束是真的存在的?」
简化者移除复杂度「能运行的最简单方案是什么?」
研究者停止编码,开始调研「我们实际有什么证据?」
架构师识别结构性原因「如果我们从头开始,还会这么做吗?」

6. Unstuck — Lateral Thinking

6. 破局——横向思考

When blocked after repeated failures, choose a persona:
ooo unstuck                 # auto-select based on situation
ooo unstuck simplifier      # cut scope to MVP — "Start with exactly 2 tables"
ooo unstuck hacker          # make it work first, elegance later
ooo unstuck contrarian      # challenge all assumptions
ooo unstuck researcher      # stop coding, find missing information
ooo unstuck architect       # restructure the approach entirely
When to use each:
  • Repeated similar failures →
    contrarian
    (challenge assumptions)
  • Too many options →
    simplifier
    (reduce scope)
  • Missing information →
    researcher
    (seek data)
  • Analysis paralysis →
    hacker
    (just make it work)
  • Structural issues →
    architect
    (redesign)

多次失败遇到瓶颈时,选择一个角色:
ooo unstuck                 # 根据情况自动选择
ooo unstuck simplifier      # 缩减范围到MVP——「从刚好2张表开始」
ooo unstuck hacker          # 先跑通,再谈优雅
ooo unstuck contrarian      # 挑战所有假设
ooo unstuck researcher      # 停止编码,查找缺失信息
ooo unstuck architect       # 完全重构方案
使用场景:
  • 多次出现类似失败 →
    contrarian
    (挑战假设)
  • 选项太多 →
    simplifier
    (缩减范围)
  • 信息缺失 →
    researcher
    (寻找数据)
  • 分析瘫痪 →
    hacker
    (先跑通再说)
  • 结构性问题 →
    architect
    (重新设计)

7. Platform Installation & Usage

7. 平台安装与使用

Claude Code (Native Plugin — Full Mode)

Claude Code(原生插件——全功能模式)

bash
undefined
bash
undefined

Install

安装

claude plugin marketplace add Q00/ouroboros claude plugin install ouroboros@ouroboros
claude plugin marketplace add Q00/ouroboros claude plugin install ouroboros@ouroboros

One-time setup

一次初始化设置

ooo setup
ooo setup

Use

使用

ooo interview "I want to build a task CLI" ooo seed ooo run ooo evaluate <session_id> ooo ralph "fix all failing tests"

All `ooo` commands work natively. Hooks auto-activate:
- `UserPromptSubmit` → keyword-detector.mjs detects triggers
- `PostToolUse(Write|Edit)` → drift-monitor.mjs tracks deviation
- `SessionStart` → session initialization

**Claude Code hooks.json** (installed at `${CLAUDE_PLUGIN_ROOT}/hooks/hooks.json`):
```json
{
  "hooks": {
    "SessionStart": [{ "matcher": "*", "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/session-start.mjs\"", "timeout": 5 }] }],
    "UserPromptSubmit": [{ "matcher": "*", "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/keyword-detector.mjs\"", "timeout": 5 }] }],
    "PostToolUse": [{ "matcher": "Write|Edit", "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/drift-monitor.mjs\"", "timeout": 3 }] }]
  }
}
ooo interview "I want to build a task CLI" ooo seed ooo run ooo evaluate <session_id> ooo ralph "fix all failing tests"

所有`ooo`命令原生可用,钩子自动激活:
- `UserPromptSubmit` → keyword-detector.mjs 检测触发词
- `PostToolUse(Write|Edit)` → drift-monitor.mjs 追踪偏差
- `SessionStart` → 会话初始化

**Claude Code hooks.json**(安装在`${CLAUDE_PLUGIN_ROOT}/hooks/hooks.json`):
```json
{
  "hooks": {
    "SessionStart": [{ "matcher": "*", "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/session-start.mjs\"", "timeout": 5 }] }],
    "UserPromptSubmit": [{ "matcher": "*", "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/keyword-detector.mjs\"", "timeout": 5 }] }],
    "PostToolUse": [{ "matcher": "Write|Edit", "hooks": [{ "type": "command", "command": "node \"${CLAUDE_PLUGIN_ROOT}/scripts/drift-monitor.mjs\"", "timeout": 3 }] }]
  }
}

Codex CLI (Adapted Mode — bash loop)

Codex CLI(适配模式——bash循环)

Codex CLI has no native AfterAgent hooks. Use the setup script to configure:
bash
undefined
Codex CLI没有原生的AfterAgent钩子,使用设置脚本配置:
bash
undefined

Setup

设置

bash <your-agent-skills>/ralph/scripts/setup-codex-hook.sh
bash <your-agent-skills>/ralph/scripts/setup-codex-hook.sh

Restart Codex, then use:

重启Codex后使用:

/prompts:ralph # load ralph loop context /prompts:ouroboros # load full ouroboros context
/prompts:ralph # 加载ralph循环上下文 /prompts:ouroboros # 加载完整ouroboros上下文

Use ooo commands in conversation:

在对话中使用ooo命令:

ooo interview "build a REST API" ooo ralph "fix all TypeScript errors"

**Codex ralph loop contract:**
1. Treat `/ralph "<task>" [--completion-promise=TEXT] [--max-iterations=N]` as a contract command
2. Parse completion signal inside XML: `<promise>VALUE</promise>`
3. If promise missing and iteration < max-iterations → continue immediately with same original command
4. If promise found or max-iterations reached → finish with status report

**Completion promise syntax:**
```xml
<promise>DONE</promise>
Manual state management for Codex:
  • Create
    .omc/state/ralph-state.json
    at loop start
  • Update
    iteration
    counter each cycle
  • Set
    status: "complete"
    when promise found
  • Default completion promise:
    DONE
    | Default max iterations:
    10
ooo interview "build a REST API" ooo ralph "fix all TypeScript errors"

**Codex ralph循环协议:**
1. 将`/ralph "<task>" [--completion-promise=TEXT] [--max-iterations=N]`视为协议命令
2. 解析XML中的完成信号:`<promise>VALUE</promise>`
3. 如果没有找到promise且迭代次数未达上限 → 立即用原命令继续执行
4. 如果找到promise或达到最大迭代次数 → 输出状态报告并结束

**完成承诺语法:**
```xml
<promise>DONE</promise>
Codex手动状态管理:
  • 循环启动时创建
    .omc/state/ralph-state.json
  • 每个周期更新
    iteration
    计数
  • 找到promise时设置
    status: "complete"
  • 默认完成承诺:
    DONE
    | 默认最大迭代次数:
    10

Gemini CLI (AfterAgent Hook Mode)

Gemini CLI(AfterAgent钩子模式)

bash
undefined
bash
undefined

Install via extensions

通过扩展安装

gemini extensions install https://github.com/Q00/ouroboros
gemini extensions install https://github.com/Q00/ouroboros

OR install skills-template

或者安装skills-template


Required in `~/.gemini/settings.json`:
```json
{
  "hooksConfig": { "enabled": true },
  "context": {
    "includeDirectories": ["~/.gemini/extensions/ralph"]
  }
}
AfterAgent hook for loop continuation (add to
~/.gemini/settings.json
):
json
{
  "hooks": {
    "AfterAgent": [{
      "matcher": "*",
      "hooks": [{
        "type": "command",
        "command": "bash ~/.gemini/hooks/ralph-check.sh",
        "timeout": 10
      }]
    }]
  }
}
Run in sandbox + YOLO mode to prevent constant confirmation prompts:
bash
gemini -s -y
Then use
ooo
commands directly:
ooo interview "build a task CLI"
ooo ralph "fix all tests"
⚠️ Gemini v0.30.0 bug:
stop_hook_active
always
false
in hook JSON. Workaround: check
.omc/state/ralph-state.json
directly instead of relying on the hook field.


需要在`~/.gemini/settings.json`中配置:
```json
{
  "hooksConfig": { "enabled": true },
  "context": {
    "includeDirectories": ["~/.gemini/extensions/ralph"]
  }
}
用于循环续跑的AfterAgent钩子(添加到
~/.gemini/settings.json
):
json
{
  "hooks": {
    "AfterAgent": [{
      "matcher": "*",
      "hooks": [{
        "type": "command",
        "command": "bash ~/.gemini/hooks/ralph-check.sh",
        "timeout": 10
      }]
    }]
  }
}
在沙箱+YOLO模式下运行,避免持续的确认提示:
bash
gemini -s -y
然后直接使用
ooo
命令:
ooo interview "build a task CLI"
ooo ralph "fix all tests"
⚠️ Gemini v0.30.0 已知bug: 钩子JSON中的
stop_hook_active
始终为
false
。 解决方案:直接检查
.omc/state/ralph-state.json
,不要依赖钩子字段。

8. Platform Support Matrix

8. 平台支持矩阵

PlatformNative SupportMechanismooo CommandsLoop
Claude Code✅ FullPlugin + hooksAll
ooo
commands
Auto via hooks
Codex CLI🔧 Adaptedbash +
/prompts:ralph
Via conversationManual state file
Gemini CLI✅ NativeAfterAgent hookAll
ooo
commands
Auto via hook
OpenCode✅ NativeSkills systemAll
ooo
commands
Auto via loop

平台原生支持实现机制ooo命令支持循环
Claude Code✅ 全功能插件+钩子所有
ooo
命令
钩子自动触发
Codex CLI🔧 适配bash +
/prompts:ralph
通过对话使用手动状态文件
Gemini CLI✅ 原生AfterAgent钩子所有
ooo
命令
钩子自动触发
OpenCode✅ 原生技能系统所有
ooo
命令
自动循环

9. Quick Reference

9. 快速参考

ActionCommand
Socratic interview
ooo interview "topic"
Generate spec
ooo seed
Execute spec
ooo run [seed.yaml]
3-stage evaluate
ooo evaluate <session_id>
Evolve until converged
ooo evolve "topic"
Persistent loop
ooo ralph "task"
Break stagnation
ooo unstuck [persona]
Check drift
ooo status [session_id]
First-time setup
ooo setup
Cancel
/ouroboros:cancel
Force cancel + clear
/ouroboros:cancel --force
Resume
ooo ralph continue
Cancel (Gemini/Codex)
/ralph:cancel

操作命令
苏格拉底式访谈
ooo interview "topic"
生成规约
ooo seed
执行规约
ooo run [seed.yaml]
三阶段评估
ooo evaluate <session_id>
演化直到收敛
ooo evolve "topic"
持续循环执行
ooo ralph "task"
突破停滞
ooo unstuck [persona]
检查偏差
ooo status [session_id]
首次初始化
ooo setup
取消
/ouroboros:cancel
强制取消+清空状态
/ouroboros:cancel --force
恢复
ooo ralph continue
取消(Gemini/Codex)
/ralph:cancel

10. Installation

10. 安装

bash
undefined
bash
undefined

Claude Code

Claude Code

claude plugin marketplace add Q00/ouroboros claude plugin install ouroboros@ouroboros ooo setup
claude plugin marketplace add Q00/ouroboros claude plugin install ouroboros@ouroboros ooo setup

Codex CLI

Codex CLI

bash <skills>/ralph/scripts/setup-codex-hook.sh
bash <skills>/ralph/scripts/setup-codex-hook.sh

Gemini CLI (extensions)

Gemini CLI (扩展)

gemini extensions install https://github.com/Q00/ouroboros
gemini extensions install https://github.com/Q00/ouroboros

All platforms via skills-template

所有平台通过skills-template安装


Source: [Q00/ouroboros](https://github.com/Q00/ouroboros) — MIT License

源码: [Q00/ouroboros](https://github.com/Q00/ouroboros) — MIT License