[RALPH + ULTRAWORK - ITERATION {{ITERATION}}/{{MAX}}]
Your previous attempt did not output the completion promise. Continue working on the task.
State Management
Use the omx_state MCP server tools (state_write, state_read, state_clear) for Ralph lifecycle state.
- On start:
state_write({mode: "ralph", active: true, iteration: 1, max_iterations: 10, current_phase: "executing", started_at: "<now>"})
- On each iteration:
state_write({mode: "ralph", iteration: <current>, current_phase: "executing"})
- On verification/fix transition:
state_write({mode: "ralph", current_phase: "verifying"}) or 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
$cancel (which should call state_clear(mode="ralph"))
When the user provides the --prd flag, initialize a Product Requirements Document before starting the ralph loop.
Detecting PRD Mode
Check if {{PROMPT}} contains --prd or --PRD.
PRD Workflow
- Create canonical PRD/progress artifacts:
- PRD:
.omx/plans/prd-{slug}.md
- Progress ledger:
.omx/state/{scope}/ralph-progress.json (session scope when available, else root scope)
- Parse the task (everything after
--prd flag)
- Break down into user stories:
{
"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
Example
User input: --prd build a todo app with React and TypeScript
Workflow: Detect flag, extract task, create .omx/plans/prd-{slug}.md, create .omx/state/{scope}/ralph-progress.json, begin ralph loop.
Legacy compatibility
- If
.omx/prd.json exists and canonical PRD is absent, migrate one-way into .omx/plans/prd-{slug}.md.
- If
.omx/progress.txt exists and canonical progress ledger is absent, import one-way into .omx/state/{scope}/ralph-progress.json.
- Keep legacy files unchanged for one release cycle.
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
Original task:
{{PROMPT}}
1---2name: ralph-23description: Self-referential loop until task completion with architect verification4---56[RALPH + ULTRAWORK - ITERATION {{ITERATION}}/{{MAX}}]78Your previous attempt did not output the completion promise. Continue working on the task.910<Purpose>11Ralph 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.12</Purpose>1314<Use_When>15- Task requires guaranteed completion with verification (not just "do your best")16- User says "ralph", "don't stop", "must complete", "finish this", or "keep going until done"17- Work may span multiple iterations and needs persistence across retries18- Task benefits from parallel execution with architect sign-off at the end19</Use_When>2021<Do_Not_Use_When>22- User wants a full autonomous pipeline from idea to code -- use `autopilot` instead23- User wants to explore or plan before committing -- use `plan` skill instead24- User wants a quick one-shot fix -- delegate directly to an executor agent25- User wants manual control over completion -- use `ultrawork` directly26</Do_Not_Use_When>2728<Why_This_Exists>29Complex 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.30</Why_This_Exists>3132<Execution_Policy>33- Fire independent agent calls simultaneously -- never wait sequentially for independent work34- Use `run_in_background: true` for long operations (installs, builds, test suites)35- Always pass the `model` parameter explicitly when delegating to agents36- Read `docs/shared/agent-tiers.md` before first delegation to select correct agent tiers37- Deliver the full implementation: no scope reduction, no partial completion, no deleting tests to make them pass38</Execution_Policy>3940<Steps>411. **Review progress**: Check TODO list and any prior iteration state422. **Continue from where you left off**: Pick up incomplete tasks433. **Delegate in parallel**: Route tasks to specialist agents at appropriate tiers44 - Simple lookups: LOW tier (Haiku) -- "What does this function return?"45 - Standard work: MEDIUM tier (Sonnet) -- "Add error handling to this module"46 - Complex analysis: HIGH tier (Opus) -- "Debug this race condition"474. **Run long operations in background**: Builds, installs, test suites use `run_in_background: true`485. **Verify completion with fresh evidence**:49 a. Identify what command proves the task is complete50 b. Run verification (test, build, lint)51 c. Read the output -- confirm it actually passed52 d. Check: zero pending/in_progress TODO items536. **Architect verification** (tiered):54 - <5 files, <100 lines with full tests: STANDARD tier minimum (architect-medium / Sonnet)55 - Standard changes: STANDARD tier (architect-medium / Sonnet)56 - >20 files or security/architectural changes: THOROUGH tier (architect / Opus)57 - Ralph floor: always at least STANDARD, even for small changes587. **On approval**: Run `/cancel` to cleanly exit and clean up all state files598. **On rejection**: Fix the issues raised, then re-verify at the same tier60</Steps>6162<Tool_Usage>63- Before first MCP tool use, call `ToolSearch("mcp")` to discover deferred MCP tools64- Use `ask_codex` with `agent_role: "architect"` for verification cross-checks when changes are security-sensitive, architectural, or involve complex multi-system integration65- Skip Codex consultation for simple feature additions, well-tested changes, or time-critical verification66- If ToolSearch finds no MCP tools or Codex is unavailable, proceed with architect agent verification alone -- never block on external tools67- Use `state_write` / `state_read` for ralph mode state persistence between iterations68</Tool_Usage>6970## State Management7172Use the `omx_state` MCP server tools (`state_write`, `state_read`, `state_clear`) for Ralph lifecycle state.7374- **On start**:75 `state_write({mode: "ralph", active: true, iteration: 1, max_iterations: 10, current_phase: "executing", started_at: "<now>"})`76- **On each iteration**:77 `state_write({mode: "ralph", iteration: <current>, current_phase: "executing"})`78- **On verification/fix transition**:79 `state_write({mode: "ralph", current_phase: "verifying"})` or `state_write({mode: "ralph", current_phase: "fixing"})`80- **On completion**:81 `state_write({mode: "ralph", active: false, current_phase: "complete", completed_at: "<now>"})`82- **On cancellation/cleanup**:83 run `$cancel` (which should call `state_clear(mode="ralph")`)8485<Examples>86<Good>87Correct parallel delegation:88```89spawn_sub_agent(subagent_type="oh-my-codex:executor-low", model="haiku", prompt="Add type export for UserConfig")90spawn_sub_agent(subagent_type="oh-my-codex:executor", model="sonnet", prompt="Implement the caching layer for API responses")91spawn_sub_agent(subagent_type="oh-my-codex:executor-high", model="opus", prompt="Refactor auth module to support OAuth2 flow")92```93Why good: Three independent tasks fired simultaneously at appropriate tiers.94</Good>9596<Good>97Correct verification before completion:98```991. Run: npm test → Output: "42 passed, 0 failed"1002. Run: npm run build → Output: "Build succeeded"1013. Run: lsp_diagnostics → Output: 0 errors1024. Spawn architect-medium → Verdict: "APPROVED"1035. Run /cancel104```105Why good: Fresh evidence at each step, architect verification, then clean exit.106</Good>107108<Bad>109Claiming completion without verification:110"All the changes look good, the implementation should work correctly. Task complete."111Why bad: Uses "should" and "look good" -- no fresh test/build output, no architect verification.112</Bad>113114<Bad>115Sequential execution of independent tasks:116```117spawn_sub_agent(executor-low, "Add type export") → wait →118spawn_sub_agent(executor, "Implement caching") → wait →119spawn_sub_agent(executor-high, "Refactor auth")120```121Why bad: These are independent tasks that should run in parallel, not sequentially.122</Bad>123</Examples>124125<Escalation_And_Stop_Conditions>126- Stop and report when a fundamental blocker requires user input (missing credentials, unclear requirements, external service down)127- Stop when the user says "stop", "cancel", or "abort" -- run `/cancel`128- Continue working when the hook system sends "The boulder never stops" -- this means the iteration continues129- If architect rejects verification, fix the issues and re-verify (do not stop)130- If the same issue recurs across 3+ iterations, report it as a potential fundamental problem131</Escalation_And_Stop_Conditions>132133<Final_Checklist>134- [ ] All requirements from the original task are met (no scope reduction)135- [ ] Zero pending or in_progress TODO items136- [ ] Fresh test run output shows all tests pass137- [ ] Fresh build output shows success138- [ ] lsp_diagnostics shows 0 errors on affected files139- [ ] Architect verification passed (STANDARD tier minimum)140- [ ] `/cancel` run for clean state cleanup141</Final_Checklist>142143<Advanced>144## PRD Mode (Optional)145146When the user provides the `--prd` flag, initialize a Product Requirements Document before starting the ralph loop.147148### Detecting PRD Mode149Check if `{{PROMPT}}` contains `--prd` or `--PRD`.150151### PRD Workflow1521. Create canonical PRD/progress artifacts:153 - PRD: `.omx/plans/prd-{slug}.md`154 - Progress ledger: `.omx/state/{scope}/ralph-progress.json` (session scope when available, else root scope)1552. Parse the task (everything after `--prd` flag)1563. Break down into user stories:157158```json159{160 "project": "[Project Name]",161 "branchName": "ralph/[feature-name]",162 "description": "[Feature description]",163 "userStories": [164 {165 "id": "US-001",166 "title": "[Short title]",167 "description": "As a [user], I want to [action] so that [benefit].",168 "acceptanceCriteria": ["Criterion 1", "Typecheck passes"],169 "priority": 1,170 "passes": false171 }172 ]173}174```1751764. Initialize canonical progress ledger at `.omx/state/{scope}/ralph-progress.json`1775. Guidelines: right-sized stories (one session each), verifiable criteria, independent stories, priority order (foundational work first)1786. Proceed to normal ralph loop using user stories as the task list179180### Example181User input: `--prd build a todo app with React and TypeScript`182Workflow: Detect flag, extract task, create `.omx/plans/prd-{slug}.md`, create `.omx/state/{scope}/ralph-progress.json`, begin ralph loop.183184### Legacy compatibility185- If `.omx/prd.json` exists and canonical PRD is absent, migrate one-way into `.omx/plans/prd-{slug}.md`.186- If `.omx/progress.txt` exists and canonical progress ledger is absent, import one-way into `.omx/state/{scope}/ralph-progress.json`.187- Keep legacy files unchanged for one release cycle.188189## Background Execution Rules190191**Run in background** (`run_in_background: true`):192- Package installation (npm install, pip install, cargo build)193- Build processes (make, project build commands)194- Test suites195- Docker operations (docker build, docker pull)196197**Run blocking** (foreground):198- Quick status checks (git status, ls, pwd)199- File reads and edits200- Simple commands201</Advanced>202203Original task:204{{PROMPT}}