Your First Task¶
Let's walk through creating and running a complete task with Ralph.
Choose Your Mode¶
Ralph offers two modes. Choose based on your task complexity:
| Mode | When to Use |
|---|---|
| Traditional | Simple tasks, quick automation, getting started |
| Hat-Based | Complex workflows, multi-step processes, role separation |
For this guide, we'll use traditional mode first, then show hat-based mode.
Traditional Mode Example¶
1. Initialize¶
mkdir my-first-ralph-task
cd my-first-ralph-task
git init # Ralph works best with git
ralph init --backend claude
2. Create Your Prompt¶
Create PROMPT.md:
# Task: Build a Simple Calculator (Rust)
Create a Rust calculator module with:
## Requirements
- Functions: add, subtract, multiply, divide
- Handle division by zero gracefully
- Include unit tests
## Acceptance Criteria
- All functions work correctly
- Tests pass with `cargo test`
- Code is formatted with `cargo fmt`
3. Run Ralph¶
Ralph will:
- Read your prompt
- Start the AI agent
- Iterate until
LOOP_COMPLETEis output - Show progress in the TUI
4. Review Results¶
When Ralph completes, check your directory:
Hat-Based Mode Example¶
For more complex tasks, use hats to separate concerns.
1. Initialize with a Preset¶
This creates a configuration with specialized hats:
- Tester - Writes failing tests first
- Implementer - Makes tests pass
- Refactorer - Cleans up the code
2. Create Your Prompt¶
# Task: Build a URL Shortener
Create a URL shortening service with:
## Requirements
- Generate short codes for URLs
- Retrieve original URLs from short codes
- Handle invalid inputs gracefully
- Persist mappings to SQLite
## Constraints
- Short codes: 6 alphanumeric characters
- No duplicate short codes
3. Run with Hat Coordination¶
The TUI shows which hat is active:
4. View Event History¶
Shows the event flow between hats:
task.start -> Tester
test.written -> Implementer
test.passed -> Refactorer
refactor.done -> Tester
...
Tips for Good Prompts¶
Be Specific¶
# Bad
Make a web app.
# Good
Create an Axum web app with:
- GET /health endpoint returning {"status": "ok"}
- POST /users accepting JSON {name, email}
- SQLite database for persistence
Include Acceptance Criteria¶
## Acceptance Criteria
- [ ] All endpoints respond correctly
- [ ] Invalid JSON returns 400 error
- [ ] Database persists across restarts
Specify Constraints¶
Monitoring and Control¶
View Progress¶
The TUI shows real-time progress. Key information:
- Iteration count - How many cycles Ralph has run
- Elapsed time - Total runtime
- Active hat - Which persona is working (hat-based mode)
- Agent output - What the AI is doing
Stop Early¶
Press q in the TUI to quit gracefully.
Resume Interrupted Sessions¶
Check Metrics¶
After completion, check .agent/ for:
scratchpad.md- Shared memory (legacy mode)memories.md- Persistent learningtasks.jsonl- Task tracking
Common Issues¶
Task Not Completing¶
If Ralph runs forever:
- Check your prompt has clear completion criteria
- Ensure
LOOP_COMPLETEcan be reasonably output - Set a lower
--max-iterationsfor testing
Wrong Backend¶
Agent Errors¶
Check the agent is installed and authenticated:
Next Steps¶
- Learn about Hats & Events
- Explore Presets for your workflow
- Master Writing Prompts