restate

Build resilient distributed applications with the Restate durable execution engine for TypeScript, Java, and Go. Intended for scenarios involving durable execution, resilient workflows, distributed transactions, the Saga pattern, virtual objects, or as a lighter-weight alternative to Temporal, covering persistent handlers, virtual objects, workflows, and Saga patterns.

Last repository push
GitHub Stars
219
Forks
38
Issues / PRs
7

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "restate" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-5e2135afb851c6125913db65c988b5b641a4c5cb936bb6e839dba7ae4e8f0db5. Verify the upstream source and version against https://github.com/TerminalSkills/skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Build resilient distributed applications with the Restate durable execution engine for TypeScript, Java, and Go. Intended for scenarios involving durable execution, resilient workflows, distributed transactions, the Saga pattern, virtual objects, or as a lighter-weight alternative to Temporal, covering persistent handlers, virtual objects, workflows, and Saga patterns.

0 Downloads

Introduction source: third_party · TerminalSkills · 1.0.0 Reference

SkillPi interpretation

Audience
Distributed transactions (payment → inventory → shipping) Long-running workflows that must complete (onboarding, provisioning) Saga pattern with compensating actions (rollback on failure) Exactly-once processing of events Replacing complex retry/queue logic with durable execution
Software, accounts and paid services
```bash npm install @restatedev/restate-sdk
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: restate
description: >-
  Build resilient distributed applications with Restate — durable execution
  engine for TypeScript/Java/Go. Use when someone asks to "durable execution",
  "Restate", "resilient workflows", "distributed transactions", "saga pattern",
  "fault-tolerant services", or "replace Temporal with something lighter".
  Covers durable handlers, virtual objects, workflows, and sagas.
license: Apache-2.0
compatibility: "TypeScript/Java/Go/Rust/Python. Self-hosted or Restate Cloud."
metadata:
  author: terminal-skills
  version: "1.0.0"
  category: development
  tags: ["durable-execution", "restate", "distributed", "workflows", "resilience"]

Restate

Overview

Restate is a durable execution engine — your code runs reliably even when things crash. Write normal async functions, and Restate ensures they complete: if a service crashes mid-execution, it resumes exactly where it left off. No lost state, no duplicate side effects. Like Temporal but with a simpler programming model — just annotate your functions, no state machines or DSLs.

When to Use

  • Distributed transactions (payment → inventory → shipping)
  • Long-running workflows that must complete (onboarding, provisioning)
  • Saga pattern with compensating actions (rollback on failure)
  • Exactly-once processing of events
  • Replacing complex retry/queue logic with durable execution

Instructions

Setup

npm install @restatedev/restate-sdk

# Run Restate server
docker run --name restate -p 8080:8080 -p 9070:9070 docker.io/restatedev/restate:latest

Durable Service

// services/payment.ts — Durable payment service
import * as restate from "@restatedev/restate-sdk";

const paymentService = restate.service({
  name: "payments",
  handlers: {
    // This handler is durable — if it crashes between steps,
    // it resumes where it left off without re-executing completed steps
    async processPayment(ctx: restate.Context, order: {
      orderId: string;
      userId: string;
      amount: number;
    }) {
      // Step 1: Reserve inventory (durable — won't re-run if already done)
      const reserved = await ctx.run("reserve-inventory", async () => {
        return await inventoryApi.reserve(order.orderId);
      });

      // Step 2: Charge payment
      const charge = await ctx.run("charge-payment", async () => {
        return await stripeApi.charge(order.userId, order.amount);
      });

      // Step 3: Confirm order
      await ctx.run("confirm-order", async () => {
        await orderDb.confirm(order.orderId, charge.id);
      });

      // Step 4: Send notification (won't duplicate even if retried)
      await ctx.run("notify", async () => {
        await emailApi.send(order.userId, "Order confirmed!");
      });

      return { orderId: order.orderId, chargeId: charge.id, status: "completed" };
    },
  },
});

restate.endpoint().bind(paymentService).listen(9080);

Virtual Objects (Stateful Entities)

// services/cart.ts — Stateful shopping cart (single-writer per key)
const cartObject = restate.object({
  name: "cart",
  handlers: {
    // Only one handler runs per cart ID at a time — no race conditions
    async addItem(ctx: restate.ObjectContext, item: { productId: string; quantity: number }) {
      // Get current cart state (durable K/V)
      const cart = (await ctx.get<CartItem[]>("items")) || [];
      cart.push(item);
      ctx.set("items", cart);
      return { items: cart.length };
    },

    async checkout(ctx: restate.ObjectContext) {
      const items = (await ctx.get<CartItem[]>("items")) || [];
      if (items.length === 0) throw new Error("Cart is empty");

      // Process payment durably
      const result = await ctx.serviceClient(paymentService).processPayment({
        orderId: ctx.key,
        items,
      });

      // Clear cart after successful payment
      ctx.clear("items");
      return result;
    },

    async getItems(ctx: restate.ObjectSharedContext) {
      return (await ctx.get<CartItem[]>("items")) || [];
    },
  },
});

Saga Pattern (Compensating Actions)

// services/booking.ts — Saga with automatic rollback
const bookingService = restate.service({
  name: "booking",
  handlers: {
    async bookTrip(ctx: restate.Context, trip: TripRequest) {
      let flightId: string | null = null;
      let hotelId: string | null = null;

      try {
        // Book flight
        flightId = await ctx.run("book-flight", () => flightApi.book(trip.flight));

        // Book hotel
        hotelId = await ctx.run("book-hotel", () => hotelApi.book(trip.hotel));

        // Book car
        const carId = await ctx.run("book-car", () => carApi.book(trip.car));

        return { flightId, hotelId, carId, status: "confirmed" };
      } catch (error) {
        // Compensate: cancel what was already booked
        if (hotelId) await ctx.run("cancel-hotel", () => hotelApi.cancel(hotelId));
        if (flightId) await ctx.run("cancel-flight", () => flightApi.cancel(flightId));
        throw error;
      }
    },
  },
});

Examples

Example 1: Reliable payment processing

User prompt: "Build a payment flow that never loses a charge — even if the server crashes between charging the card and updating the database."

The agent will use Restate durable execution to ensure each step (charge, update DB, send receipt) executes exactly once.

Example 2: Distributed saga for e-commerce

User prompt: "Implement an order workflow: reserve inventory → charge payment → ship. If any step fails, roll back everything."

The agent will create a Restate service with the saga pattern, compensating actions for each step, and durable state tracking.

Guidelines

  • ctx.run() for side effects — makes external calls durable and idempotent
  • Virtual objects for stateful entities — single-writer guarantee per key
  • Sagas with try/catch — compensate in catch block, each compensation is also durable
  • No message queues needed — Restate handles delivery and retries
  • ctx.sleep() for delays — durable timers that survive crashes
  • Service calls are durable — ctx.serviceClient(svc).method() retries automatically
  • Shared handlers — read-only handlers that can run concurrently
  • Simple programming model — write normal async functions, not state machines
  • Self-hosted — single binary, Postgres or RocksDB for state
  • HTTP invocation — trigger handlers via HTTP POST

Current listing version

1.0.0

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 提供 Restate 分布式应用开发能力,解决持久执行、Saga 模式等实际工程问题
  • 面向后端开发者,具有高实用价值和技术深度
  • 代码示例完整,可直接用于生产环境
Trigger Precision95/100

Highlights

  • 触发词覆盖全面且精准,包含核心概念和技术关键词
  • 边界清晰,无歧义或重叠风险
Structure and Standards90/100

Highlights

  • 结构清晰,分步骤说明完整
  • frontmatter 信息完整,包含许可证和兼容性说明
  • 提供端到端使用示例
Execution Reliability88/100

Highlights

  • 工具来源明确,参数配置正确
  • 异常处理机制完善(Saga 补偿模式)
  • 提供自托管部署方案
Evidence Verifiability (mean of the first four)90/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

  • Install or fetch external dependencies

    Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.

    Mentioned in main document · lines 37

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

```bash npm install @restatedev/restate-sdk

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.