EffectPatterns

PaulJPhilpMIT更新放缓

汇集 Effect-TS 实战设计模式的社区知识库,帮 TypeScript 开发者用函数式编程方式组织副作用与依赖注入。

A community-driven knowledge base of practical patterns for Effect-TS.

v0.13.0发布于 2026-02-27 19:41 UTC806star28fork同步于 2026-11-07 07:33 UTC

怎么上手

从 README 代码块原样提取,可能是其中一种安装方式
bun add -g @effect-patterns/ep-cli
硬件要求

README 没有说明硬件要求。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

这个项目的说明还在生成中,先参考下面「最近发版」和 README。

最近发版

5 个版本v0.13.0
  1. v0.13.0最新正式版2026-02-27 · 2026-02-27 19:41 UTC
  2. v0.12.42026-02-27 · 2026-02-27 19:36 UTC
    查看更新说明

    What's Changed

  3. v0.12.2v0.12.2 — Populate all DB tables, remove jobs tables2026-02-11 · 2026-02-11 17:42 UTC
    查看更新说明

    Database Population

    All 5 database tables are now fully populated:

    TableRows
    effect_patterns309
    application_patterns16
    pattern_relations455
    skills16
    skill_patterns309
    • Fixed category extraction: 38 subcategory dirs → 16 top-level categories
    • Linked all 309 patterns to their application_pattern_id
    • Populated 455 pattern relations from MDX related: frontmatter
    • Generated 16 skills (one per category)

    Removed Jobs Tables

    Dropped unused jobs and pattern_jobs tables (Jobs-to-be-Done framework) from schema, codebase, and database. Migration 0004 handles the DROP.

    Content & Documentation

    • Added rule: frontmatter to 77 schema patterns missing it
    • New docs/DATABASE_ARCHITECTURE.md — canonical database reference
    • Updated CLAUDE.md and regenerated README.md

    New Scripts

    • scripts/seed-application-patterns.ts — seed 16 categories
    • scripts/add-missing-rules.ts — add missing rule frontmatter
    • Enhanced scripts/sync-patterns-from-mdx.ts with linking and relations

    Package Versions

    • effect-patterns-hub 0.12.2
    • @effect-patterns/toolkit 0.4.2
    • @effect-patterns/ep-admin 0.2.2
  4. v0.12.1v0.12.1 — QA Pipeline + 15 Pattern Content Fixes2026-02-10 · 2026-02-10 22:04 UTC
    查看更新说明

    QA Pipeline

    New validation pipeline that checks every published pattern:

    • Frontmatter validation (id, title, skill level, tags)
    • Structure detection (supports both old and new pattern formats)
    • TypeScript type-checking of every code block via bun build

    Content Fixes

    15 pattern files fixed across concurrency, schema, error-management, streams, scheduling, and tooling:

    • Fixed broken frontmatter in concurrency-fork-basics
    • Changed pseudocode blocks from typescript to text fencing where appropriate
    • Wrapped yield* calls in proper Effect.gen generators inside catchAll, catchTag, orElse callbacks
    • Scoped duplicate declarations in linting/type-error example blocks
    • Fixed await outside async and yield* outside generator contexts

    All 309 patterns now pass validation with 0 failures.

    Other Changes

    • @effect-patterns/toolkit 0.4.1: Added releaseVersion column to effectPatterns schema
    • @effect-patterns/ep-admin 0.2.1: Added gray-matter dependency, new QA validator module
    • New scripts/sync-patterns-from-mdx.ts utility for syncing patterns to database
  5. v0.12.0v0.12.0 — First npm Publish + 5 New Patterns2026-02-10 · 2026-02-10 22:04 UTC
    查看更新说明

    First npm Publish

    Prepared all four public packages for first npm publish:

    • @effect-patterns/toolkit 0.4.0
    • @effect-patterns/ep-cli 0.3.0
    • @effect-patterns/ep-shared-services 1.0.1
    • @effect-patterns/pipeline-state 1.1.1
    • @effect-patterns/mcp-server 0.7.7 patch release

    New Content

    5 new patterns: core-concepts-chunk-vs-array, error-management-extract-cause, observability-compose-metrics, resource-management-guarantee-cleanup, resource-management-runtime-vs-provide

    Security

    • MCP Streamable Auth: Enforced strict API key validation in streamable transport with constant-time comparison
    • OAuth/PKCE Hardening: Fixed PKCE verification flow and required verifier validation for OAuth code exchange
    • OAuth Client Auth: Enforced configured client_id/client_secret validation for token exchange
    • DB Mutation Routes: Locked down destructive migration/reset/import endpoints behind admin authentication

    Improvements

    • Generator: Rewrote README generator to read patterns from disk instead of querying PostgreSQL, fixing README links
    • CI Workflow: Fixed stale services/mcp-server path in CI build step
    • Package Metadata: Added repository, bugs, homepage, engines, publishConfig to all packages
    • Toolkit: Excluded test artifacts from npm package
    • Pipeline State: Updated @effect/schema dependency from 0.68 to 0.75

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    [!WARNING] This is an auto-generated file. Manual edits will be overwritten by the publishing pipeline. For project information, see ABOUT.md

    The Effect Patterns Hub

    A community-driven knowledge base of practical, goal-oriented patterns for building robust applications with Effect-TS.

    This repository is designed to be a living document that helps developers move from core concepts to advanced architectural strategies by focusing on the "why" behind the code.

    EffectTalk.dev — Browse all 300+ patterns, take guided learning tours, and run code examples in the browser. Built on this repo.

    Install the CLI to search, browse, and install patterns from your terminal:

    bun add -g @effect-patterns/ep-cli
    ep search "error handling"
    

    Looking for machine-readable rules for AI IDEs and coding agents? See the AI Coding Rules section below.

    Table of Contents

    Effect Patterns


    Getting Started

    Foundational patterns for your first steps with Effect-TS.

    PatternSkill LevelSummary
    Why Effect? Comparing Effect to Promise🟢 BeginnerUnderstand what Effect gives you that Promise doesn't: type-safe errors, dependency injection, and composability.
    Hello World: Your First Effect🟢 BeginnerCreate and run your very first Effect program using Effect.succeed and Effect.runSync.
    Transform Values with Effect.map🟢 BeginnerUse Effect.map to transform the success value of an Effect without changing its error or dependency types.
    Handle Your First Error with Effect.fail and catchAll🟢 BeginnerLearn how to create Effects that can fail and how to recover from those failures using Effect.fail and Effect.catchAll.
    Run Multiple Effects in Parallel with Effect.all🟢 BeginnerUse Effect.all to run multiple Effects at the same time and collect all their results.
    Retry a Failed Operation with Effect.retry🟢 BeginnerUse Effect.retry with a Schedule to automatically retry failed operations with customizable delays and limits.

    Core Concepts

    Essential building blocks for understanding and using Effect.

    PatternSkill LevelSummary
    Understand the Either Data Type🟢 BeginnerUse Either<E, A> to represent computations that can fail, allowing you to accumulate multiple errors instead of short-circuiting on the first one.
    Chaining Computations with flatMap🟢 BeginnerUse flatMap to chain together computations where each step may itself be effectful, optional, or error-prone.
    Combining Values with zip🟢 BeginnerUse zip to combine two computations, pairing their results together in Effect, Stream, Option, or Either.
    Comparing Data by Value with Data.struct🟢 BeginnerUse Data.struct to create immutable, structurally-typed objects that can be compared by value, not by reference.
    Comparing Data by Value with Structural Equality🟢 BeginnerUse Data.struct and Equal.equals to safely compare objects by their value instead of their reference, avoiding common JavaScript pitfalls.
    Conditional Branching with if, when, and cond🟢 BeginnerUse combinators like if, when, and cond to express conditional logic declaratively across Effect, Stream, Option, and Either.
    Converting from Nullable, Option, or Either🟢 BeginnerUse fromNullable, fromOption, and fromEither to convert nullable values, Option, or Either into Effects or Streams, enabling safe and composable interop.
    Create Pre-resolved Effects with succeed and fail🟢 BeginnerUse Effect.succeed(value) to create an Effect that immediately succeeds with a value, and Effect.fail(error) for an Effect that immediately fails.
    Creating from Collections🟢 BeginnerUse fromIterable and fromArray to create Streams or Effects from arrays, iterables, or other collections, enabling batch and streaming operations.
    Creating from Synchronous and Callback Code🟢 BeginnerUse sync and async to lift synchronous or callback-based computations into Effect, enabling safe and composable interop with legacy code.
    Execute Asynchronous Effects with Effect.runPromise🟢 BeginnerUse Effect.runPromise at the 'end of the world' to execute an asynchronous Effect and get its result as a JavaScript Promise.
    Execute Synchronous Effects with Effect.runSync🟢 BeginnerUse Effect.runSync at the 'end of the world' to execute a purely synchronous Effect and get its value directly.
    Filtering Results with filter🟢 BeginnerUse filter to keep or discard results based on a predicate, across Effect, Stream, Option, and Either.
    Lifting Errors and Absence with fail, none, and left🟢 BeginnerUse fail, none, and left to represent errors or absence in Effect, Option, or Either, making failures explicit and type-safe.
    Lifting Values with succeed, some, and right🟢 BeginnerUse succeed, some, and right to lift plain values into Effect, Option, or Either, making them composable and type-safe.
    Understand the Option Data Type🟢 BeginnerUse Option to explicitly represent a value that may or may not exist, eliminating null and undefined errors.
    Set Up a New Effect Project🟢 BeginnerInitialize a new Node.js project with the necessary TypeScript configuration and Effect dependencies to start building.
    Solve Promise Problems with Effect🟢 BeginnerUnderstand how Effect solves the fundamental problems of native Promises, such as untyped errors, lack of dependency injection, and no built-in cancellation.
    Transform Effect Values with map and flatMap🟢 BeginnerUse Effect.map for synchronous transformations and Effect.flatMap to chain operations that return another Effect.
    Transforming Values with map🟢 BeginnerUse map to transform the result of an Effect, Stream, Option, or Either in a declarative, type-safe way.
    Understand that Effects are Lazy Blueprints🟢 BeginnerAn Effect is a lazy, immutable blueprint describing a computation, which does nothing until it is explicitly executed by a runtime.
    When to Use Chunk vs Array🟢 BeginnerChoose Chunk for Effect pipelines, Stream results, and immutable collection operations; use Array when interfacing with existing APIs.
    Understand the Three Effect Channels (A, E, R)🟢 BeginnerLearn about the three generic parameters of an Effect: the success value (A), the failure error (E), and the context requirements (R).
    Use .pipe for Composition🟢 BeginnerUse the .pipe() method to chain multiple operations onto an Effect in a readable, top-to-bottom sequence.
    Working with Immutable Arrays using Data.array🟢 BeginnerUse Data.array to create immutable, type-safe arrays that support value-based equality and safe functional operations.
    Working with Tuples using Data.tuple🟢 BeginnerUse Data.tuple to create immutable, type-safe tuples that support value-based equality and pattern matching.
    Wrap Asynchronous Computations with tryPromise🟢 BeginnerUse Effect.tryPromise to safely convert a function that returns a Promise into an Effect, capturing rejections in the error channel.
    Wrap Synchronous Computations with sync and try🟢 BeginnerUse Effect.sync for non-throwing synchronous code and Effect.try for synchronous code that might throw an exception.
    Wrapping Synchronous and Asynchronous Computations🟢 BeginnerUse try and tryPromise to safely wrap synchronous or asynchronous computations that may throw or reject, capturing errors in the Effect world.
    Write Sequential Code with Effect.gen🟢 BeginnerUse Effect.gen with yield* to write sequential, asynchronous code in a style that looks and feels like familiar async/await.
    Access Configuration from the Context🟡 IntermediateAccess your type-safe configuration within an Effect.gen block by yielding the Config object you defined.
    Beyond the Date Type - Real World Dates, Times, and Timezones🟡 IntermediateUse the Clock service for testable access to the current time and prefer immutable primitives for storing and passing timestamps.
    Control Flow with Conditional Combinators🟡 IntermediateUse combinators like Effect.if, Effect.when, and Effect.cond to handle conditional logic in a declarative, composable way.
    Define a Type-Safe Configuration Schema🟡 IntermediateUse Effect.Config primitives to define a schema for your application's configuration, ensuring type-safety and separation from code.
    Handling Errors with catchAll, orElse, and match🟡 IntermediateUse catchAll, orElse, and match to recover from errors, provide fallbacks, or transform errors in Effect, Either, and Option.
    Understand Ref for Atomic State🟡 IntermediateUse Ref to model shared, mutable state in a concurrent environment, ensuring all updates are atomic and free of race conditions.
    Mapping and Chaining over Collections with forEach and all🟡 IntermediateUse forEach and all to apply effectful functions to collections and combine the results, enabling batch and parallel processing.
    Modeling Effect Results with Exit🟡 IntermediateUse Exit<E, A> to represent the result of running an Effect, capturing both success and failure (including defects) in a type-safe way.
    Modeling Tagged Unions with Data.case🟡 IntermediateUse Data.case to create tagged unions (algebraic data types) for robust, type-safe domain modeling and pattern matching.
    Optional Pattern 1: Handling None and Some Values🟡 IntermediateUse Effect's Option type to safely handle values that may not exist, avoiding null/undefined bugs and enabling composable error handling.
    Process Streaming Data with Stream🟡 IntermediateUse Stream<A, E, R> to represent and process data that arrives over time, such as file reads, WebSocket messages, or paginated API results.
    Provide Configuration to Your App via a Layer🟡 IntermediateUse Config.layer(schema) to create a Layer that provides your configuration schema to the application's context.
    Redact and Handle Sensitive Data🟡 IntermediateUse Redacted to securely handle sensitive data, ensuring secrets are not accidentally logged or exposed.
    Representing Time Spans with Duration🟡 IntermediateUse the Duration data type to represent time intervals in a type-safe, human-readable, and composable way.
    Sequencing with andThen, tap, and flatten🟡 IntermediateUse andThen, tap, and flatten to sequence computations, run side effects, and flatten nested structures in Effect, Stream, Option, and Either.
    Type Classes for Equality, Ordering, and Hashing with Data.Class🟡 IntermediateUse Data.Class to derive and implement type classes for equality, ordering, and hashing, enabling composable and type-safe abstractions.
    Understand Layers for Dependency Injection🟡 IntermediateA Layer is a blueprint that describes how to build a service, detailing its own requirements and any potential errors during its construction.
    Use Chunk for High-Performance Collections🟡 IntermediateUse Chunk as a high-performance, immutable alternative to JavaScript's Array, especially for data processing pipelines.
    Work with Arbitrary-Precision Numbers using BigDecimal🟡 IntermediateUse BigDecimal for arbitrary-precision decimal arithmetic, avoiding rounding errors and loss of precision in financial or scientific calculations.
    Work with Dates and Times using DateTime🟡 IntermediateUse DateTime for immutable, time-zone-aware date and time values, enabling safe and precise time calculations.
    Work with Immutable Sets using HashSet🟡 IntermediateUse HashSet to model immutable, high-performance sets for efficient membership checks and set operations.
    Create a Reusable Runtime from Layers🟠 AdvancedCompile your application's layers into a reusable Runtime object to efficiently execute multiple effects that share the same context.
    Understand the Cause Data Type🟠 AdvancedUse Cause to get rich, structured information about errors and failures, including defects, interruptions, and error traces.
    Optional Pattern 2: Optional Chaining and Composition🟠 AdvancedChain optional values across multiple steps with composable operators, enabling elegant data flow through systems with missing values.

    Error Management

    Patterns for type-safe, composable error handling.

    PatternSkill LevelSummary
    Checking Option and Either Cases🟢 BeginnerUse isSome, isNone, isLeft, and isRight to check Option and Either cases for simple, type-safe branching.
    Matching on Success and Failure with match🟢 BeginnerUse match to handle both success and failure cases in a single, declarative place for Effect, Option, and Either.
    Pattern Match on Option and Either🟢 BeginnerUse declarative match() combinators to handle optional and error-prone values
    Your First Error Handler🟢 BeginnerLearn the basics of handling errors in Effect with catchAll and catchTag.
    Conditionally Branching Workflows🟡 IntermediateUse predicate-based operators like Effect.filter and Effect.if to make decisions and control the flow of your application based on runtime values.
    Control Repetition with Schedule🟡 IntermediateUse Schedule to create composable, stateful policies that define precisely how an effect should be repeated or retried.
    Effectful Pattern Matching with matchEffect🟡 IntermediateUse matchEffect to perform effectful branching based on success or failure, enabling rich workflows in the Effect world.
    Error Handling Pattern 1: Accumulating Multiple Errors🟡 IntermediateCollect multiple errors across operations instead of failing on first error, enabling comprehensive error reporting and validation.
    Extract Failures and Defects from a Cause🟡 IntermediateUse Cause.failures and Cause.defects to inspect a Cause and handle expected failures differently from unexpected defects.
    Handle Errors with catchTag, catchTags, and catchAll🟡 IntermediateUse catchTag for type-safe recovery from specific tagged errors, and catchAll to recover from any possible failure.
    Handle Flaky Operations with Retries and Timeouts🟡 IntermediateUse Effect.retry and Effect.timeout to build resilience against slow or intermittently failing operations, such as network requests.
    Handling Specific Errors with catchTag and catchTags🟡 IntermediateUse catchTag and catchTags to recover from or handle specific error types in the Effect failure channel, enabling precise and type-safe error recovery.
    Mapping Errors to Fit Your Domain🟡 IntermediateUse Effect.mapError to transform specific, low-level errors into more general domain errors, creating clean architectural boundaries.
    Matching Tagged Unions with matchTag and matchTags🟡 IntermediateUse matchTag and matchTags to pattern match on specific tagged union cases, enabling precise and type-safe branching.
    Retry Operations Based on Specific Errors🟡 IntermediateUse Effect.retry and predicate functions to selectively retry an operation only when specific, recoverable errors occur.
    Scheduling Pattern 2: Implement Exponential Backoff for Retries🟡 IntermediateUse exponential backoff with jitter to retry failed operations with increasing delays, preventing resource exhaustion and cascade failures in distributed systems.
    Error Handling Pattern 2: Error Propagation and Chains🟠 AdvancedPropagate errors through effect chains with context, preserving error information and enabling recovery at appropriate layers.
    Error Handling Pattern 3: Custom Error Strategies🟠 AdvancedBuild domain-specific error types and recovery strategies that align with business logic and provide actionable error information.
    Handle Unexpected Errors by Inspecting the Cause🟠 AdvancedUse Effect.catchAllCause or Effect.runFork to inspect the Cause of a failure, distinguishing between expected errors (Fail) and unexpected defects (Die).

    Resource Management

    Safe acquisition, use, and release of resources.

    PatternSkill LevelSummary
    Safely Bracket Resource Usage with acquireRelease🟢 BeginnerUse Effect.acquireRelease to guarantee a resource's cleanup logic runs, even if errors or interruptions occur.
    Guarantee Cleanup Even on Failure🟢 BeginnerEffect.acquireRelease and Effect.scoped ensure that release logic runs even when the use phase fails or is interrupted.
    Compose Resource Lifecycles with Layer.merge🟡 IntermediateCombine multiple resource-managing layers, letting Effect automatically handle the acquisition and release order.
    Create a Service Layer from a Managed Resource🟡 IntermediateUse Layer.scoped with Effect.Service to transform a managed resource into a shareable, application-wide service.
    Handle Resource Timeouts🟡 IntermediateSet timeouts on resource acquisition and usage to prevent hanging operations.
    Pool Resources for Reuse🟡 IntermediateCreate and manage a pool of reusable resources like database connections or workers.
    Choose Between ManagedRuntime and Effect.provide🟡 IntermediateUse ManagedRuntime when running many effects with the same layers (servers, workers); use Effect.provide for one-off scripts.
    Create a Managed Runtime for Scoped Resources🟠 AdvancedUse Layer.launch to safely manage the lifecycle of layers containing scoped resources, ensuring finalizers are always run.
    Manage Hierarchical Resources🟠 AdvancedManage parent-child resource relationships where children must be released before parents.
    Manually Manage Lifecycles with Scope🟠 AdvancedUse Scope directly to manage complex resource lifecycles or when building custom layers.

    Concurrency

    Patterns for parallel and concurrent execution.

    PatternSkill LevelSummary
    Race Effects and Handle Timeouts🟢 BeginnerRace multiple effects to get the fastest result, or add timeouts to prevent hanging operations.
    Understanding Fibers🟢 BeginnerLearn what fibers are, how they differ from threads, and why they make Effect powerful for concurrent programming.
    Your First Parallel Operation🟢 BeginnerRun multiple effects in parallel with Effect.all and understand when to use parallel vs sequential execution.
    Fork Background Work🟢 BeginnerUse Effect.fork to run work in the background while your main code continues.
    Concurrency Pattern 1: Coordinate Async Operations with Deferred🟡 IntermediateUse Deferred to coordinate async operations where multiple fibers wait for a single event to complete, enabling producer-consumer patterns and async signaling without polling.
    Concurrency Pattern 2: Rate Limit Concurrent Access with Semaphore🟡 IntermediateUse Semaphore to limit the number of concurrent operations, enabling connection pooling, API rate limiting, and controlled resource access without overload.
    Concurrency Pattern 3: Coordinate Multiple Fibers with Latch🟡 IntermediateUse Latch to synchronize multiple fibers, enabling patterns like coordinating N async tasks, fan-out/fan-in, and barrier synchronization.
    Concurrency Pattern 4: Distribute Work with Queue🟡 IntermediateUse Queue to decouple producers and consumers, enabling work distribution, pipeline stages, and backpressure handling across concurrent fibers.
    Concurrency Pattern 5: Broadcast Events with PubSub🟡 IntermediateUse PubSub to broadcast events to multiple subscribers, enabling event-driven architectures and fan-out patterns without direct coupling.
    Concurrency Pattern 6: Race and Timeout Competing Effects🟡 IntermediateUse race and timeout to compete multiple effects and enforce deadlines, enabling timeout handling and choosing fastest result.
    Manage Shared State Safely with Ref🟡 IntermediateUse Ref to model shared, mutable state in a concurrent environment, ensuring all updates are atomic and free of race conditions.
    Process a Collection in Parallel with Effect.forEach🟡 IntermediateUse Effect.forEach with the concurrency option to process a collection of items in parallel with a fixed limit, preventing resource exhaustion.
    Race Concurrent Effects for the Fastest Result🟡 IntermediateUse Effect.race to run multiple effects concurrently and proceed with the result of the one that succeeds first, automatically interrupting the others.
    Run Independent Effects in Parallel with Effect.all🟡 IntermediateUse Effect.all to run multiple independent effects concurrently and collect all their results into a single tuple.
    Add Caching by Wrapping a Layer🟠 AdvancedImplement caching by creating a new layer that wraps a live service, intercepting method calls to add caching logic without modifying the original service.
    Decouple Fibers with Queues and PubSub🟠 AdvancedUse Queue for point-to-point work distribution and PubSub for broadcast messaging to enable safe, decoupled communication between concurrent fibers.
    Execute Long-Running Apps with Effect.runFork🟠 AdvancedUse Effect.runFork at the application's entry point to launch a long-running process as a detached fiber, allowing for graceful shutdown.
    Implement Graceful Shutdown for Your Application🟠 AdvancedUse Effect.runFork and listen for OS signals (SIGINT, SIGTERM) to trigger a Fiber.interrupt, ensuring all resources are safely released.
    Manage Resource Lifecycles with Scope🟠 AdvancedUse Scope for fine-grained, manual control over resource lifecycles, ensuring cleanup logic (finalizers) is always executed.
    Poll for Status Until a Task Completes🟠 AdvancedUse Effect.race to run a repeating polling effect alongside a main task, automatically stopping the polling when the main task finishes.
    Run Background Tasks with Effect.fork🟠 AdvancedUse Effect.fork to start a computation in a background fiber, allowing the parent fiber to continue its work without waiting.
    State Management Pattern 1: Synchronized Reference with SynchronizedRef🟠 AdvancedUse SynchronizedRef to safely share mutable state across concurrent fibers, with atomic updates and guaranteed consistency.
    State Management Pattern 2: Observable State with SubscriptionRef🟠 AdvancedBuild observable state that notifies subscribers on changes, enabling reactive patterns and state-driven architecture.
    Understand Fibers as Lightweight Threads🟠 AdvancedA Fiber is a lightweight, virtual thread managed by the Effect runtime, enabling massive concurrency on a single OS thread without the overhead of traditional threading.

    Streams

    Processing sequences of values over time.

    PatternSkill LevelSummary
    Running and Collecting Stream Results🟢 BeginnerLearn the different ways to run a stream and collect its results: runCollect, runForEach, runDrain, and more.
    Stream Pattern 1: Transform Streams with Map and Filter🟢 BeginnerUse Stream.map and Stream.filter to transform and select stream elements, enabling data pipelines that reshape and filter data in flight.
    Stream vs Effect - When to Use Which🟢 BeginnerUnderstand when to use Effect (single value) vs Stream (sequence of values) for your use case.
    Take and Drop Stream Elements🟢 BeginnerControl how many stream elements to process using take, drop, takeWhile, and dropWhile.
    Your First Stream🟢 BeginnerCreate your first Effect Stream and understand what makes streams different from regular arrays.
    Sink Pattern 1: Batch Insert Stream Records into Database🟡 IntermediateUse Sink to batch stream records and insert them efficiently into a database in groups, rather than one-by-one, for better performance and resource usage.
    Sink Pattern 2: Write Stream Events to Event Log🟡 IntermediateUse Sink to append stream events to an event log with metadata and causal ordering, enabling event sourcing and audit trail patterns.
    Sink Pattern 3: Write Stream Lines to File🟡 IntermediateUse Sink to write stream data as lines to a file with buffering for efficiency, supporting log files and line-oriented formats.
    Sink Pattern 4: Send Stream Records to Message Queue🟡 IntermediateUse Sink to publish stream records to a message queue with partitioning, batching, and acknowledgment handling for distributed systems.
    Sink Pattern 5: Fall Back to Alternative Sink on Failure🟡 IntermediateUse Sink to attempt writing to a primary destination, and automatically fall back to an alternative destination if the primary fails, enabling progressive degradation and high availability.
    Sink Pattern 6: Retry Failed Stream Operations🟡 IntermediateUse Sink with configurable retry policies to automatically retry failed operations with exponential backoff, enabling recovery from transient failures without losing data.
    Stream Pattern 2: Merge and Combine Multiple Streams🟡 IntermediateUse Stream.merge, Stream.concat, and Stream.mergeAll to combine multiple streams into a single stream, enabling multi-source data aggregation.
    Stream Pattern 3: Control Backpressure in Streams🟡 IntermediateUse Stream throttling, buffering, and chunk operations to manage backpressure, preventing upstream from overwhelming downstream consumers.
    Stream Pattern 4: Stateful Operations with Scan and Fold🟡 IntermediateUse Stream.scan and Stream.fold to maintain state across stream elements, enabling cumulative operations, counters, aggregations, and stateful transformations.
    Stream Pattern 5: Grouping and Windowing Streams🟠 AdvancedUse grouping and windowing to organize streams by key or time window, enabling batch operations and temporal aggregations.
    Stream Pattern 6: Resource Management in Streams🟠 AdvancedProperly manage resources (connections, files, memory) in streams using acquire/release patterns and ensuring cleanup on error or completion.
    Stream Pattern 7: Error Handling in Streams🟠 AdvancedHandle errors gracefully in streams with recovery strategies, resuming after failures, and maintaining stream integrity.
    Stream Pattern 8: Advanced Stream Transformations🟠 AdvancedApply complex transformations across streams including custom operators, effect-based transformations, and composition patterns.

    Scheduling

    Patterns for retries, repetition, and time-based execution.

    PatternSkill LevelSummary
    Retry Failed Operations🟢 BeginnerUse Effect.retry with Schedule to automatically retry operations that fail.
    Your First Schedule🟢 BeginnerLearn the basics of scheduling in Effect - retry operations and repeat them on intervals.
    Scheduling Pattern 1: Repeat an Effect on a Fixed Interval🟡 IntermediateUse Schedule.fixed to repeat an effect at regular intervals, enabling polling, health checks, and periodic background tasks without busy-waiting or manual timing logic.
    Scheduling Pattern 3: Schedule Tasks with Cron Expressions🟡 IntermediateUse cron expressions to schedule tasks at specific times and intervals, enabling calendar-based scheduling with timezone support.
    Scheduling Pattern 4: Debounce and Throttle Execution🟡 IntermediateUse debouncing and throttling to limit how often effects execute, preventing runaway operations and handling rapid event sequences.
    Scheduling Pattern 5: Advanced Retry Chains and Circuit Breakers🟠 AdvancedBuild sophisticated retry chains with circuit breakers, fallbacks, and complex failure patterns for production-grade reliability.

    Domain Modeling

    Building robust domain models with Effect and Schema.

    PatternSkill LevelSummary
    Create Type-Safe Errors🟢 BeginnerDefine domain-specific errors using Data.TaggedError for type-safe error handling.
    Handle Missing Values with Option🟢 BeginnerUse Option to explicitly model values that might not exist, avoiding null/undefined bugs.
    Your First Domain Model🟢 BeginnerCreate a simple domain model using TypeScript interfaces and Effect to represent your business entities.
    Accumulate Multiple Errors with Either🟡 IntermediateUse Either<E, A> to represent computations that can fail, allowing you to accumulate multiple errors instead of short-circuiting on the first one.
    Avoid Long Chains of .andThen; Use Generators Instead🟡 IntermediatePrefer Effect.gen over long chains of .andThen for sequential logic to improve readability and maintainability.
    Define Contracts Upfront with Schema🟡 IntermediateUse Schema to define the types for your data models and function signatures before writing the implementation, creating clear, type-safe contracts.
    Define Type-Safe Errors with Data.TaggedError🟡 IntermediateCreate custom, type-safe error classes by extending Data.TaggedError to make error handling robust, predictable, and self-documenting.
    Distinguish 'Not Found' from Errors🟡 IntermediateUse Effect<Option> to clearly distinguish between a recoverable 'not found' case (None) and a true failure (Fail).
    Model Optional Values Safely with Option🟡 IntermediateUse Option to explicitly represent a value that may or may not exist, eliminating null and undefined errors.
    Model Validated Domain Types with Brand🟡 IntermediateUse Brand to turn primitive types like string or number into specific, validated domain types like Email or PositiveInt, making illegal states unrepresentable.
    Modeling Validated Domain Types with Brand🟡 IntermediateUse Brand to create domain-specific types from primitives, making illegal states unrepresentable and preventing accidental misuse.
    Parse and Validate Data with Schema.decode🟡 IntermediateUse Schema.decode(schema) to create an Effect that parses and validates unknown data, which integrates seamlessly with Effect's error handling.
    Transform Data During Validation with Schema🟡 IntermediateUse Schema.transform to safely convert data from one type to another during the parsing phase, such as from a string to a Date.
    Use Effect.gen for Business Logic🟡 IntermediateEncapsulate sequential business logic, control flow, and dependency access within Effect.gen for improved readability and maintainability.
    Validating and Parsing Branded Types🟡 IntermediateUse Schema and Brand together to validate and parse branded types at runtime, ensuring only valid values are constructed.

    Schema

    Validation, parsing, and transformation with @effect/schema.

    PatternSkill LevelSummary
    Adding Descriptions for AI Context🟢 BeginnerYou define a schema with field names like confidence or category, but the LLM doesn't understand the nuance of what you want. It might interpret fields differently than intended, leading to...
    Array Validation🟢 BeginnerYou receive a list of items and need to validate each one. Without schema validation, you'd loop through and check each item manually. You need to define what valid array items look like and validate...
    Basic AI Output Schema🟢 BeginnerYou're using an LLM to generate structured data. Without a schema, you get unpredictable JSON—missing fields, wrong types, hallucinated keys. You need to define a schema that tells the LLM exactly...
    Basic AI Response Parsing🟢 BeginnerYou've called an LLM with a JSON schema, but the response is still unknown. The model might have hallucinated extra fields, used wrong types, or returned malformed JSON despite your instructions....
    Basic API Response Decoding🟢 BeginnerYou're fetching data from an external API. The response is unknown at runtime. TypeScript's type assertions (as User) are lies—they don't validate anything. A malformed API response will silently...
    Basic Async Validation with Schema.filterEffect🟢 BeginnerYou have sync validation rules (format, length) handled by schema. But some rules require async operations: checking a username isn't taken, verifying a discount code is valid, calling an external...
    Basic Form Validation🟢 BeginnerYou have a form with multiple fields—name, email, age. Validation is scattered everywhere: inline JavaScript, backend checks, error messages don't match. You need a single source of truth for form...
    Basic JSON File Validation🟢 BeginnerYou have a JSON file on disk and need to read it, parse it, and validate the structure against a schema. Simply reading and parsing can produce runtime errors if the file is missing, corrupted, or...
    Basic Object Schemas🟢 BeginnerMost real data is objects with named fields. You need to define the expected shape, validate each field has the right type, and get a typed result. Without schema validation, you access properties...
    Basic Recursive Schemas with Schema.suspend🟢 BeginnerYou need to validate tree-like data: a node with children that are also nodes. Or linked lists where each item points to the next. Without recursion support, you can't express these structures—the...
    Basic Schema Transformations🟢 BeginnerYour application receives data in one shape but needs it in another. API returns a Unix timestamp; your domain uses Date objects. Form input arrives as strings; you need typed numbers. Database...
    Basic Union Types and Alternatives🟢 BeginnerYour API returns different shapes depending on context. A response could be a user profile OR an error message. A payment could succeed with a transaction ID OR fail with a reason. Without union...
    Collecting All Validation Errors🟢 BeginnerStandard validation stops at the first error: "Username is required". But users want to see ALL problems at once—missing fields, invalid formats, out-of-range values. Showing one error at a time...
    Custom Tagged Errors🟢 BeginnerYour application throws generic Error objects. When calling a function, you don't know what errors it might throw. Is it a validation error? Network timeout? Permission denied? Code that calls your...
    Date Validation and Parsing🟢 BeginnerDates arrive in many formats: ISO strings, Unix timestamps, Date objects. JavaScript's Date constructor silently accepts invalid input ("Invalid Date"). You need to parse dates safely and validate...
    Decode and Encode Data🟢 BeginnerYou receive data as JSON and need to convert it to typed objects. Later, you need to serialize those objects back to JSON for storage or API responses. Without a consistent approach, you write...
    Effect Schema vs Zod🟢 BeginnerYou're familiar with Zod (or similar libraries) and want to understand how Effect Schema differs. The syntax looks similar but Effect Schema offers capabilities Zod doesn't have. You need a quick...
    Email Address Validation🟢 BeginnerYou're accepting email addresses from user input or API requests. A simple string type tells you nothing—users submit "not-an-email", "@@invalid", or empty strings. You need validation that checks...
    Enums and Literal Types🟢 BeginnerSome fields only accept specific values: status is "active" or "inactive", role is "admin", "user", or "guest". Using Schema.String allows any string, letting invalid values slip through. You need to...
    Environment Variables with Schema Validation🟢 BeginnerEnvironment variables power your application—database URLs, API keys, ports. But they're just strings. You load them with process.env.DATABASE_URL, hoping it exists and is valid. No type safety, no...
    Extending and Adding Fields to Schemas🟢 BeginnerYou have a base schema (User) and need variants with additional fields (AdminUser, PremiumUser). Copy-pasting the schema creates maintenance burden—change one field and you update three schemas. You...
    Handling Decode Failures🟢 BeginnerYou're decoding API responses with a Schema, but validation sometimes fails. You need to know why it failed so you can decide: retry, use a default, log it, or fail explicitly.
    Handling Malformed AI Outputs🟢 BeginnerAn LLM returns malformed JSON or fields that don't match your schema. The parse fails and the operation stops. You need graceful recovery strategies: provide sensible defaults, extract partial data,...
    Handling Parse Errors🟢 BeginnerWhen validation fails, you need to know what went wrong. The default parse error is detailed but hard to read. You need to extract useful error messages for logging, displaying to users, or debugging.
    Nested Object Schemas🟢 BeginnerReal data has nested objects: a user has an address, an order has items with products. You need to define schemas for complex structures where objects contain other objects, and validate the entire...
    Number Validation and Refinements🟢 BeginnerNumbers need constraints: prices must be positive, ages must be integers, percentages must be 0-100. JavaScript's number type accepts any numeric value. You need runtime validation to catch invalid...
    Optional and Nullable Fields🟢 BeginnerNot all fields are required. Some are optional (may be missing), some are nullable (present but null), some accept both. You need to express these different optionality patterns while keeping types...
    String Validation and Refinements🟢 BeginnerRaw strings need constraints: minimum length for passwords, maximum length for tweets, email format, URL format. Without validation, invalid strings propagate through your system causing errors far...
    Tuple Schemas🟢 BeginnerSometimes you need fixed-length arrays where each position has a specific type. A coordinate is [x, y], an RGB color is [r, g, b], a range is [start, end]. Regular arrays allow any length. You need...
    URL Validation🟢 BeginnerYou accept URLs from users—as links, webhooks, or API endpoints. A string type doesn't validate that it's actually a valid URL. Users submit malformed URLs like "htp://example" or "not a url". You...
    UUID Validation (v4, v7)🟢 BeginnerYour API accepts IDs as strings, but there's no validation that they're actually valid UUIDs. Users submit malformed IDs, truncated strings, or wrong formats. You need to validate UUID format at...
    Validating Config Files🟢 BeginnerConfiguration files are often JSON and must be loaded and validated at application startup. Config files have specific requirements: certain fields are required, others are optional, and values must...
    Validating JSON Database Columns🟢 BeginnerDatabases store JSON data in columns (MySQL JSON, PostgreSQL JSONB, SQLite JSON), but the database itself doesn't enforce schema—any JSON is valid from the database's perspective. When you retrieve...
    Your First Schema🟢 BeginnerYou have unknown data—from an API, form, or file—and need to validate it has the right shape. Without schema validation, your code assumes data is correct and crashes later with cryptic errors. You...
    API Validation with Retry🟡 IntermediateAPIs are flaky. Network timeouts, rate limits, temporary service degradation—these happen. You validate the response with a schema, but what if the API is temporarily down?
    Async Validation (Username Availability)🟡 IntermediateSome validation requires checking a server: is this username available? Is this email already registered? Standard schema validation is synchronous—you can't check a database or API. You need to...
    Bidirectional API ↔ Domain ↔ DB Transformations🟡 IntermediateYour application lives in three worlds: API contracts (what clients expect), domain models (your business logic), and database schemas (how data persists). Each world has different requirements. The...
    Branded Types for Type-Safe IDs and Strings🟡 IntermediateYour domain has user IDs, product IDs, email addresses. They're all strings at runtime, but they mean different things. A function accepting string could receive any string—wrong ID format, email...
    Composable Configuration Layers🟡 IntermediateReal applications need configuration from multiple sources: default values, environment variables, config files, runtime overrides. Loading config becomes scattered across the codebase. Layers...
    Data Normalization and Canonical Forms🟡 IntermediateRaw data is messy: extra whitespace, inconsistent casing, duplicates, mixed formats. You receive product names with leading/trailing spaces, emails in different cases, phone numbers with various...
    Database Validation - Uniqueness, Foreign Keys, Constraints🟡 IntermediateA username must be unique in the database. A product reference must exist. An email can't belong to two accounts. These database constraints can't be validated with sync schemas. You need async...
    Decoding Nested API Responses🟡 IntermediateReal APIs rarely return flat objects. Responses are deeply nested: users have profiles, profiles have addresses, addresses have coordinates.
    Dependent Field Validation🟡 IntermediateForm fields depend on each other: password must match confirmation, checkout address must match billing address, date range end must be after start. Standard field-by-field validation can't check...
    Discriminated Unions with Type Narrowing🟡 IntermediateYou have a union of different event types. Without a discriminator field, checking which type it is means examining multiple fields or using instanceof checks. With a _tag or type discriminator,...
    Enums and Literal Types🟡 IntermediateYou need the LLM to pick from a specific set of values—like priority levels, categories, or statuses. Without constraints, the LLM might output variations ("high", "HIGH", "urgent", "priority:...
    Error Aggregation and Collection🟡 IntermediateForm has 10 fields. User makes mistakes in 5 of them. Current approach: show first error, user fixes it, resubmit, find next error, repeat 5 times. Bad UX. You need to collect all validation errors...
    [Error Recovery and Fallback Strategies](./c