OpenCode ready
1 variant

Ralph Loop

Iterative loop for OpenCode that advances one step per run from a prompt file.

Ralph achieved in @opencode! Running a Ralph loop right now to Migrate DB and ORMs on GPT-5.2-extra-high thinking A ralph agent, /command, plugin (for stop events and notifications), a linter on the prompt file, + extra security so it accepts basically everything except overly

Show more

Installation

Install

CLI install

Uses the same host and base path as this registry.

npx shadcn@latest add https://brennanmceachran.github.io/agent-utils/ralph-loop-opencode.json

Quick start

What this gives you

  • A bounded loop that advances one useful step per iteration.
  • A progress log written back into the prompt file after each run.
  • The ability to let an agent grind through the happy path for hours.
  • Inspired by the Claude Code Ralph Wiggum loop technique.

I have run this for 4-5 hours on gpt-5.2-codex (extra high reasoning) without babysitting.

Try it

  1. Create a PRD file (template below).
  2. Switch to the Ralph agent and run:
/ralph @docs/feature-x.prd.md 10
  1. Watch it work! The loop will continue until the agent responds with RALPH_DONE, then re-run or you manually stop it /ralph stop.
  2. ???
  3. Profit.

Usage

How to use it well

1) Draft a PRD (validator-required sections)

Ralph validates the prompt file. These headings are required and must be non-empty:

  • Goal
  • Acceptance Criteria
  • Verification
  • Progress

Below is a template. Copy it and fill it out replace with your details. Leave the Progress section alone.

# PRD: <Feature name>

## TL;DR

- One sentence: what are we shipping?

## Goal

- What outcome should exist when done?

## Constraints

- Tech constraints, deadlines, guardrails.

## Acceptance Criteria

- [ ] Observable success conditions
- [ ] Edge cases you care about

## Verification

- Tests or manual checks that prove it works

## Notes

- Anything the loop should remember each iteration

## Progress

It's your job to update the progress field every time you make a change. The purpose of this is to ensure the next developer knows what you did, what's done, any decisions or assumptions you made, and is able to continue working. If you've made changes, please copy and paste this template to the bottom of the progress and edit to add your notes.

```template
### {{Title}} - {{Date}}

- {{Summary}}
- {{Decisions}}
- {{Assumptions}}
- {{Risks}}
- {{Status}}
- Best guess at what comes next & why:
  - {{Next}}
  - {{Next?}}
```

Add entries below this line:

2) Set the model

Pick a model that can grind:

  • gpt-5.2-codex (extra high reasoning)
  • Opus 4.5

3) Switch to the Ralph agent

Tab through agents until the status reads ralph.

4) Run the loop

The Ralph commands has two parameters:

  1. The path to the PRD file
  2. The max number of iterations to run (default 25)

Start with 5 iterations until you get the hang of it:

/ralph @docs/feature-x.prd.md 5

Then up as needed:

/ralph @docs/feature-x.prd.md 50

5) How the loop behaves

It will keep smashing your prompt back into the loop until it outputs RALPH_DONE or hits the max iteration cap. That is the point: run the happy path for hours without babysitting. Each iteration writes Progress back into the PRD. So the next turn picks up where the last left off.

The configs auto accept everything, but stop git push and attemp to stop any destructive actions.

6) Need to steer every once and a while?

Because this is in Opencode UI, you can interact with the loop while it's running.

Just type a message and hit enter. OpenCode will insert it at the next available moment nudging the agent in the right direction.

However, I find the models eventually get there so try to resist the urg.

7) Stop the loop

  • Press Ctrl+C
  • Or run /ralph stop

Examples

Shared runs

ThreadPlatformWhat it showsLink
Summarizing RALPH_CONTROL loop control messageOpenCodeLoop run with progress updates and status tracking.Open thread

Notes

Notes

Restart OpenCode after installing to register the /ralph command. Prefer file-based prompts (use @path) for long instructions and multi-line edits.