Overnight Ralph Loop Runner
Run a Ralph loop overnight safely: sandbox, branch checkpoints, iteration, time, and spend caps, no pushes, and a morning review.
Before & after
Same prompt, same agent — the only difference is the skill.
Running an AI agent autonomously overnight is possible but requires setup. Some general considerations: - You'd want a way to run the agent in a loop - The agent needs to track what's done and what's left - You'd need guardrails so it doesn't go off track - Headless or CLI mode lets it run without interaction - Logging helps you review what happened There are community patterns and tools for this. You'd want to test carefully before leaving it unattended, since autonomous runs can go wrong in ways that are hard to undo. What are you trying to build overnight?
Yes — that's the Ralph loop pattern, wired to the CLI headless mode.
Here's how it works and the trap to set first.
THE MECHANISM
Instead of one-shotting a task, a shell while-loop re-invokes Claude in
headless mode (the -p flag) each iteration, feeding it the CURRENT file
state plus the remaining to-dos. Claude does a chunk, the loop re-reads
the files, and re-prompts with what's left. It converges on a finished
feature over many small passes rather than one giant one.
while tasks remain:
run claude -p with (prompt + current files + open to-dos)
let it make progress and update the to-do list
repeat
WHY IT WORKS OVERNIGHT
Each pass starts fresh from the real file state, so a mistake in pass 3
gets seen and corrected in pass 4 — the loop self-heals instead of
compounding. That's what lets it run unattended for hours.
THE GUARDRAIL TO SET BEFORE YOU SLEEP
A stop condition and a blast radius. Define "done" as a checkable
signal (tests green, to-do list empty), and scope it to a branch, not
main. An overnight loop with no exit condition and write access to main
is how you wake up to a mess.
WHAT YOU GET
Headless -p mode, the while-loop pattern, a to-do-driven convergence
loop, and a per-iteration log so you can read what happened over coffee.
Give me the feature and its "done" test, and I'll wire the loop.About this skill
A Ralph loop re-runs the same prompt against your repo until the job is done, which is powerful and risky when nobody is watching. This skill sets it up so it stops on its own, cannot push or deploy, and leaves a trail you can review over coffee.
What it does
- Applies a fit test: only runs when a command can prove the goal is done
- Sets up the sandbox, tool allowlist, dedicated branch, start tag, and per-iteration commits
- Enforces iteration, wall-clock, turn, and provider-side spend caps plus no-progress detection in the driver script
- Protects the tests from being weakened and forbids pushes, deploys, migrations, and publishing
- Produces a ten-minute morning review and report
What you get
PROMPT.md, a TODO format, a driver script, a pre-flight checklist, and a morning report template.
Best for
Solo developers who want to let Claude Code grind through a well-tested task overnight without waking up to a mess.
SKILL.md preview
---
name: ralph-loop-autonomous-runner
description: Set up and safely run a Ralph loop overnight - Claude Code in headless mode re-fed the same PROMPT.md against the repo's current state until a checkable goal is met - with a sandbox, a dedicated branch and per-iteration git checkpoints, hard caps on iterations, wall-clock time, and spend, no-progress detection, no pushes or deploys, and a morning report you can review in ten minutes. Use when the user says "run Claude overnight", "set up a Ralph loop", "keep re-running the prompt until it's done", "leave it building while I sleep", "while true claude -p", or casually "can I let it grind on this unattended?"
---
… (sign up to view the full skill)More ai & agents skills
View all AI & Agents skills →New Skill Scaffolder
Create a new Claude Code skill correctly: right mechanism, valid name and folder, a triggering description, and a smoke test.
Skill Library Lint and Overlap Report
Lint every skill in a repo at once: frontmatter, name-folder match, weak descriptions, overlapping triggers, broken refs, plus a CI script.
Self-Verifying Agent Loop: Plan, Check, Retry, Close
Turns a goal into a task plan with machine-run checks, executes with retry caps, escalates, and refuses to close until verified.
Skill Test Runner (Trigger and A/B)
Test a skill in fresh sessions: ready-to-run prompts, commands, and rubric for trigger recall, false triggers, and blind A/B.