Skip to content

Instantly share code, notes, and snippets.

@mgreenly
Created July 1, 2026 16:25
Show Gist options
  • Select an option

  • Save mgreenly/504b1f90d460841b1628502687e87cb8 to your computer and use it in GitHub Desktop.

Select an option

Save mgreenly/504b1f90d460841b1628502687e87cb8 to your computer and use it in GitHub Desktop.
A continue, next, done ralph loop in codex with the /goal command (external cursor)
/goal Advance the gather -> build -> verify prompt cycle until DONE (verify wraps
back to gather), using ./project/prompts/cursor.md as the durable current-step
marker. Each iteration: read cursor.md for the current step; if it is missing or
empty, the current step is gather. Spawn a Codex subagent to read and execute that
step's prompt file (./project/prompts/{gather,build,verify}.md); it ends by
emitting a single JSON object of the form {"status": ..., "message": ...}. Parse
its "status" and relay its "message" so progress stays visible, then act:
CONTINUE -- leave cursor.md unchanged and continue the goal with the same step.
NEXT -- write the next step in the cycle to cursor.md and continue the goal.
DONE -- delete cursor.md and stop the goal. If a subagent fails, or its final
output is not a JSON object carrying a "status" of exactly CONTINUE, NEXT, or
DONE, stop and surface the raw output -- never guess a status, and leave cursor.md
unchanged. You are only the orchestrator: you read and write cursor.md for
bookkeeping, but never read the prompt files themselves -- subagents read and
execute those.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment