effect-socket

Build pull-based TCP, Unix, TLS, and WebSocket transports with Effect Socket readers and writers.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Managing bidirectional socket connections in TypeScript involves tricky lifecycle ownership, framing, reconnection, and error handling. This Skill teaches agents how to use Effect's Socket API correctly so connections are scoped, frames are decoded, and retries reacquire resources instead of leaking them. ## Core Features & Use Cases - Pull-based readers and writers: Acquire a scoped reader that yields batches of string or Uint8Array frames, and a writer with backpressured write and writeAll operations. - Multiple transports: Create WebSocket clients, TCP, Unix, and TLS sockets via NodeSocket and BunSocket, including STARTTLS upgrades and socket servers with bound addresses. - Framing and reconnects: Compose NDJSON or SchemaBinary duplex channels over sockets, and retry scoped reader acquisition with schedules for resilient reconnects. - Use Case: Build a WebSocket client that subscribes to a feed, decodes each frame with a schema, and automatically reconnects with exponential backoff when the connection drops. ## Quick Start Ask the agent to write an Effect WebSocket client that connects to a URL, sends a subscribe message, logs incoming frames, and reconnects on abnormal close.

Frequently Asked Questions about effect-socket

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

FAQPage Schema
How do I create a WebSocket client with Effect Socket?

Use Socket.makeWebSocket with the URL and options, then acquire a reader via Socket.readerString and a writer via socket.writer inside Effect.scoped. Provide a platform constructor layer such as NodeSocket.layerWebSocketConstructor or the global constructor layer.

How do I reconnect an Effect socket after it closes?

Retry the entire scoped reader acquisition and consumption effect, not just an already-acquired pull, using Effect.retry with a Schedule. This releases each connection before the next attempt, and handshakes must be idempotent.

Does Effect Socket support TCP and TLS connections on Node?

Yes, NodeSocket.makeNet creates TCP or Unix socket recipes and NodeSocket.makeTls creates TLS connections with options like servername. Connection failures surface during reader acquisition, and layerNet or layerTls provide service equivalents.

How do I frame messages over a TCP socket in Effect?

Use Ndjson.duplexSchema with Socket.toChannel for newline-delimited JSON, or SchemaBinary.duplex with compatible schemas for binary framing. Decode unknown frames with schemas before domain processing.

Why does every socket pull termination fail with SocketError?

Effect Socket models all termination, including clean close, as a SocketError so pulls never complete silently. Narrow the reason with Effect.catchReason or guards, and handle normal close at the owning protocol boundary.