Ralph Loop Autonomous Overnight Runner
Wire the Claude Code CLI mode (-p flag) into the Ralph loop plugin so a while-loop keeps feeding the same prompt with updated files until the task is done.
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
name: ralph-loop-autonomous-runner description: Wire the Claude Code CLI mode (-p flag) into the Ralph loop plugin so a while-loop keeps feeding the same prompt with updated files until the task is done.
Ralph Loop Autonomous Overnight Runner
What This Does
The creator explains headless mode (-p flag) plus the community Ralph loop pattern named after Ralph Wiggum from The Simpsons. Instead of one-shotting a task, the loop re-prompts Claude with the current file state and remaining to-dos until the whole feature ships, often overnight without human input.
What You Get
- -p CLI headless mode
- Ralph loop while-loop wrapper
- per-iteration file-state summary
- auto-stop when to-do list empties
- overnight-friendly log format
Customize
- prompt: the master task instruction
- loop_condition: while todos_remaining > 0
- sleep_interval: seconds between iterations
- log_path: where iteration output writes
- max_iterations: safety cap
Sample Output
The Ralph loop lets a solo developer ship an entire project overnight with the same prompt re-fed with the updated file state each pass.
Target Audience
Solo devs who want overnight autonomous shipping
SKILL.md preview
---
name: ralph-loop-autonomous-runner
description: Use this skill to wire Claude Code's headless mode into a repeating loop that re-feeds the same prompt with updated file state until a multi-step task is fully done.
version: 1.0.0
category: Agent Orchestration
author: AgentVolt
license: proprietary
tags:
- agent-orchestration
- standard
---
# Ralph Loop Autonomous Overnight Runner
Runs Claude Code in headless mode inside a while-loop that keeps re-prompting with the current file state and remaining to-dos, letting a large task ship across many iterations instead of one shot.
## When to use
… (sign up to view the full skill)More ai & agents skills
View all AI & Agents skills →Self-Improving Skill Overnight Loop
Run an automated overnight research loop on a Claude skill: try a tweak, run binary assertions, keep or revert based on pass rate, and iterate.
Recursive Skill Failure-Fix Loop
Every time your skill fails on a real task, feed the failure back and have Claude update the skill.md so it never breaks that way again.
Critique Sub-Agent Reviewer
Every time the main agent produces copy, research, or code, hand it to a critique sub-agent that returns fix notes before the output ships.
AI Starter Toolkit
A free, curated starting point — the essential prompts and habits to get real value from AI on day one.