mcpField
B
building-restate-services

building-restate-services

github.com/restatedevDevelopment16373 installsUpdated 2w ago
Repository

About building-restate-services

building-restate-services guides coding agents through designing and implementing Restate services in TypeScript, Python, Java, or Go projects. It combines project detection, task-specific references, and required verification checks for durable execution, invocation management, and agent workflows.

Key features

  1. 01Detects SDK and project context
  2. 02Loads architecture references as needed
  3. 03Guidance for operating the Restate CLI
  4. 04Checks determinism and side-effect handling
  5. 05Requires replay tests for handler changes

Use cases

  1. 01Designing Restate services in an existing project
  2. 02Migrating an application or orchestrator to Restate
  3. 03Building and verifying durable agent workflows

MCP support

The skill points to the bundled restate-docs MCP server for documentation on testing, deployment, server configuration, Kafka, and other topics.

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/restatedev/skills --skill building-restate-services

After installing, type/building-restate-servicesin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
ai-agents.md
debug-applications.md
design-and-architecture.md
flow-control-and-scopes.md
invocation-lifecycle.md
translate-to-restate.md
references/go/
api-and-pitfalls.md
references/java/
api-and-pitfalls.md
references/python/
api-and-pitfalls.md
restate-google-adk-agents.md
restate-langchain-agents.md
restate-openai-agents-agents.md
restate-pydantic-ai-agents.md
references/ts/
api-and-pitfalls.md
restate-vercel-ai-agents.md

Details

From the project README

Restate

Restate is a durable execution runtime. It records every step of a handler in a journal, so if the process crashes, the handler replays from the journal and resumes exactly where it left off. Services are regular applications using the Restate SDK (TypeScript, Python, Java, Go) that run behind a Restate Server (a single Rust binary on ports 8080 for ingress and 9070 for admin UI).

Detect context

Scan the project to determine the SDK and context:

  1. Detect SDK:

    • package.json with @restatedev/restate-sdk -> TypeScript
    • requirements.txt or pyproject.toml with restate-sdk -> Python
    • pom.xml or build.gradle with dev.restate -> Java
    • go.mod with github.com/restatedev/sdk-go -> Go
    • If no SDK detected, check for project files to determine language, then ask the user
  2. Detect existing Restate code: Grep for @restatedev, restate-sdk, dev.restate.sdk, github.com/restatedev

  3. Detect AI frameworks: @ai-sdk/, openai-agents, google-adk, pydantic-ai, langchain, langgraph

  4. Detect workflow orchestrators: temporalio, @temporalio, aws-cdk/aws-stepfunctions, etc.

Core reference (always load)

After detecting the SDK, always load the SDK reference:

  • references/<sdk>/api-and-pitfalls.md - Setup, API patterns, determinism rules, error handling, and pitfalls for the detected SDK

Context-based references (load when relevant)

ContextReference
Design a new application, choose service typesreferences/design-and-architecture.md
Add concurrency limits, multi-tenant fairness, cost controls, scopes, or limit keysreferences/flow-control-and-scopes.md
Convert from a workflow orchestrator or existing appreferences/translate-to-restate.md
Invoking services, interacting with invocations (cancel, attach, idempotency, sends, Kafka)references/invocation-lifecycle.md
Design an AI agent, choose a durability boundary, or use an unsupported LLM / agent SDKreferences/ai-agents.md
Build AI agent with Vercel AI SDKreferences/ts/restate-vercel-ai-agents.md
Build AI agent with OpenAI Agents SDKreferences/python/restate-openai-agents-agents.md
Build AI agent with Google ADKreferences/python/restate-google-adk-agents.md
Build AI agent with Pydantic AIreferences/python/restate-pydantic-ai-agents.md
Build AI agent with LangChain or LangGraphreferences/python/restate-langchain-agents.md
Debug errors, stuck invocations, journal mismatchesreferences/debug-applications.md
Register deployments, inspect or manage invocations, read or edit state, query the serverRestate CLI
Testing, deployment, server config, Kafka, advanced topicsUse the bundled restate-docs MCP server
Code examples and templatesrestate example --list --json, github.com/restatedev/examples, github.com/restatedev/ai-examples
Complete TypeScript agent reference architecturerestatedev/agent

Restate CLI

Use the restate CLI to operate a running Restate Server: register deployments, inspect and manage invocations, read and edit state, and query the server's internals with SQL. The CLI describes itself, so ask it what to run instead of guessing commands or flags:

  • restate --help explains how agents should use the CLI. restate <command> --help shows the flags of a command, with examples.
  • restate search <what you want to do> finds the command, flag or SQL table for a task, e.g. restate search retry a failed invocation.
  • restate sql --help lists the SQL introspection tables, restate sql describe <table> shows their columns.
  • restate openapi prints the Admin API spec, for anything the commands don't cover.

When running it:

  • Always pass --json. The output, errors included, is a single JSON document on stdout, and the command never prompts. Errors carry a kind and often next_steps with the commands to run next.
  • Commands that change something (register, cancel, kill, purge, state edits, ...) don't apply the change with --json alone: they print the planned changes with "applied": false and an apply_command, and exit with code 3. Show the plan to the user, and only then run it again with --yes. Use --dry-run to preview without applying.
  • Run restate whoami --json to check which server the CLI talks to. By default it's the local server (admin API on localhost:9070).

These features require CLI version 1.8 or later. If restate search doesn't exist, ask the user to upgrade the CLI.

Before-you-design checklist

Before designing any Restate service architecture, check:

QuestionConsult
Restate service types, stateful entities, keying, concurrency?references/design-and-architecture.md
Concurrency limits, tenant isolation, or downstream protection?references/flow-control-and-scopes.md
Non-Restate orchestrator in the project?references/translate-to-restate.md
Invoking, cancelling, deduplicating, or attaching to invocations?references/invocation-lifecycle.md
Error handling, compensation, sagas?Error handling guide, Sagas guide
AI agent or LLM calls?references/ai-agents.md, then the relevant framework reference

Always verify before finishing

All checks below are mandatory.

  • All side effects, external I/O, and DB calls wrapped in ctx.run()
  • No native random, time, sleep, or UUID -- use ctx helpers
  • Restate concurrency combinators only (no Promise.all, asyncio.gather/wait, CompletableFuture, goroutines + channels, select)
  • No ctx operations inside ctx.run()
  • TerminalError raised for non-retryable failures
  • Python: no bare except:
  • AI agents: load references/ai-agents.md, journal every LLM call and tool side effect, and set bounded retry policies
  • Virtual Objects: no deadlock cycles
  • Service registered and invoked via curl or the UI
Replay test - required on any handler logic change

Any change to handler business logic (new ctx operations, reordered steps, new ctx.run() blocks, new branches) must be covered by a Testcontainers test with always-replay enabled, and that test must pass before declaring the work done. Always-replay forces every journaled step to replay on every invocation, so non-determinism fails the test instead of failing in production on retry.

  • TypeScript: alwaysReplay: true in RestateTestEnvironment.start
  • Python: always_replay=True in restate.create_test_harness
  • Java / Go: RESTATE_WORKER__INVOKER__INACTIVITY_TIMEOUT=0m on the Restate container

See the Testing section of references/<sdk>/api-and-pitfalls.md for the working scaffold.

Comments

Markdown supported