[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>", state: {context_snapshot_path: "<snapshot-path>"}})
- 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"))
Scenario Examples
Good: The user says continue after the workflow already has a clear next step. Continue the current branch of work instead of restarting or re-asking the same question.
Good: The user changes only the output shape or downstream delivery step (for example make a PR). Preserve earlier non-conflicting workflow constraints and apply the update locally.
Bad: The user says continue, and the workflow restarts discovery or stops before the missing verification/evidence is gathered.
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.
Prompt-side $ralph workflow activation is lighter-weight than omx ralph --prd ....
It seeds Ralph workflow state and guidance, but it does not implicitly launch the
CLI entrypoint or apply the PRD startup gate. Treat omx ralph --prd ... as the
explicit PRD-gated path.
Detecting --no-deslop
Check if {{PROMPT}} contains --no-deslop.
If --no-deslop is present, skip the deslop pass entirely after Step 7 and continue using the latest successful pre-deslop verification evidence.
Visual Reference Flags (Optional)
Ralph execution supports visual reference flags for screenshot tasks:
- Repeatable image inputs:
-i <image-path> (can be used multiple times)
- Image directory input:
--images-dir <directory>
Example:
ralph -i refs/hn.png -i refs/hn-item.png --images-dir ./screenshots "match HackerNews layout"
PRD Workflow
- 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
- 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
- During the compatibility window, Ralph
--prd startup still validates machine-readable story state from .omx/prd.json.
.omx/plans/prd-{slug}.md remains the canonical storage/documentation artifact, but it is not yet the startup validation source.
- 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: ralph3description: [OMX] 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- Default to concise, evidence-dense progress and completion reporting unless the user or risk level requires more detail39- Treat newer user task updates as local overrides for the active workflow branch while preserving earlier non-conflicting constraints40- If correctness depends on additional inspection, retrieval, execution, or verification, keep using the relevant tools until the execution loop is grounded41- Continue through clear, low-risk, reversible next steps automatically; ask only when the next step is materially branching, destructive, or preference-dependent42</Execution_Policy>4344<Steps>450. **Pre-context intake (required before planning/execution loop starts)**:46 - Assemble or load a context snapshot at `.omx/context/{task-slug}-{timestamp}.md` (UTC `YYYYMMDDTHHMMSSZ`).47 - Minimum snapshot fields:48 - task statement49 - desired outcome50 - known facts/evidence51 - constraints52 - unknowns/open questions53 - likely codebase touchpoints54 - If an existing relevant snapshot is available, reuse it and record the path in Ralph state.55 - If request ambiguity is high, gather brownfield facts first. When session guidance enables `USE_OMX_EXPLORE_CMD`, prefer `omx explore` for simple read-only repository lookups with narrow, concrete prompts; otherwise use the richer normal explore path. Then run `$deep-interview --quick <task>` to close critical gaps.56 - Do not begin Ralph execution work (delegation, implementation, or verification loops) until snapshot grounding exists. If forced to proceed quickly, note explicit risk tradeoffs.571. **Review progress**: Check TODO list and any prior iteration state582. **Continue from where you left off**: Pick up incomplete tasks593. **Delegate in parallel**: Route tasks to specialist agents at appropriate tiers60 - Simple lookups: LOW tier -- "What does this function return?"61 - Standard work: STANDARD tier -- "Add error handling to this module"62 - Complex analysis: THOROUGH tier -- "Debug this race condition"63 - When Ralph is entered as a ralplan follow-up, start from the approved **available-agent-types roster** and make the delegation plan explicit: implementation lane, evidence/regression lane, and final sign-off lane using only known agent types644. **Run long operations in background**: Builds, installs, test suites use `run_in_background: true`655. **Visual task gate (when screenshot/reference images are present)**:66 - Run `$visual-verdict` **before every next edit**.67 - Require structured JSON output: `score`, `verdict`, `category_match`, `differences[]`, `suggestions[]`, `reasoning`.68 - Persist verdict to `.omx/state/{scope}/ralph-progress.json` including numeric + qualitative feedback.69 - Default pass threshold: `score >= 90`.70 - **URL-based visual cloning tasks**: When the task description contains a target URL (e.g., "clone https://example.com"), route the work through `$visual-ralph`. `$web-clone` is hard-deprecated; Visual Ralph owns the migrated live-URL visual implementation use case and uses `$visual-verdict` for measured visual scoring.716. **Verify completion with fresh evidence**:72 a. Identify what command proves the task is complete73 b. Run verification (test, build, lint)74 c. Read the output -- confirm it actually passed75 d. Check: zero pending/in_progress TODO items767. **Architect verification** (tiered):77 - <5 files, <100 lines with full tests: STANDARD tier minimum (architect role)78 - Standard changes: STANDARD tier (architect role)79 - >20 files or security/architectural changes: THOROUGH tier (architect role)80 - Ralph floor: always at least STANDARD, even for small changes817.5 **Mandatory Deslop Pass**:82 - After Step 7 passes, run `oh-my-codex:ai-slop-cleaner` on **all files changed during the Ralph session**.83 - Scope the cleaner to **changed files only**; do not widen the pass beyond Ralph-owned edits.84 - Run the cleaner in **standard mode** (not `--review`).85 - If the prompt contains `--no-deslop`, skip Step 7.5 entirely and proceed with the most recent successful verification evidence.867.6 **Regression Re-verification**:87 - After the deslop pass, re-run all tests/build/lint and read the output to confirm they still pass.88 - If post-deslop regression fails, roll back cleaner changes or fix and retry. Then rerun Step 7.5 and Step 7.6 until the regression is green.89 - Do not proceed to completion until post-deslop regression is green (unless `--no-deslop` explicitly skipped the deslop pass).908. **On approval**: Run `/cancel` to cleanly exit and clean up all state files919. **On rejection**: Fix the issues raised, then re-verify at the same tier92</Steps>9394<Tool_Usage>95- Before first MCP tool use, call `ToolSearch("mcp")` to discover deferred MCP tools96- Use `ask_codex` with `agent_role: "architect"` for verification cross-checks when changes are security-sensitive, architectural, or involve complex multi-system integration97- Skip Codex consultation for simple feature additions, well-tested changes, or time-critical verification98- If ToolSearch finds no MCP tools or Codex is unavailable, proceed with architect agent verification alone -- never block on external tools99- Use `state_write` / `state_read` for ralph mode state persistence between iterations100- Persist context snapshot path in Ralph mode state so later phases and agents share the same grounding context101</Tool_Usage>102103## State Management104105Use the `omx_state` MCP server tools (`state_write`, `state_read`, `state_clear`) for Ralph lifecycle state.106107- **On start**:108 `state_write({mode: "ralph", active: true, iteration: 1, max_iterations: 10, current_phase: "executing", started_at: "<now>", state: {context_snapshot_path: "<snapshot-path>"}})`109- **On each iteration**:110 `state_write({mode: "ralph", iteration: <current>, current_phase: "executing"})`111- **On verification/fix transition**:112 `state_write({mode: "ralph", current_phase: "verifying"})` or `state_write({mode: "ralph", current_phase: "fixing"})`113- **On completion**:114 `state_write({mode: "ralph", active: false, current_phase: "complete", completed_at: "<now>"})`115- **On cancellation/cleanup**:116 run `$cancel` (which should call `state_clear(mode="ralph")`)117118119## Scenario Examples120121**Good:** The user says `continue` after the workflow already has a clear next step. Continue the current branch of work instead of restarting or re-asking the same question.122123**Good:** The user changes only the output shape or downstream delivery step (for example `make a PR`). Preserve earlier non-conflicting workflow constraints and apply the update locally.124125**Bad:** The user says `continue`, and the workflow restarts discovery or stops before the missing verification/evidence is gathered.126127<Examples>128<Good>129Correct parallel delegation:130```131delegate(role="executor", tier="LOW", task="Add type export for UserConfig")132delegate(role="executor", tier="STANDARD", task="Implement the caching layer for API responses")133delegate(role="executor", tier="THOROUGH", task="Refactor auth module to support OAuth2 flow")134```135Why good: Three independent tasks fired simultaneously at appropriate tiers.136</Good>137138<Good>139Correct verification before completion:140```1411. Run: npm test → Output: "42 passed, 0 failed"1422. Run: npm run build → Output: "Build succeeded"1433. Run: lsp_diagnostics → Output: 0 errors1444. Delegate to architect at STANDARD tier → Verdict: "APPROVED"1455. Run /cancel146```147Why good: Fresh evidence at each step, architect verification, then clean exit.148</Good>149150<Bad>151Claiming completion without verification:152"All the changes look good, the implementation should work correctly. Task complete."153Why bad: Uses "should" and "look good" -- no fresh test/build output, no architect verification.154</Bad>155156<Bad>157Sequential execution of independent tasks:158```159delegate(executor, LOW, "Add type export") → wait →160delegate(executor, STANDARD, "Implement caching") → wait →161delegate(executor, THOROUGH, "Refactor auth")162```163Why bad: These are independent tasks that should run in parallel, not sequentially.164</Bad>165</Examples>166167<Escalation_And_Stop_Conditions>168- Stop and report when a fundamental blocker requires user input (missing credentials, unclear requirements, external service down)169- Stop when the user says "stop", "cancel", or "abort" -- run `/cancel`170- Continue working when the hook system sends "The boulder never stops" -- this means the iteration continues171- If architect rejects verification, fix the issues and re-verify (do not stop)172- If the same issue recurs across 3+ iterations, report it as a potential fundamental problem173</Escalation_And_Stop_Conditions>174175<Final_Checklist>176- [ ] All requirements from the original task are met (no scope reduction)177- [ ] Zero pending or in_progress TODO items178- [ ] Fresh test run output shows all tests pass179- [ ] Fresh build output shows success180- [ ] lsp_diagnostics shows 0 errors on affected files181- [ ] Architect verification passed (STANDARD tier minimum)182- [ ] ai-slop-cleaner pass completed on changed files (or --no-deslop specified)183- [ ] Post-deslop regression tests pass184- [ ] `/cancel` run for clean state cleanup185</Final_Checklist>186187<Advanced>188## PRD Mode (Optional)189190When the user provides the `--prd` flag, initialize a Product Requirements Document before starting the ralph loop.191192### Detecting PRD Mode193Check if `{{PROMPT}}` contains `--prd` or `--PRD`.194195Prompt-side `$ralph` workflow activation is lighter-weight than `omx ralph --prd ...`.196It seeds Ralph workflow state and guidance, but it does not implicitly launch the197CLI entrypoint or apply the PRD startup gate. Treat `omx ralph --prd ...` as the198explicit PRD-gated path.199200### Detecting `--no-deslop`201Check if `{{PROMPT}}` contains `--no-deslop`.202If `--no-deslop` is present, skip the deslop pass entirely after Step 7 and continue using the latest successful pre-deslop verification evidence.203204### Visual Reference Flags (Optional)205Ralph execution supports visual reference flags for screenshot tasks:206- Repeatable image inputs: `-i <image-path>` (can be used multiple times)207- Image directory input: `--images-dir <directory>`208209Example:210`ralph -i refs/hn.png -i refs/hn-item.png --images-dir ./screenshots "match HackerNews layout"`211212### PRD Workflow2131. Run deep-interview in quick mode before creating PRD artifacts:214 - Execute: `$deep-interview --quick <task>`215 - Complete a compact requirements pass (context, goals, scope, constraints, validation)216 - Persist interview output to `.omx/interviews/{slug}-{timestamp}.md`2172. Create canonical PRD/progress artifacts:218 - PRD: `.omx/plans/prd-{slug}.md`219 - Progress ledger: `.omx/state/{scope}/ralph-progress.json` (session scope when available, else root scope)2203. Parse the task (everything after `--prd` flag)2214. Break down into user stories:222223```json224{225 "project": "[Project Name]",226 "branchName": "ralph/[feature-name]",227 "description": "[Feature description]",228 "userStories": [229 {230 "id": "US-001",231 "title": "[Short title]",232 "description": "As a [user], I want to [action] so that [benefit].",233 "acceptanceCriteria": ["Criterion 1", "Typecheck passes"],234 "priority": 1,235 "passes": false236 }237 ]238}239```2402415. Initialize canonical progress ledger at `.omx/state/{scope}/ralph-progress.json`2426. Guidelines: right-sized stories (one session each), verifiable criteria, independent stories, priority order (foundational work first)2437. Proceed to normal ralph loop using user stories as the task list244245### Example246User input: `--prd build a todo app with React and TypeScript`247Workflow: Detect flag, extract task, create `.omx/plans/prd-{slug}.md`, create `.omx/state/{scope}/ralph-progress.json`, begin ralph loop.248249### Legacy compatibility250- During the compatibility window, Ralph `--prd` startup still validates machine-readable story state from `.omx/prd.json`.251- `.omx/plans/prd-{slug}.md` remains the canonical storage/documentation artifact, but it is not yet the startup validation source.252- If `.omx/prd.json` exists and canonical PRD is absent, migrate one-way into `.omx/plans/prd-{slug}.md`.253- If `.omx/progress.txt` exists and canonical progress ledger is absent, import one-way into `.omx/state/{scope}/ralph-progress.json`.254- Keep legacy files unchanged for one release cycle.255256## Background Execution Rules257258**Run in background** (`run_in_background: true`):259- Package installation (npm install, pip install, cargo build)260- Build processes (make, project build commands)261- Test suites262- Docker operations (docker build, docker pull)263264**Run blocking** (foreground):265- Quick status checks (git status, ls, pwd)266- File reads and edits267- Simple commands268</Advanced>269270Original task:271{{PROMPT}}