melkin — ~/lab/relevo.mdx

~/lab/relevo

relevo

One Claude Code session plans and hands each step to named workers

· claude-code · typescript · repo

relevo in Herdr: the planner writes two handoffs, relevo opens researcher and builder in their own panes and sends both steps in one round, and the planner reads both reports in one turn.
claude plugin marketplace add melandres8/claude-mods && claude plugin install relevo@claude-mods
relevo/hooks/relay.ts
export function extractHandoffs(text: string): { to: string | null; body: string }[] {
  const blank = (code: string) => ' '.repeat(code.length)
  const masked = text.replace(/```[\s\S]*?```/g, blank).replace(/`[^`\n]*`/g, blank)
  const found: { to: string | null; body: string }[] = []
  let from = 0
  for (let close = masked.indexOf('</handoff>', from); close !== -1; close = masked.indexOf('</handoff>', from)) {
    const window = masked.slice(from, close)
    const open = /<handoff(?:\s+to="([^"]*)")?\s*>(?![\s\S]*<handoff[\s>])/.exec(window)
    if (open !== null) {
      const body = text.slice(from + open.index + open[0].length, close).trim()
      if (body !== '') found.push({ to: open[1] ?? null, body })
    }
    from = close + '</handoff>'.length
  }

  return found
}

Why I built it

I often run several Claude Code sessions side by side. One plans, and the others build, research, or review. I was the messenger between them. I copied each step into a worker, then copied each report back into the planner.

relevo removes that step. The planner writes each step inside a <handoff> block. When its turn ends, relevo sends each block to its worker.

How the loop works

Each session gets a short role prompt. The planner splits the goal into small, verifiable steps and does not edit code.

The planner names the worker in the tag, as in <handoff to="researcher">. A <handoff> without to goes to builder. A worker name has lowercase letters, digits, -, or _, and up to 32 characters, and it starts with a letter. planner and the /relevo verbs (goal, pause, resume, status, off, join) are reserved.

The snippet is the function that reads these blocks. It blanks out code first, so a <handoff> quoted in code is never a step.

Several blocks in one reply go out together, one per worker. They form one parallel round, and that round costs one of the maxRounds. relevo holds each report while another worker is still busy. When the last worker answers, the planner gets all the reports in one turn.

Each worker runs exactly the step that it receives. It closes with a <handoff> report that says what it did, which files it touched, the test results, and its doubts.

relevo adds a header to each delivery, which the model reads as [relevo ronda 3 · de researcher]. Only the planner raises the round. Each worker answers with the round that it received.

A band over the prompt shows the state in one line. It has the role, the peer, the rounds as ▰▰▰▱▱▱▱▱▱▱ 3/10, and whose turn it is.

In Herdr, the planner opens each missing worker itself. In the Herdr app it runs hc run. In the Herdr TUI it runs herdr pane split and herdr agent start. relevo picks the uuid of the new session, and the planner accepts the worker on its own only when the request comes from that uuid.

Outside Herdr, link each worker by hand. In the worker, type /relevo join <name> <id-of-the-planner>. In the planner, accept it with /relevo planner <id-of-the-worker> or the Aceptar button.

In Herdr, a planner opens up to maxWorkers workers, 3 by default, in /config. A <handoff> that would open one more stays held, and relevo pauses.

The session that asks for a link creates a random nonce. The acceptance returns it, and every round header carries it. A round counts only when it has the nonce of that worker’s link.

relevo counts only the messages that the relevo of the other session wrote. It drops a look-alike text, such as one that a model sends with SendMessage, and shows a toast. The model never sees that text, and it never sees the nonce either.

How it stops

  • The planner writes <done>…</done> when the goal is met.
  • The rounds reach maxRounds, 10 by default, in any session. relevo pauses and holds the pending <handoff>. /relevo resume sends it and grants another maxRounds rounds.
  • A worker never links. After 90 s, relevo pauses and tells you where to look, such as hc read <name> or herdr agent read <name>. /relevo resume stops the wait and passes on the reports that already arrived.
  • Nobody accepted the link yet. relevo holds the <handoff>, sends nothing, and pauses until /relevo resume.
  • A send fails or the peer rejects it. relevo shows the reason in a toast and pauses.

relevo also guards against echo loops. It sends only from the end of a model turn, never when a message arrives. It does not resend a <handoff> equal to the last one it received or sent.

What the model checks

TLC checks the model in relevo/docs/model/RelevoHub.tla with 2 workers and 2 rounds. In every reachable state, the planner never decides while a worker is out, holds reports only while it waits, and never passes maxRounds. A fourth check, NeverFinishesInParallel, is meant to fail: its counterexample is the path where the planner finishes after reading two reports together.

Set it up

Pick one way to load the plugin. If you combine the marketplace install with --plugin-dir, the hooks load twice and each handoff goes out twice.

claude plugin marketplace add melandres8/claude-mods
claude plugin install relevo@claude-mods

Every session in the loop needs relevo 0.3.1, the planner and each worker. The code is in melandres8/claude-mods, under the MIT license.

In Herdr, open one session and start the planner. It opens its workers when it sends them their first step.

/relevo planner
/relevo goal Add pagination to the /users endpoint with tests

In another terminal, link each worker by hand before you set the goal.

/relevo join builder <id-of-A>   # in session B: asks to be the worker named builder
/relevo planner <id-of-B>        # in session A: accepts it
/relevo goal Add pagination to the /users endpoint with tests

hire.me

Building something like this? I do it for clients. I reply within 48 h.