Skip to content
Agents: this page is Markdown at /effect-handbook/index.md · llms.txt · reading guide View raw

The Effect 4 Handbook — A Guided Tour of Effect v4 ​

Source-grounded guide for humans and coding agents. Validation target refreshed 2026-11-19 to published effect@4.1.4, tag effect@4.1.4, commit 289a53f7 (released 2026-11-11). Each module is labelled with its public import path and stability marker.


Orientation ​

Version and validation scope ​

This edition validates examples against published effect@4.1.4 — not unreleased main. The source audit covered all 144 modules exported from the effect root barrel, all 23 public effect/<area> families (266 modules), the 35 public packages, their tests and examples, every change from 4.1.0 to 4.1.4, and every canonical Markdown page in this site. Examples are checked with pnpm, Node's native TypeScript execution, TypeScript 7.0.2 in strict mode, and Effect @effect/tsgo 0.70.0 diagnostics. Short fragments may declare application-specific boundaries.

All chapters and deep dives inherit this edition's audit target. Edition URLs identify major.minor; the release above, the site footer, and generated Markdown headers identify the exact audited patch. Chapter prose states the behavior directly; explicit version numbers are reserved for release history, migration boundaries, reproducible installation, and pinned source links.

New to Effect 4? Start with Getting Started — it covers installation (npm install effect now installs Effect 4), TypeScript and ESM settings, and a first program.

Your first session: follow the small approval worker route through errors, a tested service, resource ownership, Layers, and shutdown — five small exercises with observable self-checks.

Stability and support ​

Effect 4.0 is a stable release with a published long-term-support policy: bug fixes until September 2029 or one year after 5.0 ships, and security fixes until September 2029 or two years after 5.0 ships, whichever is later. The effect runtime and packages in its release train share one version number and are released together, so upgrade them as one coordinated bump. External compiler tooling such as @effect/tsgo has its own version line.

Stability is declared per API with a JSDoc tag, not by import path. Since 4.0.2 every module and every directly importable export carries an explicit tag:

TagPromiseWhere you meet it
@stability stableStrict semantic versioning: breaking changes only in a major release.Most of the "effect" root barrel — Effect, Layer, Schema, Stream, Config, the data structures, most Tx* transactional modules — plus effect/testing's TestClock and the text codecs Base64, Base64Url, Hex, and EncodingError under effect/encoding.
@stability unstableMay gain features in a patch release and break in a minor release. Production-ready; pin exact versions and read release notes before upgrading.The subsystem families under effect/<area> — http, http-api, rpc, sql, cluster, workflow, ai, cli, reactivity, persistence, eventlog, observability, net, socket, process, workers, devtools, schema, crypto, jose — a set of root-barrel modules (Arbitrary, ByteSize, Bytes, ChannelSchema, ErrorReporter, ExecutionPlan, FileSystem, Graph, HashRing, LayerMap, LayerRef, Newtype, PartitionedSemaphore, Path, PlatformError, Rational, SemVer, SemVerRange, Stdio, Terminal, TxChunk, Version), TestConsole and TestSchema, the format codecs Csv, Ini, JsonArray, Json5, Jsonc, Ndjson, SchemaBinary, Sse, Tar, Toml, and Yaml, a set of advanced Schema APIs, and every API that exposes a third-party dependency (driver options and clients in @effect/sql-*, provider clients and generated schemas in @effect/ai-*, @effect/opentelemetry, the vitest re-export in @effect/vitest, Redis and undici accessors in the platform packages).
@stability experimentalMay gain features and break in a patch release.The effect/graphql family and @effect/graphql-generator; the @effect/platform-cloudflare package; Host, Dns, and AddressResolver under effect/net; DatagramSocket under effect/socket; the root modules Glob and TextDiff; the Xml and Zip codecs; CircuitBreaker under effect/persistence; McpClient, McpClientError, AgUi, AgUiSchema, and AgUiServer under effect/ai; their related Schema codecs and host adapters. Pin exact versions and re-check contracts on every upgrade; see GraphQL and Platform & Runtime Hosts.

"Unstable" describes the compatibility contract, not the quality: HTTP, SQL, and RPC are what production Effect applications are built on. Every module section carries its stable, unstable, or experimental label. TestConsole and TestSchema are unstable testing APIs. Each page describes the pinned release. What changed from one audited release to the next — behavior, stability, renamed options and telemetry names, new modules, and handbook corrections — is recorded in Release History; the per-package CHANGELOG.md files in the Effect repository remain the authoritative record of every change.

Official upstream companions ​

These official resources complement the handbook with longer explanations and executable examples. The GitHub links are pinned to the same audited release so their code and this handbook stay reproducible together; the website guides track Effect's main branch, so where they differ from this handbook, the pinned release and this handbook win.

Official Effect resourceBest use
Effect v4 guidesThe official website's narrative guides — error management, requirements, resources, concurrency, streams, scheduling, Schema, and platform. Not release-pinned. Every handbook topic links the matching guides at the top of its page.
API referenceGenerated per-module reference for every effect and @effect/* package, versioned per release.
Onboarding track and InstallationThe motivational on-ramp and setup steps; the handbook's short version is Getting Started.
AGENTS.md and ai-docs/ shipped inside the effect packageThe maintainers' own coding conventions for agents (also published as LLMS.md), with topic-organized executable examples under node_modules/effect/ai-docs/src. See Coding conventions for agents below for how this handbook relates to it.
Migration guideThe official v3 → v4 guide: import and API rename maps, services, causes, error handling, forking, layers, scopes, and the Schema v4 migration.
Arbitrary guideThe long-form reference for the native property-testing engine.
Comprehensive Schema guideThe long-form reference for codecs, validation, transformations, serialization, tooling, errors, integrations, and migration.

Effect 4 ships as one library. The core effect package holds the runtime, standard library, and the subsystem families (http, rpc, sql, cluster, ai, …), with platform-, driver-, and provider-specific satellites around it. One import surface, one version number, zero runtime dependencies, a runtime built for speed and tree-shaking.

The through-line: one type ​

Everything orbits a single type:

Fragment · Type-checked with fixture

ts
import { Effect } from "effect"

// An Effect<Success, Error, Requirements> is a *description* of a program that,
// when run, will either succeed with A, fail with a typed E, or need services R.
declare const loadEmployee: (id: string) => Effect.Effect<Employee, EmployeeNotFound, Hris>
//                                                          ▲ value     ▲ typed err       ▲ deps

Three type parameters; almost every module is "a thing you can put in one of those slots." A Stream is the many-valued sibling of the success channel. Cause is the full truth of the error channel. Layer satisfies the requirements channel.

Official guides: The Effect Type, Why Effect?.

The house style (every example in this handbook uses it) ​

Idiomatic Effect 4 uses Effect.gen for inline composition and Effect.fn for functions returning effects (adds a tracing span and tidy stack traces automatically).

Self-contained source · Type-checked

ts
import { Effect, Schema } from "effect"

// Errors are schema-defined, tagged classes — serializable and pattern-matchable.
class BudgetExceeded extends Schema.TaggedError<BudgetExceeded>()("BudgetExceeded", {
  remaining: Schema.Finite,
  requested: Schema.Finite
}) {}

// Effect.fn("name") = a traced, generator-based function returning an Effect.
export const drawFromMeritBudget = Effect.fn("drawFromMeritBudget")(
  function*(remaining: number, raise: number) {
    if (raise > remaining) {
      // `return yield*` makes termination explicit to TypeScript.
      return yield* new BudgetExceeded({ remaining, requested: raise })
    }
    yield* Effect.log(`Approving raise of ${raise}`)
    return remaining - raise
  }
)

Services are classes that extend Context.Service; the implementation rides along as a static Layer:

Fragment · Type-checked with fixture

ts
import { Context, Effect, Layer } from "effect"

class Hris extends Context.Service<Hris, {
  readonly getEmployee: (id: string) => Effect.Effect<Employee>
}>()("comp/Hris") {
  static layer = Layer.effect(Hris, Effect.gen(function*() {
    yield* Effect.log("connecting to HRIS…")
    return Hris.of({ getEmployee: (id) => Effect.succeed({ id, level: "L4" } as Employee) })
  }))
}

Dual APIs. Most Effect functions ship two overloads with identical behavior: data-last (Effect.map(f) returns a function that expects the value, built for .pipe(...) chains) and data-first (Effect.map(self, f), convenient for a single step). Rule of thumb: one step, data-first; several steps, .pipe with data-last. Function.dual builds the same pair for your own functions.

Official guides: Guidelines, Do notation vs generators, Dual APIs.

Coding conventions for agents ​

The effect package ships its maintainers' conventions as AGENTS.md (the same text as the repository's LLMS.md), and this handbook follows them. The rules that matter most when generating code:

  • Generators over combinator chains. Write inline logic with Effect.gen; write reusable functions with Effect.fn("name") when a tracing span is useful and Effect.fnUntraced when it is not (library internals, hot paths). Do not write a function whose only body is return Effect.gen(...). Attach extra behaviour as trailing arguments to Effect.fn rather than .pipe on its result.
  • Return when you fail. Inside a generator, write return yield* new SomeError(...) so TypeScript knows the function does not continue.
  • Errors are Schema.TaggedError classes, recovered with Effect.catchTag / Effect.catchTags for specific tags and Effect.catch for everything. Model variants inside one error with a tagged reason field and Effect.catchReason.
  • Behaviour lives in services. Define a service with Context.Service<Self, Interface>()("package/path/Name"), attach its implementation as a static layer, and build it with Service.of({...}). Use Context.Reference for values with a default (configuration, feature flags).
  • Validate with Schema, never by hand. Untrusted input is decoded with a schema; domain models are Schema.Classes. For runtime type guards on unknown, use the Predicate module instead of writing isString-style helpers.
  • Time goes through DateTime and Clock, not Date.now(), so it is testable.
  • Run at the edge. NodeRuntime.runMain or Layer.launch for a process; ManagedRuntime when a host framework calls in.
  • Observability is built in. Prefer the lightweight Otlp modules from effect/observability in new projects; use @effect/opentelemetry when joining an existing OpenTelemetry setup.

Two tooling habits make agents measurably more effective with Effect: install the Effect language service (@effect/tsgo, see Effect diagnostics) so a wrong channel or an un-yielded Effect is a compiler error rather than a runtime surprise, and keep the installed effect source in reach — the official guidance is to prefer the installed package and its ai-docs over other copies of the documentation, which may describe a different version.

The lay of the land ​

  • effect — The core: 144 root modules (Effect, Stream, Schema, Layer, the data structures, STM…) plus 23 public effect/<area> families (http, http-api, rpc, sql, cluster, ai, cli, workflow, eventlog, encoding, crypto, jose, reactivity, persistence, net, testing, graphql, and more).

  • @effect/platform-* — node, bun, deno, browser, plus the shared Node implementation package — concrete implementations of FileSystem, HttpServer, sockets, workers, and runtimes for each host — and the experimental cloudflare package, which runs cluster entities, workflows, and queues on Durable Objects.

  • @effect/sql-* — Drivers: pg, mysql2, mssql, clickhouse, libsql, d1, pglite, and a family of sqlite-* variants.

  • @effect/ai-* — Provider bindings: amazon-bedrock, anthropic, openai, openai-compat, openrouter, typesafe — concrete backends for the provider-agnostic AI modules.

  • @effect/atom-* — Framework bindings for the reactive Atom system: react, solid, vue.

  • @effect/opentelemetry — Bridges Effect's tracing/metrics/logging to a real OpenTelemetry SDK (Node SDK, Web SDK, exporters).

  • @effect/vitest — First-class testing: it.effect, TestClock-aware assertions, layer-sharing helpers, property tests over the native Arbitrary module.

  • tools — The repo's own build/codegen tooling — AI code/doc generators, OpenAPI and GraphQL generators, @effect/doctest, the bundler and jsdoc pipeline.

Import style. Each module is labelled with its subpath (effect/Queue), while examples import from the "effect" barrel: import { Effect, Queue } from "effect". The two are equivalent at runtime. The package declares no side effects, so bundlers with deep scope analysis (Rolldown, Rollup, Webpack 5+) tree-shake the barrel; import * as Queue from "effect/Queue" is the conservative form elsewhere. Area families are always imported by their own barrel, for example import { HttpClient } from "effect/http". Official guide: Importing Effect.

How to use this handbook ​

  • ⌘K / Ctrl+K — search — Jump to a module by name. Type "semaphore", "TxRef", "HttpApi", "Sink" — hit enter and you land right on it, with the module highlighted.

  • Sidebar — browse by theme — Chapters are grouped from foundations → concurrency → data → web → distributed → tooling. Roughly the order you'd grow into them.

  • Prev / Next — read it like a book — Each chapter ends with navigation.

  • Reading programmatically — Every page has a Markdown twin at the same path with .md appended, llms.txt routes intents to sections, and effect-4-modules.md lists every module. Using the Handbook from an Agent is the full protocol, including a drop-in AGENTS.md block.

  • Other Effect versions — One edition of the handbook is published per Effect major.minor, each audited against one release and served under its own path (/4.0/, /4.1/, …); the site root is always the newest. Use the edition switcher in the navigation bar, or versions.json at the site root, to match the handbook to the effect version you have installed.

Major module entries cover what the API is, its mental model, a real example, and a "reach for it when" line. Smaller supporting modules stay compact so this remains useful as an agent reference.

Tip: Every Effect API in this handbook is grounded in the audited implementation, tests, or package examples. Pin compatible effect and @effect/* versions together, and re-audit unstable imports before upgrading.

Edition 4.1 · audited 2026-11-19 against Effect 4.1.4.