Agent skill
ralph-handoff
Handoff protocol for single-agent orchestration mode
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/shared-ralph-handoff
SKILL.md
Ralph Handoff Protocol
This skill defines how agents communicate handoff requests in single-agent orchestration mode. Only ONE agent is active at a time - the watchdog process monitors agent output and orchestrates handoffs.
Overview
Instead of 3 agents polling simultaneously (consuming tokens continuously), this model:
- Runs ONE agent at a time
- Agent outputs handoff phrase when work is complete or another agent is needed
- Watchdog detects handoff, gracefully stops current agent, starts next agent
- Context is passed to next agent via state files + handoff message
Handoff Phrase Format
When you need another agent to take over, output this exact format:
HANDOFF:agent_name:base64_context
Where:
agent_nameis one of:pm,developer,qabase64_contextis a Base64-encoded JSON object with handoff details
Example
HANDOFF:developer:eyJmcm9tIjoicG0iLCJyZWFzb24iOiJ0YXNrX2Fzc2lnbm1lbnQiLCJ0YXNrIjp7ImlkIjoiZmVhdC0wMDEiLCJ0aXRsZSI6IkFkZCB1c2VyIGF1dGgiLCJwcmlvcml0eSI6ImhpZ2gifX0=
Context JSON Structure
The context object should include:
{
"from": "pm", // Your agent name
"reason": "task_assignment", // Why handoff is needed
"timestamp": "2026-01-20T...", // When you're handing off
"task": {
// Task-specific details
"id": "feat-001",
"title": "Add user authentication",
"action": "implement", // What the next agent should do
"notes": "Focus on JWT tokens" // Any additional context
}
}
Handoff Reasons
| Reason | From | To | Description |
|---|---|---|---|
task_assignment |
PM | Developer | New task assigned for implementation |
ready_for_qa |
Developer | QA | Implementation complete, needs validation |
validation_passed |
QA | PM | Tests passed, task complete |
validation_failed |
QA | Developer | Bugs found, needs fixes |
need_clarification |
Developer | PM | Questions about specs |
all_complete |
PM | - | All PRD items done (use RALPH_COMPLETE instead) |
Before Handoff: Save State
CRITICAL: Before outputting a handoff phrase, you MUST:
-
Save all state to files:
- Update
prd.json.sessionwith current status - Update
prd.json.items[{taskId}]with task progress - Update
prd.json.agents.{agent}with your agent status - Commit any code changes (Developer only)
- Update
-
Signal readiness:
AGENT_READY_FOR_HANDOFF -
Output handoff phrase:
HANDOFF:next_agent:context
The watchdog waits up to 30 seconds for AGENT_READY_FOR_HANDOFF before forcefully stopping you.
Helper: Encoding Context
PowerShell:
$context = @{ from = "pm"; reason = "task_assignment"; task = @{ id = "feat-001" } }
$json = $context | ConvertTo-Json -Compress
$bytes = [System.Text.Encoding]::UTF8.GetBytes($json)
$base64 = [System.Convert]::ToBase64String($bytes)
Write-Host "HANDOFF:developer:$base64"
Bash:
context='{"from":"pm","reason":"task_assignment","task":{"id":"feat-001"}}'
encoded=$(echo -n "$context" | base64 -w0)
echo "HANDOFF:developer:$encoded"
Receiving Handoff Context
When you start and receive handoff context, you'll see:
## HANDOFF CONTEXT (FROM PREVIOUS AGENT)
You are receiving control from another agent. Here is the context:
From: pm
Reason: task_assignment
Task Details: {"id":"feat-001","title":"Add user auth"}
Please acknowledge this handoff and continue the work accordingly.
Read prd.json.session and prd.json.items for full state.
Your first action should be:
- Acknowledge the handoff: "Received handoff from PM for task feat-001"
- Read
prd.json.session,prd.json.agents, andprd.json.itemsto get full context - Begin the assigned work
Completion Protocol
When ALL PRD items have passes: true, the PM agent outputs:
<promise>RALPH_COMPLETE</promise>
This signals the watchdog to end the session gracefully.
Key Differences from Polling Mode
| Aspect | Polling Mode | Single-Agent Mode |
|---|---|---|
| Active agents | 3 simultaneous | 1 at a time |
| Token usage | Continuous for all 3 | Only active agent |
| Communication | File polling every 30s | Handoff phrases |
| Agent switching | Implicit via state | Explicit handoff |
| Watchdog role | Monitor all processes | Orchestrate handoffs |
Error Handling
If you encounter an error that prevents work:
- Save any partial state
- Output error context in handoff:
json
{ "from": "developer", "reason": "error", "task": { "id": "feat-001" }, "error": "Build failed: missing dependency X" } - Handoff to PM for resolution:
HANDOFF:pm:base64_error_context
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?