This gist contains:
ralph-loop.sh: runs Codex in an autonomous loop that repeatedly:- picks the highest-priority task from
PRD.md+progress.txt - implements only that task
- runs tests/typechecks
- updates
PRD.mdand appends toprogress.txt - commits
- stops when a “promise” file is created
- picks the highest-priority task from
codexCLI installed + authenticated- A git repo with:
PRD.md(task list + acceptance criteria)progress.txt(append-only log)
- Put
ralph-loop.shin your repo root chmod +x ralph-loop.sh- Create
PRD.mdandprogress.txt(tips below) - Run:
./ralph-loop.sh 10 - Review the commits it produced
From “ask-questions-if-underspecified”: ask the minimum set of questions needed to avoid wrong work. Aim for 1–5.
Good defaults:
- Objective: what should change vs stay the same?
- “Done”: acceptance criteria + examples/edge cases?
- Scope: what’s in/out?
- Constraints: compatibility, performance, style, deps, time?
- Environment: runtime versions + test commands?
From “doc-coauthoring”: do (1) context gathering, (2) draft/refine section-by-section, then (3) reader testing.
Reader testing is especially useful: paste PRD.md into a fresh chat and ask:
- “What are the top 3 risks/unknowns?”
- “What’s the smallest first milestone?”
- “What would you do first, and why?” If it misunderstands anything, fix the PRD.
# <Project / Feature>
## Goal
<one paragraph>
## Non-goals
- ...
## Requirements (ordered)
- [ ] R1: ... (acceptance criteria)
- [ ] R2: ...
## Open Questions
- Q1: ...Append after each loop:
- date/time + iteration
- what changed (1–5 bullets)
- commands/tests run
- next task(s) / blockers
Example:
2026-01-12 iter 3
- Done: ...
- Tests: ...
- Next: ...ralph-loop.sh uses codex --dangerously-bypass-approvals-and-sandbox exec.
Run it only in a safe repo/branch, start with a small iteration count, and review commits before merging.
- https://www.humanlayer.dev/blog/brief-history-of-ralph
- https://www.aihero.dev/tips-for-ai-coding-with-ralph-wiggum
- Clarifying questions: https://github.com/prateek/dotfiles/blob/master/.codex/skills/ask-questions-if-underspecified/SKILL.md
- Doc co-authoring workflow: https://github.com/anthropics/skills/blob/main/skills/doc-coauthoring/SKILL.md