ralph-modeAutonomous development loops with iteration, backpressure gates, and completion criteria. Use for sustained coding sessions that require multiple iterations, test validation, and structured progress tracking. Supports Next.js, Python, FastAPI, and GPU workloads with Ralph Wiggum methodology adapted for OpenClaw.
Install via ClawdBot CLI:
clawdbot install richginsberg/ralph-modeRalph Mode implements the Ralph Wiggum technique adapted for OpenClaw: autonomous task completion through continuous iteration with backpressure gates, completion criteria, and structured planning.
Use Ralph Mode when:
Phase 1: Requirements Definition
specs/ (one file per topic of concern)Phase 2: Planning
IMPLEMENTATION_PLAN.md with prioritized tasksPhase 3: Building (Iterative)
Reject incomplete work automatically through validation:
Programmatic Gates (Always use these):
[test command] - Must pass before committing[typecheck command] - Catch type errors early[lint command] - Enforce code quality[build command] - Verify integrationSubjective Gates (Use for UX, design, quality):
Create this structure for each Ralph Mode project:
project-root/
āāā IMPLEMENTATION_PLAN.md # Shared state, updated each iteration
āāā AGENTS.md # Build/test/lint commands (~60 lines)
āāā specs/ # Requirements (one file per topic)
ā āāā topic-a.md
ā āāā topic-b.md
āāā src/ # Application code
āāā src/lib/ # Shared utilities
Priority task list - single source of truth. Format:
# Implementation Plan
## In Progress
- [ ] Task name (iteration N)
- Notes: discoveries, bugs, blockers
## Completed
- [x] Task name (iteration N)
## Backlog
- [ ] Future task
Can you describe the topic in one sentence without "and"?
Succinct guide for running the project. Keep under 60 lines:
# Project Operations
## Build Commands
npm run dev # Development server
npm run build # Production build
## Validation
npm run test # All tests
npm run lint # ESLint
npm run typecheck # TypeScript
npm run e2e # E2E tests
## Operational Notes
- Tests must pass before committing
- Typecheck failures block commits
- Use existing utilities from src/lib over ad-hoc copies
Specialized roles for different tasks:
Hat: Architect (@architect)
Hat: Implementer (@implementer)
Hat: Tester (@tester)
Hat: Reviewer (@reviewer)
Usage:
"Spawn a sub-agent with @architect hat to design the data model"
Your job as main agent: engineer setup, observe, course-correct.
Each sub-agent iteration:
Loop ends when:
Define success upfront - avoid "seems done" ambiguity.
[test_command] returns 0For quality criteria that resist automation:
## Completion Check - UX Quality
Criteria: Navigation is intuitive, primary actions are discoverable
Test: User can complete core flow without confusion
## Completion Check - Design Quality
Criteria: Visual hierarchy is clear, brand consistency maintained
Test: Layout follows established patterns
Run LLM-as-judge sub-agent for binary pass/fail.
specs/
āāā authentication.md
āāā database.md
āāā api-routes.md
src/
āāā app/ # App Router
āāā components/ # React components
āāā lib/ # Utilities (db, auth, helpers)
āāā types/ # TypeScript types
AGENTS.md:
Build: npm run dev
Test: npm run test
Typecheck: npx tsc --noEmit
Lint: npm run lint
specs/
āāā data-pipeline.md
āāā model-training.md
āāā api-endpoints.md
src/
āāā pipeline.py
āāā models/
āāā api/
āāā tests/
AGENTS.md:
Build: python -m src.main
Test: pytest
Typecheck: mypy src/
Lint: ruff check src/
specs/
āāā model-architecture.md
āāā training-data.md
āāā inference-pipeline.md
src/
āāā models/
āāā training/
āāā inference/
āāā utils/
AGENTS.md:
Train: python train.py
Test: pytest tests/
Lint: ruff check src/
GPU Check: nvidia-smi
Start a Ralph Mode session:
"Start Ralph Mode for my project at ~/projects/my-app. I want to implement user authentication with JWT.
I will:
When Ralph patterns emerge, update AGENTS.md:
## Discovered Patterns
- When adding API routes, also add to OpenAPI spec
- Use existing db utilities from src/lib/db over direct calls
- Test files must be co-located with implementation
When trajectory goes wrong:
For subjective criteria (tone, aesthetics, UX):
Create src/lib/llm-review.ts:
interface ReviewResult {
pass: boolean;
feedback?: string;
}
async function createReview(config: {
criteria: string;
artifact: string; // text or screenshot path
}): Promise<ReviewResult>;
Sub-agents discover and use this pattern for binary pass/fail checks.
Based on empirical usage, enforce these practices to avoid silent failures:
Ralph MUST write to PROGRESS.md after EVERY iteration. This is non-negotiable.
Create PROGRESS.md in project root at start:
# Ralph: [Task Name]
## Iteration [N] - [Timestamp]
### Status
- [ ] In Progress | [ ] Blocked | [ ] Complete
### What Was Done
- [Item 1]
- [Item 2]
### Blockers
- None | [Description]
### Next Step
[Specific next task from IMPLEMENTATION_PLAN.md]
### Files Changed
- `path/to/file.ts` - [brief description]
Why: External observers (parent agents, crons, humans) can tail one file instead of scanning directories or inferring state from session logs.
Before spawning a new Ralph session:
sessions_listAnti-pattern: Spawning Ralph v2 while v1 is still running = file conflicts, race conditions, lost work.
Never assume directory structure. At start of each iteration:
// Verify current working directory
const cwd = process.cwd();
console.log(`Working in: ${cwd}`);
// Verify expected paths exist
if (!fs.existsSync('./src/app')) {
console.error('Expected ./src/app, found:', fs.readdirSync('.'));
// Adapt or fail explicitly
}
Why: Ralph may be spawned from different contexts with different working directories.
When done, Ralph MUST:
PROGRESS.md with "## Status: COMPLETE"Example completion PROGRESS.md:
# Ralph: Influencer Detail Page
## Status: COMPLETE ā
**Finished:** [ISO timestamp]
### Final Verification
- [x] TypeScript: Pass
- [x] Tests: Pass
- [x] Build: Pass
### Files Created
- `src/app/feature/page.tsx`
- `src/app/api/feature/route.ts`
### Testing Instructions
1. Run: `npm run dev`
2. Visit: `http://localhost:3000/feature`
3. Verify: [specific checks]
If Ralph encounters unrecoverable errors:
Do not silently fail. A Ralph that stops iterating with no progress log is indistinguishable from one still working.
Set explicit iteration timeouts:
## Operational Parameters
- Max iteration time: 10 minutes
- Total session timeout: 60 minutes
- If iteration exceeds limit: Log blocker, exit
Why: Prevents infinite loops on stuck tasks, allows parent agent to intervene.
After each Ralph Mode session, document:
## [Date] Ralph Mode Session
**Project:** [project-name]
**Duration:** [iterations]
**Outcome:** success / partial / blocked
**Learnings:**
- What worked well
- What needs adjustment
- Patterns to add to AGENTS.md
Common anti-patterns observed:
| Anti-Pattern | Consequence | Prevention |
|--------------|-------------|------------|
| No progress logging | Parent agent cannot determine status | Mandatory PROGRESS.md |
| Silent failure | Work lost, time wasted | Explicit error logging |
| Overlapping sessions | File conflicts, corrupt state | Check/cleanup before spawn |
| Path assumptions | Wrong directory, wrong files | Explicit verification |
| No completion signal | Parent waits indefinitely | Clear COMPLETE status |
| Infinite iteration | Resource waste, no progress | Time limits + blockers |
| Complex initial prompts | Sub-agent never starts (empty session logs) | SIMPLIFY instructions |
Evidence: Empty session logs (2 bytes), no tool calls, 0 tokens used
## Task: [ONE specific thing]
**File:** exact/path/to/file.ts
**What:** Exact description of change
**Validate:** Exact command to run
**Then:** Update PROGRESS.md and exit
## Rules
1. Do NOT look at other files
2. Do NOT "check first"
3. Make the change, validate, exit
Fix all TypeScript errors across these files:
- lib/db.ts has 2 errors
- lib/proposal-service.ts has 5 errors
- route.ts has errors
Check which ones to fix first, then...
Fix lib/db.ts line 27:
Change: PoolClient to pg.PoolClient
Validate: npm run typecheck
Exit immediately after
Each Ralph iteration gets ONE file. Not "all errors", not "check then decide". ONE file, ONE change, validate, exit.
MANDATORY: After EVERY iteration, update PROGRESS.md with:
## Iteration [N] - [Timestamp]
### Status: Complete ā
| Blocked ā | Failed ā
### What Was Done
- [Specific changes made]
### Validation
- [Test/lint/typecheck results]
### Next Step
- [What should happen next]
Why this matters: Cron job reads PROGRESS.md for status updates. If not updated, status appears stale/repetitive.
If Ralph stalls:
If cron reports same status repeatedly:
Ralph works when: Single file focus + explicit change + validate + exit
Ralph stalls when: Complex decisions + multiple files + conditional logic
Generated Mar 1, 2026
Developing a Next.js application with backend APIs in FastAPI, requiring iterative feature implementation, automated testing, and type checking. Ralph Mode manages phased development from specs to deployment, ensuring each iteration passes validation gates before proceeding.
Building and refining GPU-accelerated machine learning models in Python, where each iteration involves data preprocessing, model training, and validation. Ralph Mode structures tasks with backpressure gates like unit tests and performance benchmarks to ensure reliability and efficiency.
Refactoring a legacy FastAPI service into modular microservices with strict type safety and linting standards. Ralph Mode coordinates iterative updates, using sub-agents for specific roles like architect and tester to maintain code quality and meet acceptance criteria.
Adding new interactive features to an educational platform using Next.js, with requirements for user authentication and session management. Ralph Mode handles phased implementation, tracking progress through an implementation plan and validating each step with automated tests and UX reviews.
Creating and maintaining Python scripts for CI/CD pipelines and infrastructure automation, requiring iterative debugging and validation. Ralph Mode ensures each script iteration passes build and test gates, with structured planning to manage complex dependencies and deployment criteria.
Offering Ralph Mode as a managed service for development teams, providing automated iteration management and quality gates. Revenue is generated through monthly or annual subscriptions, with tiers based on project complexity and support levels.
Providing expert consulting to integrate Ralph Mode into existing development workflows, including custom setup, training, and ongoing support. Revenue comes from project-based fees or retainer agreements for continuous optimization and maintenance.
Releasing Ralph Mode as open-source software to build community adoption, while monetizing through premium features like advanced analytics, enterprise support, and specialized integrations. Revenue is generated from licensing fees for premium add-ons and support contracts.
š¬ Integration Tip
Start by defining clear specs and acceptance criteria in the specs/ directory, then use the AGENTS.md file to set up validation commands for seamless integration into existing CI/CD pipelines.
Captures learnings, errors, and corrections to enable continuous improvement. Use when: (1) A command or operation fails unexpectedly, (2) User corrects Clau...
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
Search and analyze your own session logs (older/parent conversations) using jq.
Typed knowledge graph for structured agent memory and composable skills. Use when creating/querying entities (Person, Project, Task, Event, Document), linking related objects, enforcing constraints, planning multi-step actions as graph transformations, or when skills need to share state. Trigger on "remember", "what do I know about", "link X to Y", "show dependencies", entity CRUD, or cross-skill data access.
Ultimate AI agent memory system for Cursor, Claude, ChatGPT & Copilot. WAL protocol + vector search + git-notes + cloud backup. Never lose context again. Vibe-coding ready.
Headless browser automation CLI optimized for AI agents with accessibility tree snapshots and ref-based element selection