EffectPatterns
A community-driven knowledge base of practical patterns for Effect-TS.
Install / Use
/learn @PaulJPhilp/EffectPatternsREADME
[!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
- Core Concepts
- Error Management
- Resource Management
- Concurrency
- Streams
- Scheduling
- Domain Modeling
- Schema
- Platform
- Building APIs
- Making HTTP Requests
- Building Data Pipelines
- Testing
- Observability
- Tooling & Debugging
Getting Started
Foundational patterns for your first steps with Effect-TS.
| Pattern | Skill Level | Summary | | :--- | :--- | :--- | | Why Effect? Comparing Effect to Promise | 🟢 Beginner | Understand what Effect gives you that Promise doesn't: type-safe errors, dependency injection, and composability. | | Hello World: Your First Effect | 🟢 Beginner | Create and run your very first Effect program using Effect.succeed and Effect.runSync. | | Transform Values with Effect.map | 🟢 Beginner | Use 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 | 🟢 Beginner | Learn 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 | 🟢 Beginner | Use Effect.all to run multiple Effects at the same time and collect all their results. | | Retry a Failed Operation with Effect.retry | 🟢 Beginner | Use 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.
| Pattern | Skill Level | Summary | | :--- | :--- | :--- | | Understand the Either Data Type | 🟢 Beginner | Use 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 | 🟢 Beginner | Use flatMap to chain together computations where each step may itself be effectful, optional, or error-prone. | | Combining Values with zip | 🟢 Beginner | Use zip to combine two computations, pairing their results together in Effect, Stream, Option, or Either. | | Comparing Data by Value with Data.struct | 🟢 Beginner | Use Data.struct to create immutable, structurally-typed objects that can be compared by value, not by reference. | | Comparing Data by Value with Structural Equality | 🟢 Beginner | Use 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 | 🟢 Beginner | Use combinators like if, when, and cond to express conditional logic declaratively across Effect, Stream, Option, and Either. | | Converting from Nullable, Option, or Either | 🟢 Beginner | Use 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 | 🟢 Beginner | Use 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 | 🟢 Beginner | Use 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 | 🟢 Beginner | Use 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 | 🟢 Beginner | Use 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 | 🟢 Beginner | Use Effect.runSync at the 'end of the world' to execute a purely synchronous Effect and get its value directly. | | Filtering Results with filter | 🟢 Beginner | Use 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 | 🟢 Beginner | Use 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 | 🟢 Beginner | Use succeed, some, and right to lift plain values into Effect, Option, or Either, making them composable and type-safe. | | Understand the Option Data Type | 🟢 Beginner | Use Option<A> to explicitly represent a value that may or may not exist, eliminating null and undefined errors. | | Set Up a New Effect Project | 🟢 Beginner | Initialize a new Node.js project with the necessary TypeScript configuration and Effect dependencies to start building. | | Solve Promise Problems with Effect | 🟢 Beginner | Understand 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 | 🟢 Beginner | Use Effect.map for synchronous transformations and Effect.flatMap to chain operations that return another Effect. | | Transforming Values with map | 🟢 Beginner | Use map to transform the result of an Effect, Stream, Option, or Either in a declarative, type-safe way. | | Understand that Effects are Lazy Blueprints | 🟢 Beginner | An 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 | 🟢 Beginner | Choose 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) | 🟢 Beginner | Learn 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](./content
Related Skills
Writing Hookify Rules
84.7kThis skill should be used when the user asks to "create a hookify rule", "write a hook rule", "configure hookify", "add a hookify rule", or needs guidance on hookify rule syntax and patterns.
review-duplication
99.6kUse this skill during code reviews to proactively investigate the codebase for duplicated functionality, reinvented wheels, or failure to reuse existing project best practices and shared utilities.
diffs
342.0kUse the diffs tool to produce real, shareable diffs (viewer URL, file artifact, or both) instead of manual edit summaries.
mcp-for-beginners
15.7kThis open-source curriculum introduces the fundamentals of Model Context Protocol (MCP) through real-world, cross-language examples in .NET, Java, TypeScript, JavaScript, Rust and Python. Designed for developers, it focuses on practical techniques for building modular, scalable, and secure AI workflows from session setup to service orchestration.
