ralph-wiggum-codex
Scannednpx machina-cli add skill MattMagg/ralph-wiggum-codex/ralph-wiggum-codex --openclawRalph Wiggum For Codex
Codex-native long-running refinement loop.
This skill is designed to be invoked as a Codex skill ($ralph-wiggum-codex).
The loop runner script is an internal execution engine for the skill, not the primary user-facing entrypoint.
When To Use
Use this skill when:
- The task is unlikely to finish in one turn.
- You need repeated implement -> validate -> refine cycles.
- You want schema-based completion signaling with resumable state.
- You need unattended or semi-attended long-running execution with drift resistance.
Do not use this skill when:
- The request is a quick one-shot edit or explanation.
- No meaningful validation loop exists.
- The user wants manual step-by-step control each turn.
Companion Prompt Generator (Recommended Handoff)
When objectives are ambiguous or missing loop configuration, invoke $ralph-prompt-generator first to produce a ready-to-run block for this skill.
Use the companion first when:
- Validation commands are unknown or incomplete.
- Scope/progress paths are unclear.
- Model/reasoning/iteration caps are not specified.
- The task is high risk and you want stronger guardrails before execution.
Companion handoff pattern:
- Run
$ralph-prompt-generatorwith the raw request. - Answer its required question about suggested output sections.
- Confirm any inferred validations/scopes it proposes (or provide your own).
- Provide any additional targeted clarifications it requests.
- Execute the generated block, which should start with:
/skills$ralph-wiggum-codex
You can skip the companion when you already have a complete, validated prompt with explicit flags and checks.
Skill-First Operating Contract
When this skill is invoked, execute this flow:
- Collect or infer:
cwd- Objective text
- Validation commands (fastest checks first)
- Progress scopes (
--progress-scope) for meaningful edits - Codex runtime binary/path (
--codex-bin) for deterministic runtime selection - Event stream artifact format (
--events-format <tsv|jsonl|both>, defaultboth) - Whether to persist per-iteration progress artifacts (
--progress-artifact) - Runtime caps (
max-iterations,max-stagnant-iterations, timeout settings) - Completion promise only if compatibility mode is required (deprecated)
- Prepare loop files under
<cwd>/.codex/ralph-loop/:
objective.md(objective to reload every iteration)feedback.md(optional operator steering)
-
Start the loop runner with objective/feedback files and validations.
-
Monitor run artifacts (
events.log,run-summary.md,iteration-history.md, validation logs) and report concise progress. -
If blocked, update
feedback.mdwith corrective guidance and continue (--resume) instead of restarting from scratch.
Execution Command Template
~/.codex/skills/ralph-wiggum-codex/scripts/ralph-loop-codex.sh \
--cwd /path/to/repo \
--codex-bin codex \
--objective-file /path/to/repo/.codex/ralph-loop/objective.md \
--feedback-file /path/to/repo/.codex/ralph-loop/feedback.md \
--events-format both \
--progress-artifact \
--completion-promise "DONE" \
--max-iterations 40 \
--max-stagnant-iterations 6 \
--progress-scope "src/" \
--idle-timeout-seconds 900 \
--hard-timeout-seconds 7200 \
--timeout-retries 1 \
--validate-cmd "npm run lint" \
--validate-cmd "npm run test"
Long-Run Refinement Features
The runner supports long-running autonomy with iterative correction:
- Dynamic objective reload each iteration (
--objective-file) - Live operator feedback ingestion (
--feedback-file) - Auto-generated corrective feedback when codex/validation fails (
auto-feedback.md) - Iteration memory (
iteration-history.md) injected into future prompts - Stagnation detection (
--max-stagnant-iterations) - Scoped no-op prevention (
--progress-scope+no_change_justification) - Default-on watchdog timeouts with controlled retries
- Resumable state and lock-based single-run protection with stale lock recovery
Output Contract
Completion is accepted when all of the following are true:
codex execoutput conforms to.codex/ralph-loop/completion-schema.jsonstatusisCOMPLETE- Validation commands pass
- Scoped progress gate passes (or includes
no_change_justification) - If compatibility mode is enabled,
completion_promiseequals--completion-promise
Schema fields:
status:IN_PROGRESS,BLOCKED,COMPLETEevidence: non-empty array of concrete evidencenext_step: one highest-impact next stepno_change_justification: required key; non-empty only for justified no-change iterations, else empty stringcompletion_promise: required key; compatibility value when configured, else empty string
Core Files
.codex/ralph-loop/state.env.codex/ralph-loop/prompt.txt.codex/ralph-loop/events.log.codex/ralph-loop/events.jsonl(with--events-format jsonl|both; defaultboth).codex/ralph-loop/completion-schema.json.codex/ralph-loop/iteration-history.md.codex/ralph-loop/feedback.md.codex/ralph-loop/auto-feedback.md.codex/ralph-loop/last-message.txt.codex/ralph-loop/run-summary.md.codex/ralph-loop/progress/(when--progress-artifactis enabled).codex/ralph-loop/validation/.codex/ralph-loop/codex/iteration-<n>-attempt-<m>.jsonl.codex/ralph-loop/.lock/meta.env(while active)
events.log remains compatible for existing consumers; JSONL events are additive.
Resume And Stop
Resume:
~/.codex/skills/ralph-wiggum-codex/scripts/ralph-loop-codex.sh \
--cwd /path/to/repo \
--resume
Stop safely:
touch /path/to/repo/.codex/ralph-loop/STOP
References
- Harness principles:
references/harness-principles.md - Operational runbook:
references/runbook.md - Reliability vNext:
references/reliability-vnext.md
Source
git clone https://github.com/MattMagg/ralph-wiggum-codex/blob/main/skills/ralph-wiggum-codex/SKILL.mdView on GitHub Overview
Ralph Wiggum Codex enables long-running, multi-turn coding tasks with explicit completion criteria, validation checks, and resumable loop state. It supports schema-based progress signaling and drift-resistant unattended execution, ensuring repeated refine cycles converge to a defined outcome.
How This Skill Works
Used as a Codex skill, it collects cwd, objective text, validation commands, and progress scopes, then runs a loop under <cwd>/.codex/ralph-loop/. It creates objective.md and feedback.md, launches the loop runner, and emits artifacts like events.log, run-summary.md, and iteration-history.md to track progress and enable resume capability.
When to Use It
- The task is unlikely to finish in one turn and needs iterative refine cycles.
- You require implement -> validate -> refine cycles with explicit completion criteria.
- You want schema-based completion signaling with resumable state and per-iteration context.
- You need unattended or semi-attended long-running execution with drift resistance.
- Avoid for quick one-shot edits or when there is no meaningful validation loop.
Quick Start
- Step 1: Prepare your workspace and create objective.md; optionally include initial feedback.md.
- Step 2: Start the loop with the real script (e.g., ~/.codex/skills/ralph-wiggum-codex/scripts/ralph-loop-codex.sh) and provide validation commands.
- Step 3: Monitor artifacts (events.log, run-summary.md, iteration-history.md); update feedback.md and use --resume to continue when blocked.
Best Practices
- Define objective.md and at least the initial validation commands before starting the loop.
- Keep progress scopes narrow and measurable (e.g., subset of code, tests, or specs).
- Use feedback.md to steer corrections; update it when the loop stalls and you want to resume.
- Leverage iteration-history.md to preserve context and improve future iterations.
- Run validations frequently (lint, tests) and capture artifacts (events.log, run-summary.md) for auditing.
Example Use Cases
- Incrementally refactor a legacy module with automated validation after each change.
- Implement a new feature via iterative build -> test -> refine cycles with clear criteria.
- Migrate dependencies or configs and auto-detect drift with structured feedback.
- Auto-generate or complete a large spec by validating intermediate outputs at each step.
- Pause and resume performance tuning with per-iteration state carried forward.