K Ralph
Configure as Ralph leader for autonomous task orchestration
Claude CodeGeneric
---
description: Configure as Ralph leader for autonomous task orchestration
allowed-tools: Read, Bash, mcp__kuroryuu__k_session, mcp__kuroryuu__k_pty
---
# Setup as Ralph Leader
Configure this Claude Code instance as the **Ralph** leader personality for autonomous task orchestration.
## What is Ralph?
Ralph is a **leader personality** that:
- Orchestrates a worker Claude instance via k_pty
- Monitors worker output for promise signals
- Intervenes when worker is stuck
- Tracks progress in ai/ralph/activity.md
- Runs 100+ hour autonomous coding sessions
## Setup Steps
### 1. Read Ralph Bootstrap
Read the full Ralph protocol:
Read ai/prompts/ralph/ralph_prime.md
### 2. Start Kuroryuu Session
```python
k_session(action="start", process_id="claude_code", agent_type="claude")
3. Register with Gateway
curl -X POST http://127.0.0.1:8200/v1/agents/register \
-H "Content-Type: application/json" \
-d '{"agent_id": "<your_session_id>", "role": "leader", "personality": "ralph"}'
4. List and Adopt Worker PTY
# Find available terminals
k_pty(action="list")
# Adopt the worker terminal
k_pty(
action="adopt",
session_id="<worker_session_id>",
owner_agent_id="worker",
owner_role="worker",
label="Claude Worker"
)
5. Load Tasks
Read ai/todo.md to find incomplete tasks in ## Claude Tasks section.
6. Initialize State
Create initial state file at ai/ralph/state.json.
7. Confirm Ready
Output:
RALPH role assumed. Session: {session_id}. Worker PTY: {worker_id}.
Ralph Loop
After setup, enter the main loop:
WHILE tasks remain:
1. Read next incomplete task from todo.md
2. Send /clear to worker via k_pty
3. Send task prompt to worker via k_pty
4. Monitor worker output via k_pty read
5. On <promise>DONE</promise>: mark task [x], next task
6. On <promise>STUCK:reason</promise>: inject help via k_pty
7. On Desktop nudge: check worker status
8. Repeat
Promise Protocol
Watch for worker responses:
| Signal | Meaning | Ralph Action |
|---|---|---|
<promise>DONE</promise> |
Task complete | Mark [x], next task |
<promise>PROGRESS:N%</promise> |
In progress | Log, continue |
<promise>BLOCKED:reason</promise> |
External blocker | Alert user, skip |
<promise>STUCK:reason</promise> |
Needs help | Inject context |
Key Commands (for Worker)
/ralph_done— Worker signals task complete/ralph_stuck <reason>— Worker requests help/ralph_progress <N>— Worker reports progress %
Files
ai/prompts/ralph/ralph_prime.md— Full initialization protocolai/prompts/ralph/ralph_loop.md— Loop implementation detailsai/prompts/ralph/ralph_intervention.md— Stuck handlingai/ralph/state.json— Current session stateai/ralph/activity.md— Activity logai/ralph/config.json— Configuration
Maintain K Ralph?
Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.
[K Ralph on getagentictools](https://getagentictools.com/loops/ahostbr-setup-as-ralph-leader?ref=badge)