Effect
Use this skill for Effect v4 RC (effect@rc, currently 4.0.0-rc.x). npm latest is still Effect v3. Do not mix v3 and v4 packages.
Workflow
- Inspect the local Effect surface:
effect/@effect/*versions, import style (from "effect"vseffect/Effect), runtime (CLI, HTTP, worker, browser, test), and whether layers/config/platform are already in play. - Prefer a local checkout of
Effect-TS/effectmainunder.temp/effect(v4 RC source).Effect-TS/effect-smolis archived; v4 history now lives inEffect-TS/effect. Browse sources,LLMS.md,MIGRATION.md,migration/*,packages/effect/SCHEMA.md, andai-docs/. Details: source-map.md. - Refresh docs when the installed RC differs from the snapshot or the task asks for latest APIs. Resolve library docs, then check installed
.d.ts. - Route by concern:
- Install,
Effect.fn/gen, errors, forks, run, Config → setup-core.md - Services, layers, scopes,
ManagedRuntime,Layer.launch→ services-layers-runtime.md - Full stable module catalog (what each module is for) → modules-stable.md
- Stream, Queue/PubSub, fibers, STM-like
Tx*, caching, requests → concurrency.md - Schema v4 → schema-v4.md
effect/unstable/*→ modules-unstable.md@effect/platform-*,sql-*,ai-*,atom-*, OTel, tools → ecosystem.md@effect/vitest@rc→ vitest-testing.md- v3 → v4 → migration.md
- Install,
- Implement in project style: match the installed RC, keep framework edges thin, compose layers explicitly, treat
effect/unstable/*as RC-plus-unstable (may break in minor releases).
Coding style (canonical)
From Effect’s own LLMS.md / ai-docs:
- Named effectful functions use
Effect.fn("name")(span + stack). Library internals in Effect’s own repo preferEffect.fnUntraced. Do not wrapEffect.genin a plain function; do not.pipethe result ofEffect.fn. - Domain errors:
Schema.TaggedError. Alwaysreturn yield*when failing so TypeScript narrows. - Services:
Context.Service, identifier like"myapp/db/Database", implement withDatabase.of({ ... }), attachstatic readonly layer. Preferyield* ServiceoverService.useexcept one-liners. - Untrusted data: Schema, not ad-hoc predicates. Use
PredicateforisString/isObject/ composition — do not invent those helpers. - Dates/time in Effect programs:
DateTime+Clock, not rawDate.now(). - Observability: logs/traces/metrics in core; new projects prefer
effect/unstable/observabilityOTLP. Use@effect/opentelemetrywhen an existing OTel SDK is required. - Process entry:
NodeRuntime.runMain/BunRuntime.runMain(BunRuntimeis the shared Node runner) orDenoRuntime/BrowserRuntime, orLayer.launch. Prefer those overRuntime.makeRunMain. Cloudflare: no platform package — Fetch + SQL D1/DO drivers. - Prefer Stream/Sink over Channel; Schema over SchemaAST; Cache vs ScopedCache vs Pool vs RcMap per concurrency.md.
Judgment
- Align every
@effect/*package to the same4.0.0-rc.Naseffect. - TypeScript 5.9+ (7 recommended for Effect’s TS tooling).
strict: true. Node 18+ generally; some SQL drivers need Node 22.16+. - No v3 APIs in v4 code:
Context.Tag/GenericTag,Effect.Tag/Effect.Service,Either,FiberRef,Effect.catchAll,Effect.fork(useforkChild),Effect.async(usecallback). - Layers memoize across
Effect.provideunless{ local: true }orLayer.fresh. Runtime<R>is gone. Run withEffect.run*/run*With(context)orManagedRuntime.Ref/Deferred/Fiberare not yieldable Effects — useRef.get,Deferred.await,Fiber.join.- Prefer typed failures over throw/die. Defects are programmer errors.
- Keep Schema
EncodedvsTypevisible at boundaries. - Tests:
@effect/vitest@rc+vitest@^4.1.0. Preferit.effect(already scoped + TestClock; do not wrap inEffect.scoped). ImportTestClockfromeffect/testing.it.effectsuppresses logs;it.livedoes not. - Do not:
catchAll/fork/forkDaemon/Context.Tag/Effect.Service/.Default/Either/FiberRef/Date.now/try/catchingen/Schema.Datefor ISO strings/Union(A,B)/it.effect+ extraEffect.scoped.
Module routing (quick)
| Need | Use |
|---|---|
| Workflows, errors, concurrency | Effect, Cause, Exit, Result, Fiber |
| DI | Context, Layer, ManagedRuntime |
| Config | Config, ConfigProvider |
| Validation / domain types | Schema (+ Schema.Class / TaggedError) |
| Time | Clock, Duration, DateTime, Cron, Schedule |
| Collections | Array, Chunk, HashMap, HashSet, Record, Option |
| One producer, many consumers | PubSub |
| Work queue | Queue |
| Pull streams | Stream / Sink / Channel (low-level) |
| Atomic multi-ref updates | Effect.tx + TxRef / TxQueue / … |
| HTTP client/server | effect/unstable/http + @effect/platform-* |
| Schema-first HTTP API | effect/unstable/httpapi |
| SQL | effect/unstable/sql + @effect/sql-* |
| LLM / tools | effect/unstable/ai + @effect/ai-* |
| Tests | @effect/vitest, effect/testing |
Every stable module: modules-stable.md. Every unstable area: modules-unstable.md.
Verification
- Typecheck
Effect<A, E, R>, layers, Schema encoded/type sides, RC names. @effect/vitest@rc:it.effect, TestClock, Exit/Result, per-testEffect.providewhen isolation matters.- Schema: valid/invalid input, defaults, excess keys, classes, tagged errors, JSON Schema.
- Migration scan: v3 imports,
Either,FiberRef, old catch/fork/runtime/Schema APIs.