Anthropic's Ralph Loop + Claude Code: Anthropic's new FRAMEWORK can run CLAUDE CODE for 24/7!

AICodeKingAbout 5 min readDec 29, 2025Watch original
THE SUMMARYAI-generated

Ralph Wigum: Persistent AI Agents with Clawed Code

Key Concepts:

  • Clawed Code: An agentic tool for interacting with large language models (LLMs) to build and modify code.
  • Hooks: User-defined shell commands within Clawed Code that execute at specific points in the agent’s lifecycle, providing deterministic control.
  • Stop Hook: A specific type of hook that runs when Claude Code attempts to end a session.
  • Ralph Wigum Plugin: A Clawed Code plugin utilizing the stop hook to create a persistent loop, forcing the AI to continue working until a defined completion criteria is met.
  • Completion Promise: A specific word or phrase defined in the prompt that signals successful task completion, triggering the AI to exit the loop.
  • Opus 4.5: A powerful LLM from Anthropic, known for its strong reasoning capabilities, particularly in coding tasks.
  • D-max Iterations: A safety flag used with Ralph Wigum to limit the number of loop iterations, preventing excessive API costs.

The Problem of AI “Laziness” & Premature Completion

The video addresses a common issue with current AI agents like Clawed Code: a tendency to prematurely declare task completion, often with incomplete or incorrect results. This “laziness” stems from the AI’s desire to conserve tokens and a lack of inherent persistence. The agent might write a few files and then confidently state the task is finished, even if critical components like database schemas or tests are missing. This necessitates significant user intervention to correct errors and prompt further development. The speaker highlights the frustration of spending time debugging AI-generated code that should have been functional from the start.

Introducing Ralph Wigum: Persistence Through Hooks

The Ralph Wigum plugin for Clawed Code offers a solution by implementing a persistent loop. This is achieved through the use of hooks, specifically the stop hook. Hooks allow users to define custom shell commands that execute at various stages of the agent’s operation. The stop hook intercepts the AI’s attempt to exit the session. Instead of allowing the AI to terminate, Ralph Wigum checks for a pre-defined completion promise within the AI’s output. If the promise isn’t present, the hook redirects the AI back to the original prompt, initiating another iteration. This creates a self-referential feedback loop where the AI continuously revises its work based on its previous outputs and errors. As the speaker states, “It grabs Claude by the collar and throws it back into the loop with the same prompt.”

Implementing Ralph Wigum: A Step-by-Step Process

  1. Activate Ralph Loop: Initiate the plugin with the /raffloop command in Clawed Code.
  2. Define the Prompt: Craft a detailed prompt that clearly outlines the desired outcome, including specific requirements (e.g., technologies to use, features to implement).
  3. Specify Completion Promise: Include a flag like completion promise complete to define the signal for successful completion.
  4. Set Max Iterations: Utilize the --d-max iterations flag (e.g., --d-max iterations 20) to limit the number of loop iterations and prevent runaway costs.
  5. Execute & Monitor: Run the command and allow the loop to execute, observing the AI’s iterative process.

The Power of Opus 4.5 in a Ralph Loop

While Ralph Wigum functions with various LLMs, its effectiveness is significantly amplified when paired with Claude Opus 4.5. Opus 4.5’s superior reasoning capabilities (scoring nearly 90% on coding benchmarks) allow it to not only identify errors but also understand why those errors occurred. This prevents the AI from getting stuck in unproductive loops, a common issue with less powerful models like Haiku or Flash. The speaker notes that Opus 4.5 costs approximately $25 per million output tokens, but argues the value proposition is high, potentially allowing for fully automated code refactoring and bug fixing. As stated, “if you really want to see something insane, you need to pair this with Opus 4.5.”

Prompt Engineering for Success with Ralph Wigum

Effective use of Ralph Wigum requires a shift in prompt engineering. Vague prompts like “make it good” are ineffective because they lack objective criteria. Instead, prompts should focus on binary success criteria – conditions that can be automatically verified. The speaker emphasizes the importance of using tests as a completion criterion: “Tests passing is the best one because the computer can verify it.” Other suitable criteria include linting and compilation success. The goal is to define a clear goal state that the AI can reliably assess.

Real-World Application: Automated Unit Test Generation

The speaker provides a practical example of using Ralph Wigum to write comprehensive unit tests for an existing project. By prompting the AI to “Write tests until coverage is 80%,” they were able to automate a tedious task, achieving the desired coverage with minimal human intervention after approximately five to six iterations.

Shifting the Burden of Management

Ralph Wigum fundamentally alters the interaction with AI agents. Instead of constant monitoring and correction, the user defines the desired outcome and allows the loop to manage the iterative process. The speaker highlights this shift: “It shifts the burden of management from you to the script.”

Conclusion: Brute-Force Intelligence and Persistence

Ralph Wigum represents a novel approach to leveraging AI for complex coding tasks. By combining intelligence (particularly with Opus 4.5) and persistence, it allows users to “brute force” solutions to problems that would otherwise require significant manual effort. The plugin is particularly well-suited for tasks with automatic verification mechanisms, offering a powerful tool for automating code generation, refactoring, and testing.

AI summaries can miss context or contain errors. Check important details against the original video.

Go a little deeper.

Have a question about this video? Load its transcript to open the video chat.