[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: 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- Apply the shared workflow guidance pattern: outcome-first framing, concise visible updates for multi-step execution, local overrides for the active workflow branch, validation proportional to risk, explicit stop rules, and automatic continuation for safe reversible steps. Ask only for material, destructive, credentialed, external-production, or preference-dependent branches.39</Execution_Policy>4041<Steps>420. **Pre-context intake (required before planning/execution loop starts)**:43 - Assemble or load a context snapshot at `.omx/context/{task-slug}-{timestamp}.md` (UTC `YYYYMMDDTHHMMSSZ`).44 - Minimum snapshot fields:45 - task statement46 - desired outcome47 - known facts/evidence48 - constraints49 - unknowns/open questions50 - likely codebase touchpoints51 - If an existing relevant snapshot is available, reuse it and record the path in Ralph state.52 - 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.53 - Do not begin Ralph execution work (delegation, implementation, or verification loops) until snapshot grounding exists. If forced to proceed quickly, note explicit risk tradeoffs.541. **Review progress**: Check TODO list and any prior iteration state552. **Continue from where you left off**: Pick up incomplete tasks563. **Delegate in parallel**: Route tasks to specialist agents at appropriate tiers57 - Simple lookups: LOW tier -- "What does this function return?"58 - Standard work: STANDARD tier -- "Add error handling to this module"59 - Complex analysis: THOROUGH tier -- "Debug this race condition"60 - 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 types614. **Run long operations in background**: Builds, installs, test suites use `run_in_background: true`625. **Visual task gate (when screenshot/reference images are present)**:63 - Run `$visual-verdict` **before every next edit**.64 - Require structured JSON output: `score`, `verdict`, `category_match`, `differences[]`, `suggestions[]`, `reasoning`.65 - Persist verdict to `.omx/state/{scope}/ralph-progress.json` including numeric + qualitative feedback.66 - Default pass threshold: `score >= 90`.67 - **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.686. **Verify completion with fresh evidence**:69 a. Identify what command proves the task is complete70 b. Run verification (test, build, lint)71 c. Read the output -- confirm it actually passed72 d. Check: zero pending/in_progress TODO items737. **Architect verification** (tiered):74 - <5 files, <100 lines with full tests: STANDARD tier minimum (architect role)75 - Standard changes: STANDARD tier (architect role)76 - >20 files or security/architectural changes: THOROUGH tier (architect role)77 - Ralph floor: always at least STANDARD, even for small changes787.5 **Mandatory Deslop Pass**:79 - After Step 7 passes, run `oh-my-codex:ai-slop-cleaner` on **all files changed during the Ralph session**.80 - Scope the cleaner to **changed files only**; do not widen the pass beyond Ralph-owned edits.81 - Run the cleaner in **standard mode** (not `--review`).82 - If the prompt contains `--no-deslop`, skip Step 7.5 entirely and proceed with the most recent successful verification evidence.837.6 **Regression Re-verification**:84 - After the deslop pass, re-run all tests/build/lint and read the output to confirm they still pass.85 - 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.86 - Do not proceed to completion until post-deslop regression is green (unless `--no-deslop` explicitly skipped the deslop pass).878. **On approval**: Run `/cancel` to cleanly exit and clean up all state files889. **On rejection**: Fix the issues raised, then re-verify at the same tier89</Steps>9091<Tool_Usage>92- Before first MCP tool use, call `ToolSearch("mcp")` to discover deferred MCP tools93- Use `ask_codex` with `agent_role: "architect"` for verification cross-checks when changes are security-sensitive, architectural, or involve complex multi-system integration94- Skip Codex consultation for simple feature additions, well-tested changes, or time-critical verification95- If ToolSearch finds no MCP tools or Codex is unavailable, proceed with architect agent verification alone -- never block on external tools96- Use `state_write` / `state_read` for ralph mode state persistence between iterations97- Persist context snapshot path in Ralph mode state so later phases and agents share the same grounding context98- If an `omx_state` MCP tool call reports that its stdio transport is unavailable/closed, do **not** retry the same MCP call. Retry once through the supported CLI parity surface with the same payload, preserving `workingDirectory` and `session_id`: `omx state write --input '<json>' --json`, `omx state read --input '<json>' --json`, or `omx state clear --input '<json>' --json`. If the CLI path also fails, continue with `.omx/context` / `.omx/plans` file-backed artifacts and report the state persistence blocker.99</Tool_Usage>100101## State Management102103Use the `omx_state` MCP server tools (`state_write`, `state_read`, `state_clear`) for Ralph lifecycle state.104105- **On start**:106 `state_write({mode: "ralph", active: true, iteration: 1, max_iterations: 10, current_phase: "executing", started_at: "<now>", state: {context_snapshot_path: "<snapshot-path>"}})`107- **On each iteration**:108 `state_write({mode: "ralph", iteration: <current>, current_phase: "executing"})`109- **On verification/fix transition**:110 `state_write({mode: "ralph", current_phase: "verifying"})` or `state_write({mode: "ralph", current_phase: "fixing"})`111- **On completion**:112 `state_write({mode: "ralph", active: false, current_phase: "complete", completed_at: "<now>"})`113- **On cancellation/cleanup**:114 run `$cancel` (which should call `state_clear(mode="ralph")`)115116117## Scenario Examples118119**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.120121**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.122123**Bad:** The user says `continue`, and the workflow restarts discovery or stops before the missing verification/evidence is gathered.124125<Examples>126<Good>127Correct parallel delegation:128```129delegate(role="executor", tier="LOW", task="Add type export for UserConfig")130delegate(role="executor", tier="STANDARD", task="Implement the caching layer for API responses")131delegate(role="executor", tier="THOROUGH", task="Refactor auth module to support OAuth2 flow")132```133Why good: Three independent tasks fired simultaneously at appropriate tiers.134</Good>135136<Good>137Correct verification before completion:138```1391. Run: npm test → Output: "42 passed, 0 failed"1402. Run: npm run build → Output: "Build succeeded"1413. Run: lsp_diagnostics → Output: 0 errors1424. Delegate to architect at STANDARD tier → Verdict: "APPROVED"1435. Run /cancel144```145Why good: Fresh evidence at each step, architect verification, then clean exit.146</Good>147148<Bad>149Claiming completion without verification:150"All the changes look good, the implementation should work correctly. Task complete."151Why bad: Uses "should" and "look good" -- no fresh test/build output, no architect verification.152</Bad>153154<Bad>155Sequential execution of independent tasks:156```157delegate(executor, LOW, "Add type export") → wait →158delegate(executor, STANDARD, "Implement caching") → wait →159delegate(executor, THOROUGH, "Refactor auth")160```161Why bad: These are independent tasks that should run in parallel, not sequentially.162</Bad>163</Examples>164165<Escalation_And_Stop_Conditions>166- Stop and report when a fundamental blocker requires user input (missing credentials, unclear requirements, external service down)167- Stop when the user says "stop", "cancel", or "abort" -- run `/cancel`168- Continue working when the hook system sends "The boulder never stops" -- this means the iteration continues169- If architect rejects verification, fix the issues and re-verify (do not stop)170- If the same issue recurs across 3+ iterations, report it as a potential fundamental problem171</Escalation_And_Stop_Conditions>172173<Final_Checklist>174- [ ] All requirements from the original task are met (no scope reduction)175- [ ] Zero pending or in_progress TODO items176- [ ] Fresh test run output shows all tests pass177- [ ] Fresh build output shows success178- [ ] lsp_diagnostics shows 0 errors on affected files179- [ ] Architect verification passed (STANDARD tier minimum)180- [ ] ai-slop-cleaner pass completed on changed files (or --no-deslop specified)181- [ ] Post-deslop regression tests pass182- [ ] `/cancel` run for clean state cleanup183</Final_Checklist>184185<Advanced>186## PRD Mode (Optional)187188When the user provides the `--prd` flag, initialize a Product Requirements Document before starting the ralph loop.189190### Detecting PRD Mode191Check if `{{PROMPT}}` contains `--prd` or `--PRD`.192193Prompt-side `$ralph` workflow activation is lighter-weight than `omx ralph --prd ...`.194It seeds Ralph workflow state and guidance, but it does not implicitly launch the195CLI entrypoint or apply the PRD startup gate. Treat `omx ralph --prd ...` as the196explicit PRD-gated path.197198### Detecting `--no-deslop`199Check if `{{PROMPT}}` contains `--no-deslop`.200If `--no-deslop` is present, skip the deslop pass entirely after Step 7 and continue using the latest successful pre-deslop verification evidence.201202### Visual Reference Flags (Optional)203Ralph execution supports visual reference flags for screenshot tasks:204- Repeatable image inputs: `-i <image-path>` (can be used multiple times)205- Image directory input: `--images-dir <directory>`206207Example:208`ralph -i refs/hn.png -i refs/hn-item.png --images-dir ./screenshots "match HackerNews layout"`209210### PRD Workflow2111. Run deep-interview in quick mode before creating PRD artifacts:212 - Execute: `$deep-interview --quick <task>`213 - Complete a compact requirements pass (context, goals, scope, constraints, validation)214 - Persist interview output to `.omx/interviews/{slug}-{timestamp}.md`2152. Create canonical PRD/progress artifacts:216 - PRD: `.omx/plans/prd-{slug}.md`217 - Progress ledger: `.omx/state/{scope}/ralph-progress.json` (session scope when available, else root scope)2183. Parse the task (everything after `--prd` flag)2194. Break down into user stories:220221```json222{223 "project": "[Project Name]",224 "branchName": "ralph/[feature-name]",225 "description": "[Feature description]",226 "userStories": [227 {228 "id": "US-001",229 "title": "[Short title]",230 "description": "As a [user], I want to [action] so that [benefit].",231 "acceptanceCriteria": ["Criterion 1", "Typecheck passes"],232 "priority": 1,233 "passes": false234 }235 ]236}237```2382395. Initialize canonical progress ledger at `.omx/state/{scope}/ralph-progress.json`2406. Guidelines: right-sized stories (one session each), verifiable criteria, independent stories, priority order (foundational work first)2417. Proceed to normal ralph loop using user stories as the task list242243### Example244User input: `--prd build a todo app with React and TypeScript`245Workflow: Detect flag, extract task, create `.omx/plans/prd-{slug}.md`, create `.omx/state/{scope}/ralph-progress.json`, begin ralph loop.246247### Legacy compatibility248- During the compatibility window, Ralph `--prd` startup still validates machine-readable story state from `.omx/prd.json`.249- `.omx/plans/prd-{slug}.md` remains the canonical storage/documentation artifact, but it is not yet the startup validation source.250- If `.omx/prd.json` exists and canonical PRD is absent, migrate one-way into `.omx/plans/prd-{slug}.md`.251- If `.omx/progress.txt` exists and canonical progress ledger is absent, import one-way into `.omx/state/{scope}/ralph-progress.json`.252- Keep legacy files unchanged for one release cycle.253254## Background Execution Rules255256**Run in background** (`run_in_background: true`):257- Package installation (npm install, pip install, cargo build)258- Build processes (make, project build commands)259- Test suites260- Docker operations (docker build, docker pull)261262**Run blocking** (foreground):263- Quick status checks (git status, ls, pwd)264- File reads and edits265- Simple commands266</Advanced>267268Original task:269{{PROMPT}}