effect-rpc-client

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

3|Updated Apr 1, 2026
One-click install
npx skills add https://github.com/mpsuesser/opencode-effect-enforcer --skill effect-rpc-client-mpsuesser
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: effect-rpc-client
Source: https://github.com/mpsuesser/opencode-effect-enforcer/tree/main/skills/effect-rpc-client
Command: npx skills add https://github.com/mpsuesser/opencode-effect-enforcer --skill effect-rpc-client-mpsuesser

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Consuming Effect RPC services requires correctly wiring protocol layers, serialization codecs, headers, streaming, interruption, and reconnection logic, and mistakes in any of these produce confusing transport failures. This Skill gives the agent authoritative guidance for assembling and debugging RpcClient stacks against Effect v4. ## Core Features & Use Cases - Client and transport assembly: Create typed clients with RpcClient.make and pair them with HTTP, WebSocket, raw TCP, or worker protocol layers plus JSON, NDJSON, SchemaBinary, or JSON-RPC serialization. - Streaming, headers, and interruption: Consume stream RPCs as Streams or queues, manage ambient and per-call headers, propagate client-side interrupts to server handlers, and configure reconnection with ConnectionHooks. - Error handling and testing: Handle the RpcClientError reason taxonomy, distinguish server defects in the Cause channel, and test consumers in-process with RpcTest.makeClient. - Use Case: You need a browser client that calls a streaming RPC over WebSocket with bearer-token middleware and automatic reconnect; the Skill walks through layerProtocolSocket, layerNdjson, RpcMiddleware.layerClient, and retryTransientErrors. ## Quick Start Use the effect-rpc-client skill to build a typed client for my UserRpcs group 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 such as layerProtocolHttp or layerProtocolSocket, an RpcSerialization layer, and any requiredForClient middleware layers, typically wrapped in a Context.Service.

Which serialization should I use for Effect RPC over WebSocket or TCP?

Raw TCP requires a framed codec such as NDJSON, SchemaBinary, or newline JSON-RPC because plain JSON cannot find message boundaries in a byte stream. WebSocket works with any codec including plain JSON since the transport frames messages itself. Client and server must use the same codec.

How do I consume streaming RPCs with Effect RpcClient?

A stream: true rpc returns a Stream directly, which you run with operators like Stream.take and Stream.runCollect. Use the asQueue: true option to get a Queue.Dequeue for manual chunk control, where end-of-stream arrives as Cause.Done in the error channel.

Does Effect RpcClient reconnect automatically on socket failure?

Yes, the socket protocol pings every 5 seconds and reconnects with an exponential schedule capped at 5 seconds. In-flight requests fail with RpcClientError and are not replayed; enable retryTransientErrors to keep pending requests alive across reconnect attempts.

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, which the upstream end-to-end fixtures depend on.

How do I test Effect RPC consumers without a network?

Use RpcTest.makeClient to create an in-process client-server pair that exercises requests, streams, acks, interrupts, headers, and middleware through the real machinery without codecs or sockets. Its error channel excludes RpcClientError, so only your declared rpc and middleware errors appear.