effect

Build production TypeScript applications with Effect v4 workflows, services, layers, and schemas.

2.4k|538|Updated Nov 19, 2020
Ready to run
npx skills add https://github.com/supabase/cli --skill effect-supabase
💬 Prompt for ChatGPT / Claude Chat▼
Please help me install this Agent Skill.
Skill: effect
Source: https://github.com/supabase/cli/tree/main/.agents/skills/effect
Command: npx skills add https://github.com/supabase/cli --skill effect-supabase

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? This Skill provides definitive guidance for implementing production-grade TypeScript applications using Effect v4. It eliminates confusion about API choices, service patterns, error handling, and runtime wiring by establishing opinionated conventions aligned with current Effect 4.0.0 APIs. ## Core Features & Use Cases - Service & Layer Architecture: Define typed services with Context.Service, build layers with deterministic composition, and wire runtime dependencies. - Schema-Driven Data Modeling: Model records, variants, errors, and boundary contracts using Schema.Struct, Schema.TaggedUnion, and Schema.TaggedError. - Async Workflows: Compose workflows with Effect.gen, manage retry/repeat policies with Schedule, handle streams for event sources, and build HTTP clients with typed error recovery. - Use Case: You are building a backend service that reads configuration from environment variables, calls external APIs with retry logic, caches expensive lookups, validates incoming JSON against schemas, and logs structured errors. This Skill guides schema construction, Config recipes, Cache strategies, HttpClient setup, and test stubs. ## Quick Start Read the branch chooser in SKILL.md to find the matching reference file for your task—if you are working with database schemas and validation, start with SCHEMA.md; if you need retry and polling policies, read SCHEDULING.md.

Frequently Asked Questions about effect

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

FAQPage Schema
How do I define a service in Effect v4?▼

Use Context.Service to create a typed service tag, implement it with Layer.effect and Effect.gen, and return the service with Service.of(). Export the service class, layer, and public interface so consumers depend only on the interface type.

What is the right way to model data with Effect schemas?▼

Use Schema.Struct with a same-name interface for records, Schema.TaggedUnion for boundary contracts, and Schema.TaggedError for typed failures. Decode unknown input with Schema.decodeUnknownEffect; use schema.makeEffect for construction with validation.

How do I retry an operation with backoff?▼

Use Effect.retry with Schedule.exponential for exponential backoff, add Schedule.jittered to avoid synchronized storms, and bound retries with Schedule.recurs or Schedule.upTo. Read SCHEDULING.md for rate-limit-aware policies and polling worker patterns.

When should I use Cache vs Effect.cached?▼

Use Cache.make for per-key lookups with TTL and capacity bounds; it deduplicates concurrent requests for the same key. Use Effect.cached or Effect.cachedWithTTL for a single memoized result with no key.

How do I test Effect services without real time?▼

Use TestClock to advance virtual time deterministically, avoid arbitrary sleeps, and synchronize with Deferred, Queue, or Latch. Build first-class test stubs by extending the service interface and using Layer.effectContext to wire both production and test implementations.

What is the difference between Effect.fn and Effect.gen?▼

Effect.gen composes workflows with yield statements; Effect.fn wraps a generator function to apply tracing, error classification, or retry around the entire call. Use Effect.fn for public service methods and non-trivial internal operations.