ralph-wiggum

Implements the Ralph Wiggum autonomous iteration technique with deliberate context management. Use when building greenfield projects, iterating on well-defined tasks, or when continuous autonomous development is needed. Manages context like memory - tracks allocations, prevents redlining, and knows when to start fresh.

457 stars

Best use case

ralph-wiggum is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Implements the Ralph Wiggum autonomous iteration technique with deliberate context management. Use when building greenfield projects, iterating on well-defined tasks, or when continuous autonomous development is needed. Manages context like memory - tracks allocations, prevents redlining, and knows when to start fresh.

Teams using ralph-wiggum should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

How ralph-wiggum Compares

Feature / Agentralph-wiggumStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Implements the Ralph Wiggum autonomous iteration technique with deliberate context management. Use when building greenfield projects, iterating on well-defined tasks, or when continuous autonomous development is needed. Manages context like memory - tracks allocations, prevents redlining, and knows when to start fresh.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Ralph Wiggum: Autonomous Iteration with Context Engineering

Ralph is a technique for autonomous AI development. In its purest form, Ralph is a loop that repeatedly feeds the same prompt to an AI agent, letting it iterate on a task until completion. The key insight is that **context is like memory** - when you `malloc()` data into the context window, it cannot be `free()`'d except by starting fresh.

## Core Philosophy

> "That's the beauty of Ralph - the technique is deterministically bad in an undeterministic world."

Ralph will make mistakes. That's expected. Each mistake is an opportunity to add a "sign" (guardrail) that prevents that mistake in the future. Like tuning a guitar, you adjust Ralph until it plays the right notes.

### The malloc/free Metaphor

- **Context is memory**: Everything loaded into the LLM's context window stays there
- **You cannot free() context**: The only way to clear context is to start a new conversation
- **One task per context**: Mixed concerns lead to autoregressive failure
- **Don't redline**: Pushing context to limits degrades performance
- **Gutter detection**: Once the bowling ball is in the gutter, start fresh

## How This Skill Works

### State Files (The Persistent Memory)

Ralph tracks state in files, NOT in context:

```
.ralph/
├── state.md           # Current iteration, task, completion criteria
├── guardrails.md      # Accumulated "signs" from observed failures  
├── context-log.md     # What's been loaded into context
├── failures.md        # Failure patterns for learning
└── progress.md        # What's been accomplished
```

### The Iteration Cycle

1. **Read state files** to understand current task and progress
2. **Check guardrails** for relevant "signs" to follow
3. **Work on the task** - implement, test, refine
4. **Update progress** in files (not just context)
5. **Commit checkpoint** via git
6. **Evaluate completion** against criteria
7. **If not complete**: Signal for next iteration
8. **If stuck**: Detect gutter, suggest fresh context

### Guardrails ("Signs")

When Ralph makes a mistake, add a sign:

```markdown
## Sign: Don't Jump Off The Slide
- **Trigger**: When implementing authentication
- **Instruction**: Always validate tokens before trusting claims
- **Added after**: Iteration 5 - security vulnerability introduced
```

Signs accumulate in `guardrails.md` and are injected into future iterations.

## Usage

### Starting a Ralph Loop

Create a `RALPH_TASK.md` file in your project root:

```markdown
---
task: Build a REST API for task management
completion_criteria:
  - All CRUD endpoints working
  - Input validation implemented
  - Tests passing with >80% coverage
  - API documentation complete
max_iterations: 50
---

## Requirements

Build a task management API with the following endpoints:
- POST /tasks - Create a task
- GET /tasks - List all tasks
- GET /tasks/:id - Get a task
- PUT /tasks/:id - Update a task
- DELETE /tasks/:id - Delete a task

## Constraints

- Use TypeScript
- Use Express.js
- Use SQLite for storage
- Follow REST conventions
```

Then tell Cursor: "Start a Ralph loop on this task"

### Monitoring Progress

Check `.ralph/progress.md` to see what's been accomplished:

```markdown
## Iteration 1
- Created project structure
- Implemented POST /tasks endpoint
- Status: Partial progress

## Iteration 2
- Added GET endpoints
- Fixed validation bug
- Status: Continuing
```

### When to Start Fresh

Ralph will detect "gutter" situations:
- Same error repeated 3+ times
- Context approaching limits
- Circular failure patterns

When detected, Ralph will suggest: "Context is polluted. Recommend starting fresh conversation."

## Best Practices

### 1. Clear Completion Criteria

❌ Bad: "Make a good API"
✅ Good: "All tests passing, coverage >80%, docs complete"

### 2. Incremental Goals

❌ Bad: "Build complete e-commerce platform"
✅ Good: Phase 1: Auth, Phase 2: Products, Phase 3: Cart

### 3. Let Failures Teach

Don't intervene too quickly. Let Ralph fail, then add signs.

### 4. Trust the Files

Progress is in files and git, not in your head or the context.

### 5. Fresh Context is Cheap

Don't hesitate to start fresh. State persists in files.

## Integration with Cursor Hooks

This skill uses Cursor hooks for:

- **beforeSubmitPrompt**: Inject guardrails and context awareness
- **beforeReadFile**: Track context allocations
- **afterFileEdit**: Update progress tracking
- **stop**: Evaluate completion, trigger next iteration or fresh start

See `scripts/` for hook implementations.

## Learn More

- Original technique: https://ghuntley.com/ralph/
- Context engineering: https://ghuntley.com/gutter/
- malloc/free metaphor: https://ghuntley.com/allocations/

Related Skills

ralphinho-rfc-pipeline

144923
from affaan-m/everything-claude-code

基于RFC驱动的多智能体DAG执行模式,包含质量门、合并队列和工作单元编排。

DevelopmentClaude

ralph-plan

22487
from mastra-ai/mastra

Interactive planning assistant that helps create focused, well-structured ralph-loop commands through collaborative conversation

ralph

22262
from Yeachan-Heo/oh-my-claudecode

Self-referential loop until task completion with configurable verification reviewer

ralph

18419
from Yeachan-Heo/oh-my-codex

Self-referential loop until task completion with architect verification

ralph-init

18419
from Yeachan-Heo/oh-my-codex

Initialize a PRD (Product Requirements Document) for structured ralph-loop execution

ralph

7060
from civitai/civitai

Autonomous agent for tackling big projects. Create PRDs with user stories, then run them via the CLI. Sessions persist across restarts with pause/resume and real-time monitoring.

ralph-opencode-free-loop

3891
from openclaw/skills

Run an autonomous Open Ralph Wiggum coding loop using OpenCode Zen with free models and automatic fallback.

ralph-loop

3891
from openclaw/skills

Guide OpenClaw agents to execute Ralph Wiggum loops using exec and process tools. Agent orchestrates coding agents (Codex, Claude Code, OpenCode, Goose) with proper TTY support via pty:true. Plans/builds code via PROMPT.md + AGENTS.md, SPECS and IMPLEMENTATION_PLAN.md. Includes PLANNING vs BUILDING modes, backpressure, sandboxing, and completion conditions. Users request loops, agents execute using tools.

Skill: Ralph — Two-Pass Issue Scanning

1828
from bradygaster/squad

**Confidence:** high

setup-ralph

1772
from glittercowboy/taches-cc-resources

Set up and configure Geoffrey Huntley's original Ralph Wiggum autonomous coding loop in any directory with proper structure, prompts, and backpressure.

ralph-loop

1174
from foryourhealth111-pixel/Vibe-Skills

Codex-compatible Ralph loop runner with dual engines (compat local state loop + optional open-ralph-wiggum backend).

cancel-ralph

1174
from foryourhealth111-pixel/Vibe-Skills

Codex-compatible cancel command for Ralph loop state, preserving the original command name.