Restate workflows

From joelhooks/joelclaw · View interactive version

Restate workflows is an AI agent skill from the GitHub repository joelhooks/joelclaw. Compatibility alias for substrate-specific ADR-0217 runtime bridge work. For new work, load `workflow-rig` first; use this skill only when the task is explicitly about external-repo bridging, queue-family contracts, or low-level runtime submission mechanics.

How to use this skill

Skill file

Restate Workflows

This skill is now a compatibility alias for substrate work.

For new work, load workflow-rig first. Use this skill only when the real problem is the runtime bridge itself: external repo submission, queue-family contracts, or low-level ADR-0217 substrate mechanics.

The boundary is the joelclaw CLI.

Do not reach into Redis directly. Do not import private joelclaw packages. Do not pretend the other repo knows internal queue schemas unless you have explicitly verified them.

The runtime shape

ADR-0217 currently reads best as:

An external repo should integrate at the edge, not by coupling itself to the middle.

That means:

When to use

Use this skill when a user asks for any of these:

Non-negotiable rules

First steps

Run these before designing the bridge:

joelclaw workload run --help
joelclaw queue --help
joelclaw queue emit --help

If the target repo is supposed to monitor results too, also inspect:

joelclaw jobs status --hours 1 --count 10
joelclaw queue observe --hours 1

If you are unsure whether a workflow family already exists, search docs or ask instead of inventing one.

What to build in the external repo

The default deliverable is a thin wrapper command/module/script around joelclaw workload run when the repo can produce a saved workload artifact. Fall back to joelclaw queue emit only when you have a verified low-level family and there is no workload artifact to bridge.

Good shapes:

Bad shape:

Minimum request payload

Every request payload should include these fields unless the target family has a stricter contract:

{
  "idempotencyKey": "repo-name:task-type:base-sha:input-hash",
  "requestId": "uuid-or-stable-derived-id",
  "repo": {
    "path": "/abs/path/or/null",
    "url": "git@github.com:owner/repo.git",
    "name": "repo-name",
    "baseSha": "abc123",
    "branch": "main"
  },
  "task": {
    "kind": "sandboxed-change",
    "prompt": "what the runtime should do",
    "artifacts": ["patch", "test-report", "summary.json"]
  },
  "caller": {
    "source": "external-repo-name",
    "requestedBy": "human-or-agent",
    "sessionId": "optional-session-id",
    "callback": {
      "kind": "poll",
      "target": "joelclaw jobs status"
    }
  },
  "meta": {
    "dryRun": false,
    "createdAt": "2026-03-08T05:00:00.000Z"
  }
}

Required semantics

Emission pattern

The wrapper should construct JSON, then call the CLI.

Example pattern:

joelclaw queue emit <event-family> --data '<json>'

Example Node/Bun sketch:

import { spawn } from "node:child_process";

export async function requestWorkflow(
  event: string,
  payload: unknown,
  dryRun = false,
) {
  const data = JSON.stringify(payload);

  if (dryRun) {
    return {
      ok: true,
      mode: "dry-run",
      event,
      payload,
    };
  }

  return await new Promise((resolve, reject) => {
    const child = spawn("joelclaw", ["queue", "emit", event, "--data", data], {
      stdio: ["ignore", "pipe", "pipe"],
    });

    let stdout = "";
    let stderr = "";

    child.stdout.on("data", (chunk) => {
      stdout += chunk.toString();
    });

    child.stderr.on("data", (chunk) => {
      stderr += chunk.toString();
    });

    child.on("close", (code) => {
      if (code === 0) {
        resolve({ ok: true, mode: "live", event, payload, stdout });
        return;
      }
      reject(
        new Error(`joelclaw queue emit failed (${code}): ${stderr || stdout}`),
      );
    });
  });
}

Family selection

Do not hijack an unrelated proof family just because it exists.

Rules:

A good stop-and-document line is:

No canonical workflow-request family was verified in the target runtime. This repo now emits a validated payload object locally and documents the proposed sandbox/work.requested contract, but does not enqueue live requests until the runtime family is confirmed.

That is honest. Honesty beats fake integration.

Required wrapper features

1. Dry-run mode

The command must be able to print the exact event + payload without sending it.

Dry-run output should be parseable JSON, for example:

{
  "ok": true,
  "mode": "dry-run",
  "event": "sandbox/work.requested",
  "payload": { "...": "..." }
}

2. Clear errors

Handle these explicitly:

3. Machine-readable success output

Return stable JSON on success, not prose.

At minimum:

{
  "ok": true,
  "mode": "live",
  "event": "sandbox/work.requested",
  "idempotencyKey": "...",
  "stdout": "raw joelclaw output"
}

4. Local tests

Tests should verify:

Mock the CLI process if needed. Do not require the real runtime for unit tests.

README contract

Document these four things in the calling repo:

  1. what command submits work
  2. what event family it emits
  3. what payload fields are required
  4. how to verify the request from joelclaw surfaces

Minimum verification section:

joelclaw jobs status --hours 1 --count 10
joelclaw queue observe --hours 1

If there is a known workflow ID or downstream surface, include it.

Anti-patterns

Do not do this:

Recommended deliverables

When asked to implement this integration in another repo, deliver:

  1. the wrapper command/module
  2. payload contract documentation
  3. example invocation
  4. verification steps
  5. tests

Short prompt for another agent

Paste this:

Use /skill:restate-workflows. Add a thin wrapper in this repo around joelclaw queue emit so it can submit work into joelclaw without talking to Redis or private joelclaw internals. Check joelclaw queue emit --help first. Emit machine-readable JSON with requestId, idempotencyKey, repo url/branch/baseSha, task prompt, expected artifacts, and caller metadata. Support --dry-run, add a README example and tests, and if the canonical event family is not verified, stop and document the proposed family instead of guessing.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.