This guide gets you from zero to a working Ralph + RLM loop quickly.
- Put the plugin at
.opencode/plugins/ralph-rlm.ts(project) or~/.config/opencode/plugins/(global). - Start OpenCode in your repo.
- Ensure
.opencode/ralph.jsonexists (or run doctor in step 2).
Ralph-RLM has two distinct layers so the agent behavior stays predictable:
- Main session (you): Supervisor + strategist in one. It orchestrates the loop, updates
PLAN.md/RLM_INSTRUCTIONS.md, and callsralph_spawn_worker(). It should not implement code. - RLM worker (per-attempt): A fresh coding session that does the actual edits, calls
ralph_verify(), then stops.
Think of it as: Main strategist (you) → RLM worker (implementation).
Main strategist (you)
└─ RLM worker (attempt N)
└─ ralph_verify()
├─ pass → done
└─ fail → attempt N+1 (new worker)
- Main strategist stays high-level (orchestration, decisions, answering
ralph_ask). - Main strategist updates
PLAN.md/RLM_INSTRUCTIONS.md, then spawns a worker. - Worker does the actual edits, calls
ralph_verify(), then stops. - The loop continues until
verify.commandpasses ormaxAttemptsis reached.
Run:
ralph_doctor(autofix=true)
This creates missing baseline files/config and checks readiness.
Fast path (recommended):
ralph_quickstart_wizard(goal, requirements, stopping_conditions, features, steps, todos, start_loop=false)
Manual path:
ralph_bootstrap_plan(...)ralph_validate_plan()
Tip: put clear stopping conditions in the plan and a strong verify.command in .opencode/ralph.json.
Default is manual start (autoStartOnMainIdle: false):
ralph_create_supervisor_session(start_loop=true)
Check status anytime:
ralph_supervision_status()
This repo includes project-local OpenCode agent profiles in .opencode/agents/:
supervisor(primary): safe orchestration posture for Ralph loop controlralph-reviewer(subagent): read-only quality reviewdocs-writer(subagent): documentation edits without shell accesssecurity-auditor(subagent): read-only security-focused review
Use these to control behavior and delegation while keeping loop execution in the plugin.
- Structured feed:
SUPERVISOR_LOG.md - Human-readable timeline:
CONVERSATION.md - Session questions: use
ralph_respond(id, answer)when prompted byralph_ask() - Quick peek (posts worker CURRENT_STATE into main conversation):
ralph_peek_worker()
- Cycle primary agents with Tab (OpenCode calls this
agent_cycle). - If sub-agents spawn child sessions, cycle parent ⇄ child with:
<leader>+Right(session_child_cycle)<leader>+Left(session_child_cycle_reverse)
- Open the sessions list with
/sessions(or<leader>+l) to jump between sessions. - Keybinds are configured in
opencode.json(default leader isctrl+x).
- Pause without ending:
ralph_pause_supervision(reason?) - Resume:
ralph_resume_supervision(start_loop?) - Hard stop:
ralph_end_supervision(reason?, clear_binding?, delete_sessions?) - Restart after stop/done:
ralph_create_supervisor_session(restart_if_done=true)
To avoid running reviewer too often:
- Worker signals readiness:
ralph_request_review("ready for review") - Supervisor runs reviewer:
ralph_run_reviewer() - Report is written to
.opencode/reviews/review-attempt-N.md
Reviewer limits are controlled by:
reviewerRequireExplicitReadyreviewerMaxRunsPerAttemptreviewerEnabled
Reviewer runtime state persists in .opencode/reviewer_state.json.
{
"enabled": true,
"autoStartOnMainIdle": false,
"statusVerbosity": "normal",
"maxAttempts": 25,
"heartbeatMinutes": 15,
"verifyTimeoutMinutes": 15,
"verify": { "command": ["bun", "run", "verify"], "cwd": "." },
"gateDestructiveToolsUntilContextLoaded": true,
"maxRlmSliceLines": 200,
"requireGrepBeforeLargeSlice": true,
"grepRequiredThresholdLines": 120,
"subAgentEnabled": true,
"maxSubAgents": 5,
"maxConversationLines": 1200,
"conversationArchiveCount": 3,
"reviewerEnabled": false,
"reviewerRequireExplicitReady": true,
"reviewerMaxRunsPerAttempt": 1,
"reviewerOutputDir": ".opencode/reviews",
"reviewerPostToConversation": true,
"agentMdPath": "AGENT.md"
}ralph_spawn_worker() must be called from the bound supervisor session- Start with
ralph_create_supervisor_session()and callralph_spawn_worker()from that session.
- Start with
- Loop not starting
- Check
ralph_supervision_status()and runralph_doctor(autofix=true).
- Check
- Verify always failing
- Fix
verify.commandto match your repo’s actual quality gate.
- Fix
- Too much log noise
- Lower
statusVerbosityor reduce loop chatter by using milestone-levelralph_reportonly.
- Lower
For full reference, see README.md.