effect-atom-rpc

Build reactive Atom-aware RPC clients with cached queries, invalidating mutations, and SSR hydration.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Connecting React or Atom-based frontends to an Effect RpcGroup normally requires hand-writing caching, invalidation, loading states, and SSR hydration logic. This Skill guides the construction of AtomRpc clients that provide cached query atoms, invalidating mutation atoms, and hydration support out of the box. ## Core Features & Use Cases - Cached Reactive Queries: Create query atoms via client.query(tag, payload, options) that deduplicate requests by key, support time-to-live caching, and re-fetch on reactivity-key invalidation. - Invalidating Mutations: Use client.mutation(tag) to run side-effectful RPCs that automatically invalidate dependent query atoms through reactivity keys. - SSR Hydration: Pass a serializationKey to make query atoms serializable so server-rendered state hydrates on the client without refetching. - Use Case: Build a user management UI where a UserList component subscribes to a cached ListUsers query, and a CreateUser mutation invalidates the 'users' reactivity key so the list refreshes automatically after creation. ## Quick Start Ask the AI to create an AtomRpc client for an existing RpcGroup with a query for listing records and a mutation that invalidates the list's reactivity key.

Frequently Asked Questions about effect-atom-rpc

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

FAQPage Schema
How do I create a reactive RPC client with AtomRpc in Effect?

Define a class extending AtomRpc.Service with your RpcGroup and a protocol layer such as RpcClient.layerProtocolHttp. The class exposes static query and mutation methods that return cached atoms consumable via useAtomValue and useAtomSet from @effect/atom-react.

How do I invalidate cached queries after a mutation in AtomRpc?

Pass reactivityKeys to both the query and the mutation call. After a mutation succeeds, it fires Reactivity.invalidate with those keys, causing every query atom declaring overlapping keys to re-fetch automatically.

Does AtomRpc support SSR hydration for query atoms?

Yes, non-stream query atoms become serializable when you pass a stable serializationKey, keyed as AtomRpc:tag:key. Dehydrate the registry on the server with Hydration.dehydrate and call Hydration.hydrate on the client before rendering.

Can I use AtomRpc with stream RPCs?

Yes, stream RPCs return an Atom.Writable of PullResult instead of AsyncResult. Write void to the atom to pull the next chunk, but note that stream queries cannot be serialized or hydrated.

What is the difference between AtomRpc and AtomHttpApi?

AtomRpc targets RpcGroup definitions while AtomHttpApi targets HttpApi endpoints, but both expose the same query and mutation pattern. AtomHttpApi queries take group and endpoint names plus a request object instead of a tag and payload.

Why is my AtomRpc UI stale after a mutation?

The mutation likely omitted reactivityKeys, so no query atoms were invalidated. Add reactivityKeys matching the keys declared on the affected queries, and avoid overly broad keys that invalidate unrelated data.