page

What Ralph Actually Does

Ralph Code Architecture

Ralph is a bash-based iterative loop system for Claude Code that:

  1. Reads a PROMPT.md file with project requirements
  2. Executes Claude Code with that prompt
  3. Analyzes the response for completion signals:
  4. Completion keywords (done, complete, finished)
  5. Test-only patterns (just running tests, no implementation)
  6. Error patterns (stuck loops)
  7. File changes via git diff
  8. Circuit breaker pattern prevents runaway loops:
  9. Opens after 3 loops with no file changes
  10. Opens after 5 loops with same error
  11. Half-open monitoring state for recovery
  12. Rate limiting (100 calls/hour by default)
  13. Graceful exit detection when objectives are met

Key Files

  • /opt/repos/ralph-claude-code/ralph_loop.sh - Main loop logic
  • /opt/repos/ralph-claude-code/lib/response_analyzer.sh - Completion detection
  • /opt/repos/ralph-claude-code/lib/circuit_breaker.sh - Stagnation prevention

Why It Works for Code

Ralph succeeds because code tasks have clear completion criteria: - Tests pass - Files change - Explicit 'done' signals

The loop lets Claude fail, learn from errors, and iterate until success.

ID: 14685b09
Path: Accelerated AI Training > Ralph Code Analysis > What Ralph Actually Does
Updated: 2026-01-01T19:26:44