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 |
| Automated PDD Design | Example-only design workflow with simulated requirements interview |
| Spec-Driven Development | Example-only workflow pattern, not a shipped builtin |
| 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 a built-in hat collection:
ralph init --backend claude
cat > PROMPT.md << 'EOF'
Implement a URL validator function.
Must handle:
- HTTP and HTTPS protocols
- IPv4 addresses
- Domain names
- Port numbers
EOF
ralph run -c ralph.yml -H builtin:code-assist
Inline Prompts¶
Skip the prompt file:
Custom Configuration¶
Override defaults:
Example Workflows¶
Feature Development¶
# Initialize core config
ralph init --backend claude
# 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 with the default implementation hats
ralph run -c ralph.yml -H builtin:code-assist
Bug Investigation¶
# Use debug hat collection
ralph run -c ralph.yml -H builtin:debug -p "Users report login fails on Safari. Error: 'Invalid token'. Investigate and fix."
Code Review¶
# Use review hat collection
ralph run -c ralph.yml -H builtin:review -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
- Automated PDD Design — Simulated interview that ends with a reviewed design package
- Spec-Driven — Example specification-first pattern
- Multi-Hat — Complex hat coordination
- Debugging — Bug investigation workflow