Skip to content
GroundworkGroundwork
Esc
↑↓navigate↵open⌘Jpreview
On this page

Built-in services

The services Effect already has for commands, files, the terminal, HTTP, sockets, SQL and more, to reach for before writing your own.

Effect ships services for most of what a system talks to. Use them before writing a wrapper: they’re typed, testable through their layers, and traced. The platform layer (NodeServices.layer from @effect/platform-node, or the Bun and browser equivalents) provides the ones that touch the machine.

Modules under effect/<name> are still marked unstable in Effect 4. Use them anyway: an unstable Effect module is almost always better than writing your own. Pin the version and read the release notes before bumping.

These tables are a starting point, not a full list. Effect has more modules than this, and their APIs change between releases, so check the official Effect documentation and the module’s source before relying on one.

The machine

Need Service Module
Run a command and read its output ChildProcess, ChildProcessSpawner effect/process
Read and write files FileSystem effect
Join and resolve paths Path effect
Read keys and lines, write to the screen Terminal, Stdio effect
Environment variables and settings Config, ConfigProvider effect
Time, for code that tests can control Clock, Cron effect

Commands and agents

Need Service Module
Commands, flags, prompts and completions Command, Flag, Argument, Prompt effect/cli
MCP servers and tools McpServer, Tool, Toolkit effect/ai
Calling a language model LanguageModel, Chat effect/ai

CLI and agents shows them working.

Talking to other systems

Need Service Module
HTTP requests HttpClient, FetchHttpClient effect/http
An HTTP server and router HttpServer, HttpRouter effect/http
A typed HTTP API with a client and OpenAPI HttpApi effect/http-api
Unix and TCP sockets, WebSockets Socket, SocketServer effect/socket
Typed requests over any transport RpcGroup, RpcClient, RpcServer effect/rpc
Server-sent events and NDJSON streams Sse, Ndjson effect/encoding

A daemon with a CLI on the same machine, such as a bridge or a sync service, talks over a Unix socket with effect/rpc, so both ends share one schema.

Data

Need Service Module
SQL, with migrations SqlClient, Migrator, and a driver from @effect/sql-* effect/sql
Key-value storage KeyValueStore effect/persistence
Caches that survive a restart, rate limits PersistedCache, RateLimiter effect/persistence
In-memory caches Cache effect

Work over time

Need Service Module
Retries, polling and backoff Schedule effect
Streams of output or events Stream effect
Queues and fan-out Queue, PubSub effect
Work in a worker thread Worker effect/workers
Long jobs that resume after a restart Workflow, Activity effect/workflow
App state for a UI Atom, see Lit effect/reactivity

Seeing what it does

Need Service Module
Logs Logger effect
Traces and metrics Tracer, Metric effect
Sending them to a collector Otlp, PrometheusMetrics effect/observability

Platform layers

Last updated on