Back to Skills

ralph-loop-guide

verified

Ralph Loop Best Practices - Guidelines for effective autonomous iteration. Based on Anthropic's official ralph-loop plugin. Helps design prompts for iterative AI development with clear completion signals.

View on GitHub

Marketplace

specweave

anton-abyzov/specweave

Plugin

sw

development

Repository

anton-abyzov/specweave
27stars

plugins/specweave/skills/ralph-loop-guide/SKILL.md

Last Verified

January 25, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/anton-abyzov/specweave/blob/main/plugins/specweave/skills/ralph-loop-guide/SKILL.md -a claude-code --skill ralph-loop-guide

Installation paths:

Claude
.claude/skills/ralph-loop-guide/
Powered by add-skill CLI

Instructions

# Ralph Loop Best Practices Guide

This skill provides guidelines for effective autonomous iteration using the Ralph Wiggum pattern, based on Anthropic's official ralph-loop plugin.

## How Ralph Loop Works

The Ralph Loop is a methodology for iterative AI development through self-referential feedback loops:

1. **The prompt never changes between iterations**
2. **Claude's previous work persists in files**
3. **Each cycle, the AI sees modified files and git history**
4. **Enables autonomous refinement without manual re-prompting**

## Effective Ralph Prompt Design

### Required Elements

1. **Clear Completion Signal**
   ```markdown
   ## Completion Criteria
   - [ ] All unit tests pass (npm test)
   - [ ] Build succeeds (npm run build)
   - [ ] Coverage ≥80% (npm run coverage)
   - [ ] No TypeScript errors (npx tsc --noEmit)

   When ALL criteria are met, output: "RALPH_COMPLETE: All tasks done"
   ```

2. **Incremental Phases**
   ```markdown
   ## Implementation Phases

   ### Phase 1: Foundation
   - Create database schema
   - Set up repository layer
   - Write unit tests for repository

   ### Phase 2: Business Logic
   - Implement service layer
   - Add validation
   - Write service tests

   ### Phase 3: API Layer
   - Create endpoints
   - Add input validation
   - Write API tests
   - Run full test suite
   ```

3. **Self-Correction Cycles**
   ```markdown
   ## On Each Iteration

   1. Run tests: `npm test`
   2. If tests fail:
      - Read error messages
      - Fix the failing code
      - Run tests again
   3. If tests pass:
      - Check coverage: `npm run coverage`
      - If coverage < 80%, add more tests
      - If coverage ≥ 80%, proceed to next phase
   ```

4. **Safety Limits**
   ```markdown
   ## Safety Rules

   - Maximum 100 iterations per phase
   - If stuck for 5 iterations on same error, ask for help
   - Never delete test files
   - Always commit working state before major changes
   ```

## Good Ralph Prompts

### Example 1: API Develop

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
6349 chars