effect-rpc-api

Define type-safe RPC contracts with Effect v4 Rpc, RpcGroup, RpcSchema, and RpcMiddleware.

1|Updated Aug 24, 2026
One-click install
npx skills add https://github.com/lambdasolver2/opencode-effect-harness --skill effect-rpc-api-lambdasolver2
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: effect-rpc-api
Source: https://github.com/lambdasolver2/opencode-effect-harness/tree/main/packages/module-typescript/assets/skills/effect-rpc-api
Command: npx skills add https://github.com/lambdasolver2/opencode-effect-harness --skill effect-rpc-api-lambdasolver2

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Defining RPC contracts that both client and server packages can share is error-prone: payload, success, error, and defect schemas drift apart, streaming semantics are misunderstood, and middleware types get misdeclared. This Skill provides verified, source-checked guidance for declaring RPC contracts with effect/unstable/rpc in Effect v4, so contract changes surface as compile errors in every handler and client. ## Core Features & Use Cases - RPC Definition: Declare procedures with Rpc.make covering payload, success, error, defect schemas, primaryKey for idempotent payloads, and per-rpc combinators like prefix, annotate, and middleware. - Streaming Contracts: Model streaming endpoints with stream: true and RpcSchema.Stream, including correct element/error schema interpretation and ClientAbort cancellation semantics. - Group Composition & Middleware: Compose contracts with RpcGroup (add/merge/omit/prefix), define RpcMiddleware.Service with provides/requires/clientError, and build client layers via RpcMiddleware.layerClient. - Use Case: You are building a shared contract package for a users service. Use this Skill to define GetUser, CreateUser, and a streaming WatchUsers rpc, attach an AuthMiddleware with a UserNotFound/Unauthorized error union, and version the API with prefix + merge. ## Quick Start Ask the AI to define a shared Effect v4 RPC contract with a streaming endpoint and auth middleware using Rpc.make, RpcGroup, and RpcMiddleware from effect/unstable/rpc.

Frequently Asked Questions about effect-rpc-api

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I define an RPC contract in Effect v4?

Use Rpc.make from effect/unstable/rpc with a tag and options for payload, success, error, and defect schemas. Payloads accept inline struct fields or a Schema.Class, and the resulting rpc value is grouped with RpcGroup.make for shared client/server use.

How do I add a streaming endpoint with Effect RPC?

Set stream: true in Rpc.make; the success option becomes the stream element schema and error becomes the stream error schema, while errorSchema is set to Schema.Never. Handlers return a Stream and clients receive Stream<Element, StreamError | RpcClientError>.

Is there an @effect/rpc package in Effect v4?

No, @effect/rpc does not exist in v4. Everything lives under effect/unstable/rpc, and deep subpath imports like effect/unstable/rpc/RpcMessage also work via the package's wildcard export.

How does RPC middleware work in Effect v4?

Define a class extending RpcMiddleware.Service with a config type parameter carrying provides, requires, and clientError, plus options limited to error and requiredForClient. Attach it with rpc.middleware(...) or group.middleware(...); its error schema is automatically unioned into the rpc's error type.

Why does RpcGroup.merge silently override my RPCs?

RpcGroup.merge is last-wins on duplicate rpc tags and duplicate group annotation keys, with no error raised. Apply prefix to each group before merging so tag collisions cannot occur.

When should I use primaryKey in Rpc.make?

Use primaryKey only when the payload is declared as inline struct fields; it is typed never for schema payloads. It gives each payload a deterministic string identity that the cluster layer uses to dedupe retried sends of persisted messages.