- Add .gitkeep files to ensure all essential directories are tracked by git - Update .gitignore to allow .gitkeep files in logs/ and docs/generated/ - Preserve directory structure for Ralph project template system - Directories added: src/, examples/, specs/stdlib/, templates/specs/, logs/, docs/generated/ This ensures the complete Ralph project structure is available when cloning the repository, even before any actual project files are created. |
||
|---|---|---|
| docs/generated | ||
| examples | ||
| logs | ||
| specs/stdlib | ||
| src | ||
| templates | ||
| .gitignore | ||
| CLAUDE.md | ||
| create_files.sh | ||
| LICENSE | ||
| ralph_loop.sh | ||
| ralph_monitor.sh | ||
| README.md | ||
| setup.sh | ||
Ralph for Claude Code
Autonomous AI development loop with intelligent exit detection and rate limiting
Ralph is an implementation of the Ralph technique specifically designed for Claude Code. It enables continuous autonomous development cycles where Claude Code iteratively improves your project until completion, with built-in safeguards to prevent infinite loops and API overuse.
🌟 Features
- 🔄 Autonomous Development Loop - Continuously executes Claude Code with your project requirements
- 🛡️ Intelligent Exit Detection - Automatically stops when project objectives are complete
- ⚡ Rate Limiting - Built-in API call management with hourly limits and countdown timers
- 📊 Live Monitoring - Real-time dashboard showing loop status, progress, and logs
- 🎯 Task Management - Structured approach with prioritized task lists and progress tracking
- 🔧 Project Templates - Quick setup for new projects with best-practice structure
- 📝 Comprehensive Logging - Detailed execution logs with timestamps and status tracking
🚀 Quick Start
1. Clone and Setup
git clone https://github.com/frankbria/ralph-claude-code.git
cd ralph-claude-code
./create_files.sh
2. Create Your First Project
./setup.sh my-awesome-project
cd my-awesome-project
3. Configure Your Project
Edit the generated files:
PROMPT.md- Define your project requirements and objectivesspecs/- Add detailed specifications and requirements@fix_plan.md- Set initial priorities and tasks
4. Start the Ralph Loop
# Start autonomous development
../ralph_loop.sh
# Monitor progress (in another terminal)
../ralph_monitor.sh
📖 How It Works
Ralph operates on a simple but powerful cycle:
- 📋 Read Instructions - Loads
PROMPT.mdwith your project requirements - 🤖 Execute Claude Code - Runs Claude Code with current context and priorities
- 📊 Track Progress - Updates task lists and logs execution results
- 🔍 Evaluate Completion - Checks for exit conditions and project completion signals
- 🔄 Repeat - Continues until project is complete or limits are reached
Intelligent Exit Detection
Ralph automatically stops when it detects:
- ✅ All tasks in
@fix_plan.mdmarked complete - 🎯 Multiple consecutive "done" signals from Claude Code
- 🧪 Too many test-focused loops (indicating feature completeness)
- 📋 Strong completion indicators in responses
🛠️ Configuration
Rate Limiting
# Default: 100 calls per hour
../ralph_loop.sh --calls 50
# Check current usage
../ralph_loop.sh --status
Custom Prompts
# Use custom prompt file
../ralph_loop.sh --prompt my_custom_instructions.md
Exit Thresholds
Modify these variables in ralph_loop.sh:
MAX_CONSECUTIVE_TEST_LOOPS=3 # Exit after 3 test-only loops
MAX_CONSECUTIVE_DONE_SIGNALS=2 # Exit after 2 "done" signals
TEST_PERCENTAGE_THRESHOLD=30 # Flag if 30%+ loops are test-only
📁 Project Structure
Ralph creates a standardized structure for each project:
my-project/
├── PROMPT.md # Main development instructions for Ralph
├── @fix_plan.md # Prioritized task list (@ prefix = Ralph control file)
├── @AGENT.md # Build and run instructions
├── specs/ # Project specifications and requirements
│ └── stdlib/ # Standard library specifications
├── src/ # Source code implementation
├── examples/ # Usage examples and test cases
├── logs/ # Ralph execution logs
└── docs/generated/ # Auto-generated documentation
🎯 Best Practices
Writing Effective Prompts
- Be Specific - Clear requirements lead to better results
- Prioritize - Use
@fix_plan.mdto guide Ralph's focus - Set Boundaries - Define what's in/out of scope
- Include Examples - Show expected inputs/outputs
Project Specifications
- Place detailed requirements in
specs/ - Use
@fix_plan.mdfor prioritized task tracking - Keep
@AGENT.mdupdated with build instructions - Document key decisions and architecture
Monitoring Progress
- Use
../ralph_monitor.shfor live status updates - Check logs in
logs/for detailed execution history - Monitor
status.jsonfor programmatic access - Watch for exit condition signals
🔧 System Requirements
- Bash 4.0+ - For script execution
- Claude Code CLI -
npx @anthropic/claude-code - jq - JSON processing for status tracking
- Git - Version control (projects are initialized as git repos)
- Standard Unix tools - grep, date, etc.
📊 Monitoring and Debugging
Live Dashboard
../ralph_monitor.sh
Shows real-time:
- Current loop count and status
- API calls used vs. limit
- Recent log entries
- Rate limit countdown
Status Checking
# JSON status output
../ralph_loop.sh --status
# Manual log inspection
tail -f logs/ralph.log
Common Issues
- Rate Limits - Ralph automatically waits and displays countdown
- Stuck Loops - Check
@fix_plan.mdfor unclear or conflicting tasks - Early Exit - Review exit thresholds if Ralph stops too soon
- Missing Dependencies - Ensure Claude Code CLI is installed
🤝 Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Test with
./create_files.shand sample projects - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Inspired by the Ralph technique from the Aider project
- Built for Claude Code by Anthropic
- Community feedback and contributions
🔗 Related Projects
- Claude Code - The AI coding assistant that powers Ralph
- Aider - Original Ralph technique implementation
Ready to let AI build your project? Start with ./create_files.sh and let Ralph take it from there! 🚀