effect

Guides building production TypeScript applications with Effect v4 services, layers, schemas, and streams.

Updated Sep 5, 2023
One-click install
npx skills add https://github.com/eyenalxai/dotfiles --skill effect-eyenalxai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: effect
Source: https://github.com/eyenalxai/dotfiles/tree/main/.agents/skills/effect
Command: npx skills add https://github.com/eyenalxai/dotfiles --skill effect-eyenalxai

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires effect, and includes references (resource) components.

What problem does it solve? Writing production-grade TypeScript with Effect v4 requires choosing correctly among many APIs—services, layers, schemas, schedules, caches, streams, and HTTP clients—and misusing them leads to fragile retries, hand-rolled caches, flaky tests, and untyped errors. This Skill provides opinionated, branch-specific guidance so Effect code follows current v4 conventions from the start. ## Core Features & Use Cases - Branch-specific reference routing: Directs the AI to read only the relevant reference file (schema, services/layers, config, scheduling, caching, streams, HTTP clients, or testing) based on the task. - Production defaults and anti-patterns: Enforces conventions like Effect.fn operation boundaries, Schema.TaggedError for typed failures, Config instead of process.env, and TestClock instead of real sleeps, with explicit Do Nots. - Use Case: When implementing a polling worker that calls a rate-limited provider API, the Skill guides you to use Schedule with jittered backoff, retryAfterMs-aware delays, typed pass failures, and Cache for deduplicating concurrent lookups. ## Quick Start Use the effect skill to implement a new service with a layer, typed errors, and retry logic in my Effect v4 TypeScript project.

Frequently Asked Questions about effect

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

FAQPage Schema
How do I define services and layers in Effect v4?

Define a service tag with Context.Service<Service, Interface>(), build the implementation with Layer.effect(Service, Effect.gen(...)), and return Service.of({ ... }). Public methods should use Effect.fn("Domain.operation") for tracing and error boundaries.

How do I retry failed Effect operations with backoff?

Use Effect.retry with a Schedule such as Schedule.exponential("100 millis") combined with Schedule.jittered and Schedule.upTo({ times: 5 }). For provider errors carrying retryAfterMs, use Schedule.modifyDelay to take the larger of backoff and provider delay.

Should I use Schema.TaggedError or custom error classes in Effect?

Use Schema.TaggedError for typed Effect errors; it is the explicit class exception for error modeling. Avoid hand-rolled _tag error classes, and map infrastructure failures into domain-specific tagged errors at service boundaries.

When should I use Cache versus Effect.cached in Effect?

Use Cache.make or Cache.makeWith for keyed lookups needing TTL, capacity bounds, and concurrent dedupe of in-flight requests. Use Effect.cached or Effect.cachedWithTTL only for memoizing a single effect result with no key.

How do I test Effect code that uses time and sleeps?

Use TestClock.setTime or TestClock.adjust instead of real sleeping, and fork sleeping effects before advancing the clock. Replace arbitrary Effect.sleep in tests with deterministic synchronization primitives like Deferred, Queue, Latch, or Ref.

When should I use raw fetch instead of Effect HttpClient?

Raw fetch is reasonable for browser or edge constraints, platform transports, or libraries avoiding unstable Effect HTTP modules. Keep it inside an adapter service, wire AbortSignal from Effect.tryPromise, classify status before decoding, and decode responses with Schema.