Stop-Hook Ralph (Deterministic Loop Without Bash)
A Ralph variant that lives inside a single Claude Code session: a stop hook re-injects the task prompt whenever the agent tries to end its turn, trading the bash while-loop's fresh context for a persistent session.
Implementation note
When to use: you want Ralph-style relentless iteration but inside a single Claude Code session — no bash wrapper, no process management — and you accept persistent context instead of fresh context as the trade. How it works: a Claude Code stop hook intercepts the agent whenever it tries to end its turn and re-injects the task prompt, forcing another iteration until a completion condition or a hard iteration cap is met. That yields Ralph semantics — keep going until done — deterministically within one session, trading the bash while-loop's fresh-context-per-iteration for session continuity and its context accumulation. Safety: the source's warning is the rule: always include a hard iteration cap in the hook logic, because a stop hook with no cap is an infinite loop by construction — the agent literally cannot end its turn. Make the completion condition machine-checkable, and remember that accumulated context drifts; for very long runs, fresh-context Ralph resists drift better.
More automation loops
Ship production-grade apps autonomously
Hand an idea to Claude Code; it authors specs, designs, builds, tests, secures, and ships until enterprise done or budget exhausted.
claude-progress.txt harness pattern (Anthropic)
Anthropic's first-party file-as-memory harness for long-running agents: every fresh-context session recovers state from a progress file and the git log, does one unit of work, updates the file, commits, and exits.
Complete all tasks in tasks.md
Work through your tasks.md file, completing each task until none remain or max iterations is reached.