ralph
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese[RALPH + ULTRAWORK - ITERATION {{ITERATION}}/{{MAX}}]
Your previous attempt did not output the completion promise. Continue working on the task.
<Purpose>
Ralph is a persistence loop that keeps working on a task until it is fully complete and architect-verified. It wraps ultrawork's parallel execution with session persistence, automatic retry on failure, and mandatory verification before completion.
</Purpose>
<Use_When>
- Task requires guaranteed completion with verification (not just "do your best")
- User says "ralph", "don't stop", "must complete", "finish this", or "keep going until done"
- Work may span multiple iterations and needs persistence across retries
- Task benefits from parallel execution with architect sign-off at the end </Use_When>
<Do_Not_Use_When>
- User wants a full autonomous pipeline from idea to code -- use instead
autopilot - User wants to explore or plan before committing -- use skill instead
plan - User wants a quick one-shot fix -- delegate directly to an executor agent
- User wants manual control over completion -- use directly </Do_Not_Use_When>
ultrawork
<Why_This_Exists>
Complex tasks often fail silently: partial implementations get declared "done", tests get skipped, edge cases get forgotten. Ralph prevents this by looping until work is genuinely complete, requiring fresh verification evidence before allowing completion, and using tiered architect review to confirm quality.
</Why_This_Exists>
<Execution_Policy>
- Fire independent agent calls simultaneously -- never wait sequentially for independent work
- Use for long operations (installs, builds, test suites)
run_in_background: true - Always pass the parameter explicitly when delegating to agents
model - Read before first delegation to select correct agent tiers
docs/shared/agent-tiers.md - Deliver the full implementation: no scope reduction, no partial completion, no deleting tests to make them pass
- Default to concise, evidence-dense progress and completion reporting unless the user or risk level requires more detail
- Treat newer user task updates as local overrides for the active workflow branch while preserving earlier non-conflicting constraints
- If correctness depends on additional inspection, retrieval, execution, or verification, keep using the relevant tools until the execution loop is grounded
- Continue through clear, low-risk, reversible next steps automatically; ask only when the next step is materially branching, destructive, or preference-dependent </Execution_Policy>
<Tool_Usage>
- Before first MCP tool use, call to discover deferred MCP tools
ToolSearch("mcp") - Use with
ask_codexfor verification cross-checks when changes are security-sensitive, architectural, or involve complex multi-system integrationagent_role: "architect" - Skip Codex consultation for simple feature additions, well-tested changes, or time-critical verification
- If ToolSearch finds no MCP tools or Codex is unavailable, proceed with architect agent verification alone -- never block on external tools
- Use /
state_writefor ralph mode state persistence between iterationsstate_read - Persist context snapshot path in Ralph mode state so later phases and agents share the same grounding context </Tool_Usage>
[RALPH + ULTRAWORK - 迭代 {{ITERATION}}/{{MAX}}]
您之前的尝试未输出完成承诺,请继续处理任务。
<Purpose>
Ralph是一个持久化循环,会持续处理任务直到任务完全完成并通过架构师验证。它为ultrawork的并行执行能力封装了会话持久化、失败自动重试、以及完成前强制验证机制。
</Purpose>
<Use_When>
- 任务需要带验证的可保障完成结果(而非仅“尽力而为”)
- 用户提到“ralph”、“不要停止”、“必须完成”、“做完这个”或“一直做到完成”
- 工作可能需要多轮迭代,且需要跨重试的持久化能力
- 任务适合并行执行,且最终需要架构师签字确认 </Use_When>
<Do_Not_Use_When>
- 用户需要从创意到代码的完全自主流水线——请改用
autopilot - 用户想要在提交前先探索或规划——请改用skill
plan - 用户需要快速的一次性修复——直接委派给执行Agent即可
- 用户想要手动控制完成流程——直接使用即可 </Do_Not_Use_When>
ultrawork
<Why_This_Exists>
复杂任务经常会静默失败:部分实现被宣称“已完成”,测试被跳过,边缘情况被遗忘。Ralph通过循环执行直到工作真正完成、完成前要求提供新的验证证据、以及使用分层架构评审确认质量来避免这类问题。
</Why_This_Exists>
<Execution_Policy>
- 同时发起独立的Agent调用——永远不要顺序等待独立工作完成
- 长时间操作(安装、构建、测试套件)使用
run_in_background: true - 向Agent委派任务时始终显式传递参数
model - 首次委派前阅读以选择正确的Agent层级
docs/shared/agent-tiers.md - 交付完整实现:不缩小范围、不部分完成、不删除测试来强制通过
- 默认使用简洁、证据密集的进度和完成报告,除非用户或风险等级要求更多细节
- 较新的用户任务更新作为当前工作流分支的局部覆盖,同时保留早期无冲突的约束
- 如果正确性需要额外的检查、检索、执行或验证,请持续使用相关工具直到执行循环落地
- 自动推进清晰、低风险、可回滚的后续步骤;仅当下一步存在重大分支、破坏性操作或依赖用户偏好时才发起询问 </Execution_Policy>
<Tool_Usage>
- 首次使用MCP工具前,调用发现延迟加载的MCP工具
ToolSearch("mcp") - 当变更涉及安全敏感内容、架构改动或复杂多系统集成时,使用搭配
ask_codex进行交叉验证agent_role: "architect" - 简单功能新增、经过充分测试的变更或时间紧急的验证可以跳过Codex咨询
- 如果ToolSearch未找到MCP工具或Codex不可用,仅使用架构师Agent验证继续流程——永远不要因外部工具阻塞
- 使用/
state_write实现ralph模式迭代间的状态持久化state_read - 将上下文快照路径持久化到Ralph模式状态中,以便后续阶段和Agent共享相同的落地上下文 </Tool_Usage>
State Management
状态管理
Use the MCP server tools (, , ) for Ralph lifecycle state.
omx_statestate_writestate_readstate_clear- On start:
state_write({mode: "ralph", active: true, iteration: 1, max_iterations: 10, current_phase: "executing", started_at: "<now>", state: {context_snapshot_path: "<snapshot-path>"}}) - On each iteration:
state_write({mode: "ralph", iteration: <current>, current_phase: "executing"}) - On verification/fix transition:
or
state_write({mode: "ralph", current_phase: "verifying"})state_write({mode: "ralph", current_phase: "fixing"}) - On completion:
state_write({mode: "ralph", active: false, current_phase: "complete", completed_at: "<now>"}) - On cancellation/cleanup:
run (which should call
$cancel)state_clear(mode="ralph")
使用 MCP服务工具(、、)管理Ralph生命周期状态。
omx_statestate_writestate_readstate_clear- 启动时:
state_write({mode: "ralph", active: true, iteration: 1, max_iterations: 10, current_phase: "executing", started_at: "<now>", state: {context_snapshot_path: "<snapshot-path>"}}) - 每次迭代时:
state_write({mode: "ralph", iteration: <current>, current_phase: "executing"}) - 验证/修复状态转换时:
或
state_write({mode: "ralph", current_phase: "verifying"})state_write({mode: "ralph", current_phase: "fixing"}) - 完成时:
state_write({mode: "ralph", active: false, current_phase: "complete", completed_at: "<now>"}) - 取消/清理时:
运行(应该会调用
$cancel)state_clear(mode="ralph")
Scenario Examples
场景示例
Good: The user says after the workflow already has a clear next step. Continue the current branch of work instead of restarting or re-asking the same question.
continueGood: The user changes only the output shape or downstream delivery step (for example ). Preserve earlier non-conflicting workflow constraints and apply the update locally.
make a PRBad: The user says , and the workflow restarts discovery or stops before the missing verification/evidence is gathered.
<Examples>
<Good>
Correct parallel delegation:
```
delegate(role="executor", tier="LOW", task="Add type export for UserConfig")
delegate(role="executor", tier="STANDARD", task="Implement the caching layer for API responses")
delegate(role="executor", tier="THOROUGH", task="Refactor auth module to support OAuth2 flow")
```
Why good: Three independent tasks fired simultaneously at appropriate tiers.
</Good>
<Good>
Correct verification before completion:
```
1. Run: npm test → Output: "42 passed, 0 failed"
2. Run: npm run build → Output: "Build succeeded"
3. Run: lsp_diagnostics → Output: 0 errors
4. Delegate to architect at STANDARD tier → Verdict: "APPROVED"
5. Run /cancel
```
Why good: Fresh evidence at each step, architect verification, then clean exit.
</Good>
<Bad>
Claiming completion without verification:
"All the changes look good, the implementation should work correctly. Task complete."
Why bad: Uses "should" and "look good" -- no fresh test/build output, no architect verification.
</Bad>
<Bad>
Sequential execution of independent tasks:
```
delegate(executor, LOW, "Add type export") → wait →
delegate(executor, STANDARD, "Implement caching") → wait →
delegate(executor, THOROUGH, "Refactor auth")
```
Why bad: These are independent tasks that should run in parallel, not sequentially.
</Bad>
</Examples>
continue<Escalation_And_Stop_Conditions>
- Stop and report when a fundamental blocker requires user input (missing credentials, unclear requirements, external service down)
- Stop when the user says "stop", "cancel", or "abort" -- run
/cancel - Continue working when the hook system sends "The boulder never stops" -- this means the iteration continues
- If architect rejects verification, fix the issues and re-verify (do not stop)
- If the same issue recurs across 3+ iterations, report it as a potential fundamental problem </Escalation_And_Stop_Conditions>
<Final_Checklist>
- All requirements from the original task are met (no scope reduction)
- Zero pending or in_progress TODO items
- Fresh test run output shows all tests pass
- Fresh build output shows success
- lsp_diagnostics shows 0 errors on affected files
- Architect verification passed (STANDARD tier minimum)
- ai-slop-cleaner pass completed on changed files (or --no-deslop specified)
- Post-deslop regression tests pass
- run for clean state cleanup </Final_Checklist>
/cancel
正确示例:工作流已经有明确的下一步时用户说,继续当前工作分支,不要重启或重复询问相同问题。
continue正确示例:用户仅修改输出形式或下游交付步骤(例如),保留早期无冲突的工作流约束,局部应用更新。
提交PR错误示例:用户说,但工作流重启了信息采集,或者在缺失验证/证据时停止。
<Examples>
<Good>
正确的并行委派:
```
delegate(role="executor", tier="LOW", task="Add type export for UserConfig")
delegate(role="executor", tier="STANDARD", task="Implement the caching layer for API responses")
delegate(role="executor", tier="THOROUGH", task="Refactor auth module to support OAuth2 flow")
```
为什么正确:三个独立任务同时发起,且使用了对应的层级。
</Good>
<Good>
完成前的正确验证:
```
1. Run: npm test → Output: "42 passed, 0 failed"
2. Run: npm run build → Output: "Build succeeded"
3. Run: lsp_diagnostics → Output: 0 errors
4. Delegate to architect at STANDARD tier → Verdict: "APPROVED"
5. Run /cancel
```
为什么正确:每一步都有新证据,经过架构师验证,然后干净退出。
</Good>
<Bad>
未经验证就宣称完成:
"所有改动看起来都不错,实现应该可以正常工作。任务完成。"
为什么错误:使用了“应该”和“看起来不错”——没有新的测试/构建输出,没有架构师验证。
</Bad>
<Bad>
独立任务的顺序执行:
```
delegate(executor, LOW, "Add type export") → wait →
delegate(executor, STANDARD, "Implement caching") → wait →
delegate(executor, THOROUGH, "Refactor auth")
```
为什么错误:这些是独立任务,应该并行运行而非顺序执行。
</Bad>
</Examples>
continue<升级与停止条件>
- 遇到需要用户输入的根本阻塞问题时停止并上报(缺失凭证、需求不明确、外部服务宕机)
- 用户说“stop”、“cancel”或“abort”时停止——运行
/cancel - 钩子系统发送“The boulder never stops”时继续工作——表示迭代继续
- 如果架构师驳回验证,修复问题后重新验证(不要停止)
- 如果同一问题在3轮以上迭代中重复出现,作为潜在根本问题上报 </Escalation_And_Stop_Conditions>
<最终检查清单>
- 原始任务的所有需求都已满足(无范围缩减)
- 无待处理或进行中的TODO项
- 新的测试运行输出显示所有测试通过
- 新的构建输出显示成功
- lsp_diagnostics显示受影响文件0错误
- 架构师验证通过(最低STANDARD层级)
- 改动文件已完成ai-slop-cleaner清理(或指定了--no-deslop)
- 清理后的回归测试通过
- 已运行完成状态清理 </Final_Checklist>
/cancel
<高级功能>
PRD Mode (Optional)
PRD模式(可选)
When the user provides the flag, initialize a Product Requirements Document before starting the ralph loop.
--prd当用户提供参数时,启动ralph循环前先初始化产品需求文档。
--prdDetecting PRD Mode
检测PRD模式
Check if contains or .
{{PROMPT}}--prd--PRD检查是否包含或。
{{PROMPT}}--prd--PRDDetecting --no-deslop
--no-deslop检测--no-deslop
--no-deslopCheck if contains .
If is present, skip the deslop pass entirely after Step 7 and continue using the latest successful pre-deslop verification evidence.
{{PROMPT}}--no-deslop--no-deslop检查是否包含。
如果存在,步骤7后完全跳过清理步骤,使用清理前最新的成功验证证据继续。
{{PROMPT}}--no-deslop--no-deslopVisual Reference Flags (Optional)
视觉参考参数(可选)
Ralph execution supports visual reference flags for screenshot tasks:
- Repeatable image inputs: (can be used multiple times)
-i <image-path> - Image directory input:
--images-dir <directory>
Example:
ralph -i refs/hn.png -i refs/hn-item.png --images-dir ./screenshots "match HackerNews layout"Ralph执行支持截图任务的视觉参考参数:
- 可重复图片输入:(可多次使用)
-i <image-path> - 图片目录输入:
--images-dir <directory>
示例:
ralph -i refs/hn.png -i refs/hn-item.png --images-dir ./screenshots "match HackerNews layout"PRD Workflow
PRD工作流
- Run deep-interview in quick mode before creating PRD artifacts:
- Execute:
$deep-interview --quick <task> - Complete a compact requirements pass (context, goals, scope, constraints, validation)
- Persist interview output to
.omx/interviews/{slug}-{timestamp}.md
- Execute:
- Create canonical PRD/progress artifacts:
- PRD:
.omx/plans/prd-{slug}.md - Progress ledger: (session scope when available, else root scope)
.omx/state/{scope}/ralph-progress.json
- PRD:
- Parse the task (everything after flag)
--prd - Break down into user stories:
json
{
"project": "[Project Name]",
"branchName": "ralph/[feature-name]",
"description": "[Feature description]",
"userStories": [
{
"id": "US-001",
"title": "[Short title]",
"description": "As a [user], I want to [action] so that [benefit].",
"acceptanceCriteria": ["Criterion 1", "Typecheck passes"],
"priority": 1,
"passes": false
}
]
}- Initialize canonical progress ledger at
.omx/state/{scope}/ralph-progress.json - Guidelines: right-sized stories (one session each), verifiable criteria, independent stories, priority order (foundational work first)
- Proceed to normal ralph loop using user stories as the task list
- 创建PRD产物前先运行快速深度访谈:
- 执行:
$deep-interview --quick <task> - 完成精简需求梳理(上下文、目标、范围、约束、验证标准)
- 将访谈输出持久化到
.omx/interviews/{slug}-{timestamp}.md
- 执行:
- 创建规范PRD/进度产物:
- PRD:
.omx/plans/prd-{slug}.md - 进度台账:(可用时用会话范围,否则用根范围)
.omx/state/{scope}/ralph-progress.json
- PRD:
- 解析任务(参数后的所有内容)
--prd - 拆分为用户故事:
json
{
"project": "[Project Name]",
"branchName": "ralph/[feature-name]",
"description": "[Feature description]",
"userStories": [
{
"id": "US-001",
"title": "[Short title]",
"description": "As a [user], I want to [action] so that [benefit].",
"acceptanceCriteria": ["Criterion 1", "Typecheck passes"],
"priority": 1,
"passes": false
}
]
}- 在初始化规范进度台账
.omx/state/{scope}/ralph-progress.json - 指导原则:故事粒度合适(单会话可完成)、可验证的标准、独立故事、按优先级排序(基础工作优先)
- 使用用户故事作为任务列表进入常规ralph循环
Example
示例
User input:
Workflow: Detect flag, extract task, create , create , begin ralph loop.
--prd build a todo app with React and TypeScript.omx/plans/prd-{slug}.md.omx/state/{scope}/ralph-progress.json用户输入:
工作流:检测参数、提取任务、创建、创建、启动ralph循环。
--prd build a todo app with React and TypeScript.omx/plans/prd-{slug}.md.omx/state/{scope}/ralph-progress.jsonLegacy compatibility
旧版本兼容
- If exists and canonical PRD is absent, migrate one-way into
.omx/prd.json..omx/plans/prd-{slug}.md - If exists and canonical progress ledger is absent, import one-way into
.omx/progress.txt..omx/state/{scope}/ralph-progress.json - Keep legacy files unchanged for one release cycle.
- 如果存在且没有规范PRD,单向迁移到
.omx/prd.json。.omx/plans/prd-{slug}.md - 如果存在且没有规范进度台账,单向导入到
.omx/progress.txt。.omx/state/{scope}/ralph-progress.json - 旧版本文件保留一个发布周期不修改。
Background Execution Rules
后台执行规则
Run in background ():
run_in_background: true- Package installation (npm install, pip install, cargo build)
- Build processes (make, project build commands)
- Test suites
- Docker operations (docker build, docker pull)
Run blocking (foreground):
- Quick status checks (git status, ls, pwd)
- File reads and edits
- Simple commands </Advanced>
Original task:
{{PROMPT}}
后台运行():
run_in_background: true- 包安装(npm install, pip install, cargo build)
- 构建流程(make, 项目构建命令)
- 测试套件
- Docker操作(docker build, docker pull)
阻塞运行(前台):
- 快速状态检查(git status, ls, pwd)
- 文件读写和编辑
- 简单命令 </Advanced>
原始任务:
{{PROMPT}}