Examples¶
Practical examples showing Ralph in action.
In This Section¶
| Example | Description |
|---|---|
| Simple Task | Basic traditional mode usage |
| TDD Workflow | Test-driven development with hats |
| Spec-Driven Development | Specification-first approach |
| Multi-Hat Workflow | Complex coordination between hats |
| Debugging | Using Ralph to investigate bugs |
Quick Examples¶
Traditional Mode¶
Simple loop until completion:
ralph init --backend claude
cat > PROMPT.md << 'EOF'
Write a function that calculates factorial.
Include tests.
EOF
ralph run
Hat-Based Mode¶
Using the TDD preset:
ralph init --preset tdd-red-green
cat > PROMPT.md << 'EOF'
Implement a URL validator function.
Must handle:
- HTTP and HTTPS protocols
- IPv4 addresses
- Domain names
- Port numbers
EOF
ralph run
Inline Prompts¶
Skip the prompt file:
Custom Configuration¶
Override defaults:
Example Workflows¶
Feature Development¶
# Initialize with feature preset
ralph init --preset feature
# Create detailed prompt
cat > PROMPT.md << 'EOF'
# Feature: User Dashboard
Add a user dashboard with:
- Profile summary widget
- Recent activity feed
- Quick action buttons
Use React components.
Follow existing UI patterns.
EOF
# Run Ralph
ralph run
Bug Investigation¶
# Initialize with debug preset
ralph init --preset debug
# Describe the bug
ralph run -p "Users report login fails on Safari. Error: 'Invalid token'. Investigate and fix."
Code Review¶
# Initialize with review preset
ralph init --preset review
# Review specific files
ralph run -p "Review the changes in src/api/auth.rs for security issues"
Full Examples¶
Detailed walkthroughs are available:
- Simple Task — Step-by-step traditional mode
- TDD Workflow — Red-green-refactor with hats
- Spec-Driven — Specification to implementation
- Multi-Hat — Complex hat coordination
- Debugging — Bug investigation workflow