effect-rpc-client

Build typed RPC clients in Effect with HTTP, WebSocket, TCP, and worker transports.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Consuming typed RPC services in Effect v4 requires correctly assembling protocol layers, serialization codecs, headers, streaming, interruption, and error handling, and mistakes in any of these cause transport failures or untyped errors that are hard to debug. ## Core Features & Use Cases - Client construction: Create typed clients with RpcClient.make, wrap them in Context.Service layers, and satisfy middleware requirements with RpcMiddleware.layerClient. - Transport and serialization pairing: Choose between HTTP, WebSocket, raw TCP, and worker protocol layers, paired correctly with json, ndjson, msgpack, or JSON-RPC codecs based on framing rules. - Streaming, interruption, and errors: Consume stream RPCs as Stream or Queue, propagate interrupts to the server, handle the RpcClientError taxonomy, and configure reconnection with ConnectionHooks. - Use Case: You need to call a UserRpcs group from a browser app over WebSocket with ndjson, attach a bearer token via client middleware, and retry transient socket errors with backoff. ## Quick Start Use the effect-rpc-client skill to build a typed client for my RpcGroup over WebSocket with ndjson serialization and auth headers.

Frequently Asked Questions about effect-rpc-client

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

FAQPage Schema
How do I create a typed RPC client in Effect?

Call RpcClient.make with your RpcGroup to get an object with one typed method per rpc tag. Provide a Protocol layer, any required client middleware layers, and a Scope, typically by wrapping it in Layer.effect inside a Context.Service.

Which serialization codec should I use with each RPC transport?

Raw TCP requires a framed codec like ndjson, msgpack, or ndJsonRpc because plain json cannot find message boundaries. WebSocket works with any codec, and HTTP streaming responses need a framed codec so chunks arrive incrementally.

How do I test an Effect RPC client without a network?

Use RpcTest.makeClient, which wires an in-process client and server through the real request, streaming, and middleware machinery with no transport. Provide the handler layers plus any server and client middleware layers, and the error channel excludes transport errors.

Why do my RPC header names not match on the server?

Header names are normalized to lowercase by Headers.fromInput, so sending { userId: '123' } arrives as headers.userid on the server. Server middleware must read the lowercase key.

Does the Effect RPC socket client reconnect automatically?

Yes, the socket protocol retries with an exponential schedule capped at 5 seconds forever by default, and sends pings every 5 seconds. In-flight requests fail on connection errors unless retryTransientErrors is enabled, and requests are not replayed after reconnect.

Why does my RPC client fail with RpcClientError instead of my domain error?

RpcClientError represents transport failures such as socket errors, HTTP errors, or worker failures, separate from your declared rpc errors. Catch domain errors by tag and retry RpcClientError separately, excluding the RpcClientDefect reason which indicates a protocol bug.