{"id":30105889,"url":"https://github.com/pauljphilp/effectpatterns","last_synced_at":"2025-08-10T00:20:31.438Z","repository":{"id":300642554,"uuid":"1006702352","full_name":"PaulJPhilp/EffectPatterns","owner":"PaulJPhilp","description":"A community-driven knowledge base of practical patterns for Effect-TS.","archived":false,"fork":false,"pushed_at":"2025-07-15T06:52:42.000Z","size":15250,"stargazers_count":266,"open_issues_count":3,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-07-15T10:16:12.872Z","etag":null,"topics":["design-patterns","effect","effect-ts","functional-programming","knowledge-base","patterns","typescript"],"latest_commit_sha":null,"homepage":"","language":"MDX","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PaulJPhilp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"ROADMAP-module1.mdx","authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-22T20:34:23.000Z","updated_at":"2025-07-15T07:39:29.000Z","dependencies_parsed_at":"2025-07-08T04:24:02.908Z","dependency_job_id":"0edbd44e-bf42-4230-8b90-96434ca1587d","html_url":"https://github.com/PaulJPhilp/EffectPatterns","commit_stats":null,"previous_names":["pauljphilp/effectpatterns"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PaulJPhilp/EffectPatterns","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulJPhilp%2FEffectPatterns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulJPhilp%2FEffectPatterns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulJPhilp%2FEffectPatterns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulJPhilp%2FEffectPatterns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PaulJPhilp","download_url":"https://codeload.github.com/PaulJPhilp/EffectPatterns/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PaulJPhilp%2FEffectPatterns/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269657705,"owners_count":24454919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-09T02:00:10.424Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["design-patterns","effect","effect-ts","functional-programming","knowledge-base","patterns","typescript"],"created_at":"2025-08-10T00:20:30.416Z","updated_at":"2025-08-10T00:20:31.420Z","avatar_url":"https://github.com/PaulJPhilp.png","language":"MDX","readme":"# The Effect Patterns Hub\n\nA community-driven knowledge base of practical, goal-oriented patterns for building robust applications with Effect-TS.\n\nThis 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.\n\n**Looking for machine-readable rules for AI IDEs and coding agents? See the [AI Coding Rules](#ai-coding-rules) section below.**\n\n## Table of Contents\n\n- [Error Management](#error-management)\n- [Building APIs](#building-apis)\n- [Core Concepts](#core-concepts)\n- [Concurrency](#concurrency)\n- [Testing](#testing)\n- [Tooling and Debugging](#tooling-and-debugging)\n- [Domain Modeling](#domain-modeling)\n- [Modeling Data](#modeling-data)\n- [Making HTTP Requests](#making-http-requests)\n- [Observability](#observability)\n- [Resource Management](#resource-management)\n- [File Handling](#file-handling)\n- [Database Connections](#database-connections)\n- [Network Requests](#network-requests)\n- [Building Data Pipelines](#building-data-pipelines)\n- [Application Configuration](#application-configuration)\n- [Modeling Time](#modeling-time)\n- [Project Setup \u0026 Execution](#project-setup-execution)\n- [Advanced Dependency Injection](#advanced-dependency-injection)\n- [Custom Layers](#custom-layers)\n- [Dependency Injection](#dependency-injection)\n- [Application Architecture](#application-architecture)\n\n---\n\n## Error Management\n\n| Pattern | Skill Level | Summary |\n| :--- | :--- | :--- |\n| [Handle Errors with catchTag, catchTags, and catchAll](./content/published/handle-errors-with-catch.mdx) | 🟡 **Intermediate** | Use catchTag for type-safe recovery from specific tagged errors, and catchAll to recover from any possible failure. |\n| [Mapping Errors to Fit Your Domain](./content/published/mapping-errors-to-fit-your-domain.mdx) | 🟡 **Intermediate** | Use Effect.mapError to transform specific, low-level errors into more general domain errors, creating clean architectural boundaries. |\n| [Control Repetition with Schedule](./content/published/control-repetition-with-schedule.mdx) | 🟡 **Intermediate** | Use Schedule to create composable, stateful policies that define precisely how an effect should be repeated or retried. |\n| [Model Optional Values Safely with Option](./content/published/model-optional-values-with-option.mdx) | 🟡 **Intermediate** | Use Option\u003cA\u003e to explicitly represent a value that may or may not exist, eliminating null and undefined errors. |\n| [Define Type-Safe Errors with Data.TaggedError](./content/published/define-tagged-errors.mdx) | 🟡 **Intermediate** | Create custom, type-safe error classes by extending Data.TaggedError to make error handling robust, predictable, and self-documenting. |\n| [Leverage Effect's Built-in Structured Logging](./content/published/leverage-structured-logging.mdx) | 🟡 **Intermediate** | Use Effect's built-in logging functions (Effect.log, Effect.logInfo, etc.) for structured, configurable, and context-aware logging. |\n| [Conditionally Branching Workflows](./content/published/conditionally-branching-workflows.mdx) | 🟡 **Intermediate** | Use predicate-based operators like Effect.filter and Effect.if to make decisions and control the flow of your application based on runtime values. |\n| [Retry Operations Based on Specific Errors](./content/published/retry-based-on-specific-errors.mdx) | 🟡 **Intermediate** | Use Effect.retry and predicate functions to selectively retry an operation only when specific, recoverable errors occur. |\n| [Handle Flaky Operations with Retries and Timeouts](./content/published/handle-flaky-operations-with-retry-timeout.mdx) | 🟡 **Intermediate** | Use Effect.retry and Effect.timeout to build resilience against slow or intermittently failing operations, such as network requests. |\n| [Distinguish 'Not Found' from Errors](./content/published/distinguish-not-found-from-errors.mdx) | 🟡 **Intermediate** | Use Effect\u003cOption\u003cA\u003e\u003e to clearly distinguish between a recoverable 'not found' case (None) and a true failure (Fail). |\n| [Accumulate Multiple Errors with Either](./content/published/accumulate-multiple-errors-with-either.mdx) | 🟡 **Intermediate** | Use Either\u003cE, A\u003e to represent computations that can fail, allowing you to accumulate multiple errors instead of short-circuiting on the first one. |\n| [Handle Unexpected Errors by Inspecting the Cause](./content/published/handle-unexpected-errors-with-cause.mdx) | 🟠 **Advanced** | Use Effect.catchAllCause or Effect.runFork to inspect the Cause of a failure, distinguishing between expected errors (Fail) and unexpected defects (Die). |\n\n## Building APIs\n\n| Pattern | Skill Level | Summary |\n| :--- | :--- | :--- |\n| [Handle a GET Request](./content/published/handle-get-request.mdx) | 🟢 **Beginner** | Define a route that responds to a specific HTTP GET request path. |\n| [Send a JSON Response](./content/published/send-json-response.mdx) | 🟢 **Beginner** | Create and send a structured JSON response with the correct headers and status code. |\n| [Extract Path Parameters](./content/published/extract-path-parameters.mdx) | 🟢 **Beginner** | Capture and use dynamic segments from a request URL, such as a resource ID. |\n| [Create a Basic HTTP Server](./content/published/launch-http-server.mdx) | 🟢 **Beginner** | Launch a simple, effect-native HTTP server to respond to incoming requests. |\n| [Validate Request Body](./content/published/validate-request-body.mdx) | 🟡 **Intermediate** | Safely parse and validate an incoming JSON request body against a predefined Schema. |\n| [Provide Dependencies to Routes](./content/published/provide-dependencies-to-routes.mdx) | 🟡 **Intermediate** | Inject services like database connections into HTTP route handlers using Layer and Effect.Service. |\n| [Handle API Errors](./content/published/handle-api-errors.mdx) | 🟡 **Intermediate** | Translate application-specific errors from the Effect failure channel into meaningful HTTP error responses. |\n| [Make an Outgoing HTTP Client Request](./content/published/make-http-client-request.mdx) | 🟡 **Intermediate** | Use the built-in Effect HTTP client to make safe and composable requests to external services from within your API. |\n\n## Core Concepts\n\n| Pattern | Skill Level | Summary |\n| :--- | :--- | :--- |\n| [Understand that Effects are Lazy Blueprints](./content/published/effects-are-lazy.mdx) | 🟢 **Beginner** | An Effect is a lazy, immutable blueprint describing a computation, which does nothing until it is explicitly executed by a runtime. |\n| [Wrap Asynchronous Computations with tryPromise](./content/published/wrap-asynchronous-computations.mdx) | 🟢 **Beginner** | Use Effect.tryPromise to safely convert a function that returns a Promise into an Effect, capturing rejections in the error channel. |\n| [Write Sequential Code with Effect.gen](./content/published/write-sequential-code-with-gen.mdx) | 🟢 **Beginner** | Use Effect.gen with yield* to write sequential, asynchronous code in a style that looks and feels like familiar async/await. |\n| [Transform Effect Values with map and flatMap](./content/published/transform-effect-values.mdx) | 🟢 **Beginner** | Use Effect.map for synchronous transformations and Effect.flatMap to chain operations that return another Effect. |\n| [Create Pre-resolved Effects with succeed and fail](./content/published/create-pre-resolved-effect.mdx) | 🟢 **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. |\n| [Solve Promise Problems with Effect](./content/published/solve-promise-problems-with-effect.mdx) | 🟢 **Beginner** | Understand how Effect solves the fundamental problems of native Promises, such as untyped errors, lack of dependency injection, and no built-in cancellation. |\n| [Wrap Synchronous Computations with sync and try](./content/published/wrap-synchronous-computations.mdx) | 🟢 **Beginner** | Use Effect.sync for non-throwing synchronous code and Effect.try for synchronous code that might throw an exception. |\n| [Use .pipe for Composition](./content/published/use-pipe-for-composition.mdx) | 🟢 **Beginner** | Use the .pipe() method to chain multiple operations onto an Effect in a readable, top-to-bottom sequence. |\n| [Understand the Three Effect Channels (A, E, R)](./content/published/understand-effect-channels.mdx) | 🟢 **Beginner** | Learn about the three generic parameters of an Effect: the success value (A), the failure error (E), and the context requirements (R). |\n| [Control Repetition with Schedule](./content/published/control-repetition-with-schedule.mdx) | 🟡 **Intermediate** | Use Schedule to create composable, stateful policies that define precisely how an effect should be repeated or retried. |\n| [Conditionally Branching Workflows](./content/published/conditionally-branching-workflows.mdx) | 🟡 **Intermediate** | Use predicate-based operators like Effect.filter and Effect.if to make decisions and control the flow of your application based on runtime values. |\n| [Control Flow with Conditional Combinators](./content/published/control-flow-with-combinators.mdx) | 🟡 **Intermediate** | Use combinators like Effect.if, Effect.when, and Effect.cond to handle conditional logic in a declarative, composable way. |\n| [Process Streaming Data with Stream](./content/published/process-streaming-data-with-stream.mdx) | 🟡 **Intermediate** | Use Stream\u003cA, E, R\u003e to represent and process data that arrives over time, such as file reads, WebSocket messages, or paginated API results. |\n| [Manage Shared State Safely with Ref](./content/published/manage-shared-state-with-ref.mdx) | 🟡 **Intermediate** | Use Ref\u003cA\u003e to model shared, mutable state in a concurrent environment, ensuring all updates are atomic and free of race conditions. |\n| [Understand Layers for Dependency Injection](./content/published/understand-layers-for-dependency-injection.mdx) | 🟡 **Intermediate** | A Layer is a blueprint that describes how to build a service, detailing its own requirements and any potential errors during its construction. |\n| [Use Chunk for High-Performance Collections](./content/published/use-chunk-for-high-performance-collections.mdx) | 🟡 **Intermediate** | Use Chunk\u003cA\u003e as a high-performance, immutable alternative to JavaScript's Array, especially for data processing pipelines. |\n| [Understand Fibers as Lightweight Threads](./content/published/understand-fibers-as-lightweight-threads.mdx) | 🟠 **Advanced** | A 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. |\n\n## Concurrency\n\n| Pattern | Skill Level | Summary |\n| :--- | :--- | :--- |\n| [Control Repetition with Schedule](./content/published/control-repetition-with-schedule.mdx) | 🟡 **Intermediate** | Use Schedule to create composable, stateful policies that define precisely how an effect should be repeated or retried. |\n| [Race Concurrent Effects for the Fastest Result](./content/published/race-concurrent-effects.mdx) | 🟡 **Intermediate** | Use Effect.race to run multiple effects concurrently and proceed with the result of the one that succeeds first, automatically interrupting the others. |\n| [Manage Shared State Safely with Ref](./content/published/manage-shared-state-with-ref.mdx) | 🟡 **Intermediate** | Use Ref\u003cA\u003e to model shared, mutable state in a concurrent environment, ensuring all updates are atomic and free of race conditions. |\n| [Run Independent Effects in Parallel with Effect.all](./content/published/run-effects-in-parallel-with-all.mdx) | 🟡 **Intermediate** | Use Effect.all to run multiple independent effects concurrently and collect all their results into a single tuple. |\n| [Process a Collection in Parallel with Effect.forEach](./content/published/process-collection-in-parallel-with-foreach.mdx) | 🟡 **Intermediate** | Use Effect.forEach with the `concurrency` option to process a collection of items in parallel with a fixed limit, preventing resource exhaustion. |\n| [Add Caching by Wrapping a Layer](./content/published/add-caching-by-wrapping-a-layer.mdx) | 🟠 **Advanced** | Implement caching by creating a new layer that wraps a live service, intercepting method calls to add caching logic without modifying the original service. |\n| [Manage Resource Lifecycles with Scope](./content/published/manage-resource-lifecycles-with-scope.mdx) | 🟠 **Advanced** | Use Scope for fine-grained, manual control over resource lifecycles, ensuring cleanup logic (finalizers) is always executed. |\n| [Run Background Tasks with Effect.fork](./content/published/run-background-tasks-with-fork.mdx) | 🟠 **Advanced** | Use Effect.fork to start a computation in a background fiber, allowing the parent fiber to continue its work without waiting. |\n| [Execute Long-Running Apps with Effect.runFork](./content/published/execute-long-running-apps-with-runfork.mdx) | 🟠 **Advanced** | Use Effect.runFork at the application's entry point to launch a long-running process as a detached fiber, allowing for graceful shutdown. |\n| [Implement Graceful Shutdown for Your Application](./content/published/implement-graceful-shutdown.mdx) | 🟠 **Advanced** | Use Effect.runFork and listen for OS signals (SIGINT, SIGTERM) to trigger a Fiber.interrupt, ensuring all resources are safely released. |\n| [Decouple Fibers with Queues and PubSub](./content/published/decouple-fibers-with-queue-pubsub.mdx) | 🟠 **Advanced** | Use Queue for point-to-point work distribution and PubSub for broadcast messaging to enable safe, decoupled communication between concurrent fibers. |\n| [Poll for Status Until a Task Completes](./content/published/poll-for-status-until-task-completes.mdx) | 🟠 **Advanced** | Use Effect.race to run a repeating polling effect alongside a main task, automatically stopping the polling when the main task finishes. |\n| [Understand Fibers as Lightweight Threads](./content/published/understand-fibers-as-lightweight-threads.mdx) | 🟠 **Advanced** | A 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. |\n\n## Testing\n\n| Pattern | Skill Level | Summary |\n| :--- | :--- | :--- |\n| [Accessing the Current Time with Clock](./content/published/accessing-current-time-with-clock.mdx) | 🟡 **Intermediate** | Use the Clock service to access the current time in a testable, deterministic way, avoiding direct calls to Date.now(). |\n| [Write Tests That Adapt to Application Code](./content/published/write-tests-that-adapt-to-application-code.mdx) | 🟡 **Intermediate** | A cardinal rule of testing: Tests must adapt to the application's interface, not the other way around. Never modify application code solely to make a test pass. |\n| [Use the Auto-Generated .Default Layer in Tests](./content/published/use-default-layer-for-tests.mdx) | 🟡 **Intermediate** | When testing, always use the MyService.Default layer that is automatically generated by the Effect.Service class for dependency injection. |\n| [Mocking Dependencies in Tests](./content/published/mocking-dependencies-in-tests.mdx) | 🟡 **Intermediate** | Use a test-specific Layer to provide mock implementations of services your code depends on, enabling isolated and deterministic unit tests. |\n| [Model Dependencies as Services](./content/published/model-dependencies-as-services.mdx) | 🟡 **Intermediate** | Abstract external dependencies and capabilities into swappable, testable services using Effect's dependency injection system. |\n| [Create a Testable HTTP Client Service](./content/published/create-a-testable-http-client-service.mdx) | 🟡 **Intermediate** | Define an HttpClient service with separate 'Live' and 'Test' layers to enable robust, testable interactions with external APIs. |\n| [Organize Layers into Composable Modules](./content/published/organize-layers-into-composable-modules.mdx) | 🟠 **Advanced** | Structure a large application by grouping related services into 'module' layers, which are then composed together with a shared base layer. |\n\n## Tooling and Debugging\n\n| Pattern | Skill Level | Summary |\n| :--- | :--- | :--- |\n| [Supercharge Your Editor with the Effect LSP](./content/published/supercharge-your-editor-with-the-effect-lsp.mdx) | 🟡 **Intermediate** | Install the Effect Language Server (LSP) extension for your editor to get rich, inline type information and enhanced error checking for your Effect code. |\n| [Teach your AI Agents Effect with the MCP Server](./content/published/teach-your-ai-agents-effect-with-the-mcp-server.mdx) | 🟠 **Advanced** | Use the Effect MCP server to provide live, contextual information about your application's structure directly to AI coding agents. |\n\n## Domain Modeling\n\n| Pattern | Skill Level | Summary |\n| :--- | :--- | :--- |\n| [Model Optional Values Safely with Option](./content/published/model-optional-values-with-option.mdx) | 🟡 **Intermediate** | Use Option\u003cA\u003e to explicitly represent a value that may or may not exist, eliminating null and undefined errors. |\n| [Use Effect.gen for Business Logic](./content/published/use-gen-for-business-logic.mdx) | 🟡 **Intermediate** | Encapsulate sequential business logic, control flow, and dependency access within Effect.gen for improved readability and maintainability. |\n| [Transform Data During Validation with Schema](./content/published/transform-data-with-schema.mdx) | 🟡 **Intermediate** | Use Schema.transform to safely convert data from one type to another during the parsing phase, such as from a string to a Date. |\n| [Define Type-Safe Errors with Data.TaggedError](./content/published/define-tagged-errors.mdx) | 🟡 **Intermediate** | Create custom, type-safe error classes by extending Data.TaggedError to make error handling robust, predictable, and self-documenting. |\n| [Define Contracts Upfront with Schema](./content/published/define-contracts-with-schema.mdx) | 🟡 **Intermediate** | Use Schema to define the types for your data models and function signatures before writing the implementation, creating clear, type-safe contracts. |\n| [Parse and Validate Data with Schema.decode](./content/published/parse-with-schema-decode.mdx) | 🟡 **Intermediate** | Use Schema.decode(schema) to create an Effect that parses and validates unknown data, which integrates seamlessly with Effect's error handling. |\n| [Avoid Long Chains of .andThen; Use Generators Instead](./content/published/avoid-long-andthen-chains.mdx) | 🟡 **Intermediate** | Prefer Effect.gen over long chains of .andThen for sequential logic to improve readability and maintainability. |\n| [Distinguish 'Not Found' from Errors](./content/published/distinguish-not-found-from-errors.mdx) | 🟡 **Intermediate** | Use Effect\u003cOption\u003cA\u003e\u003e to clearly distinguish between a recoverable 'not found' case (None) and a true failure (Fail). |\n| [Model Validated Domain Types with Brand](./content/published/model-validated-domain-types-with-brand.mdx) | 🟡 **Intermediate** | Use Brand to turn primitive types like string or number into specific, validated domain types like Email or PositiveInt, making illegal states unrepresentable. |\n| [Accumulate Multiple Errors with Either](./content/published/accumulate-multiple-errors-with-either.mdx) | 🟡 **Intermediate** | Use Either\u003cE, A\u003e to represent computations that can fail, allowing you to accumulate multiple errors instead of short-circuiting on the first one. |\n\n## Modeling Data\n\n| Pattern | Skill Level | Summary |\n| :--- | :--- | :--- |\n| [Comparing Data by Value with Structural Equality](./content/published/comparing-data-by-value-with-structural-equality.mdx) | 🟢 **Beginner** | Use Data.struct and Equal.equals to safely compare objects by their value instead of their reference, avoiding common JavaScript pitfalls. |\n\n## Making HTTP Requests\n\n| Pattern | Skill Level | Summary |\n| :--- | :--- | :--- |\n| [Add Custom Metrics to Your Application](./content/published/add-custom-metrics.mdx) | 🟡 **Intermediate** | Use Effect's Metric module to instrument your code with counters, gauges, and histograms to track key business and performance indicators. |\n| [Model Dependencies as Services](./content/published/model-dependencies-as-services.mdx) | 🟡 **Intermediate** | Abstract external dependencies and capabilities into swappable, testable services using Effect's dependency injection system. |\n| [Create a Testable HTTP Client Service](./content/published/create-a-testable-http-client-service.mdx) | 🟡 **Intermediate** | Define an HttpClient service with separate 'Live' and 'Test' layers to enable robust, testable interactions with external APIs. |\n| [Add Caching by Wrapping a Layer](./content/published/add-caching-by-wrapping-a-layer.mdx) | 🟠 **Advanced** | Implement caching by creating a new layer that wraps a live service, intercepting method calls to add caching logic without modifying the original service. |\n| [Build a Basic HTTP Server](./content/published/build-a-basic-http-server.mdx) | 🟠 **Advanced** | Combine Layer, Runtime, and Effect to create a simple, robust HTTP server using Node.js's built-in http module. |\n| [Create a Managed Runtime for Scoped Resources](./content/published/create-managed-runtime-for-scoped-resources.mdx) | 🟠 **Advanced** | Use Layer.launch to safely manage the lifecycle of layers containing scoped resources, ensuring finalizers are always run. |\n\n## Observability\n\n| Pattern | Skill Level | Summary |\n| :--- | :--- | :--- |\n| [Add Custom Metrics to Your Application](./content/published/add-custom-metrics.mdx) | 🟡 **Intermediate** | Use Effect's Metric module to instrument your code with counters, gauges, and histograms to track key business and performance indicators. |\n| [Trace Operations Across Services with Spans](./content/published/trace-operations-with-spans.mdx) | 🟡 **Intermediate** | Use Effect.withSpan to create custom tracing spans, providing detailed visibility into the performance and flow of your application's operations. |\n\n## Resource Management\n\n| Pattern | Skill Level | Summary |\n| :--- | :--- | :--- |\n| [Safely Bracket Resource Usage with `acquireRelease`](./content/published/safely-bracket-resource-usage.mdx) | 🟢 **Beginner** | Use `Effect.acquireRelease` to guarantee a resource's cleanup logic runs, even if errors or interruptions occur. |\n| [Create a Service Layer from a Managed Resource](./content/published/scoped-service-layer.mdx) | 🟡 **Intermediate** | Use `Layer.scoped` with `Effect.Service` to transform a managed resource into a shareable, application-wide service. |\n| [Compose Resource Lifecycles with `Layer.merge`](./content/published/compose-scoped-layers.mdx) | 🟡 **Intermediate** | Combine multiple resource-managing layers, letting Effect automatically handle the acquisition and release order. |\n| [Manage Resource Lifecycles with Scope](./content/published/manage-resource-lifecycles-with-scope.mdx) | 🟠 **Advanced** | Use Scope for fine-grained, manual control over resource lifecycles, ensuring cleanup logic (finalizers) is always executed. |\n| [Manually Manage Lifecycles with `Scope`](./content/published/manual-scope-management.mdx) | 🟠 **Advanced** | Use `Scope` directly to manage complex resource lifecycles or when building custom layers. |\n| [Implement Graceful Shutdown for Your Application](./content/published/implement-graceful-shutdown.mdx) | 🟠 **Advanced** | Use Effect.runFork and listen for OS signals (SIGINT, SIGTERM) to trigger a Fiber.interrupt, ensuring all resources are safely released. |\n| [Create a Managed Runtime for Scoped Resources](./content/published/create-managed-runtime-for-scoped-resources.mdx) | 🟠 **Advanced** | Use Layer.launch to safely manage the lifecycle of layers containing scoped resources, ensuring finalizers are always run. |\n\n## File Handling\n\n| Pattern | Skill Level | Summary |\n| :--- | :--- | :--- |\n| [Safely Bracket Resource Usage with `acquireRelease`](./content/published/safely-bracket-resource-usage.mdx) | 🟢 **Beginner** | Use `Effect.acquireRelease` to guarantee a resource's cleanup logic runs, even if errors or interruptions occur. |\n\n## Database Connections\n\n| Pattern | Skill Level | Summary |\n| :--- | :--- | :--- |\n| [Safely Bracket Resource Usage with `acquireRelease`](./content/published/safely-bracket-resource-usage.mdx) | 🟢 **Beginner** | Use `Effect.acquireRelease` to guarantee a resource's cleanup logic runs, even if errors or interruptions occur. |\n\n## Network Requests\n\n| Pattern | Skill Level | Summary |\n| :--- | :--- | :--- |\n| [Safely Bracket Resource Usage with `acquireRelease`](./content/published/safely-bracket-resource-usage.mdx) | 🟢 **Beginner** | Use `Effect.acquireRelease` to guarantee a resource's cleanup logic runs, even if errors or interruptions occur. |\n\n## Building Data Pipelines\n\n| Pattern | Skill Level | Summary |\n| :--- | :--- | :--- |\n| [Create a Stream from a List](./content/published/stream-from-iterable.mdx) | 🟢 **Beginner** | Turn a simple in-memory array or list into a foundational data pipeline using Stream. |\n| [Run a Pipeline for its Side Effects](./content/published/stream-run-for-effects.mdx) | 🟢 **Beginner** | Execute a pipeline for its effects without collecting the results, saving memory. |\n| [Collect All Results into a List](./content/published/stream-collect-results.mdx) | 🟢 **Beginner** | Run a pipeline and gather all of its results into an in-memory array. |\n| [Turn a Paginated API into a Single Stream](./content/published/stream-from-paginated-api.mdx) | 🟡 **Intermediate** | Convert a paginated API into a continuous, easy-to-use stream, abstracting away the complexity of fetching page by page. |\n| [Process Items Concurrently](./content/published/stream-process-concurrently.mdx) | 🟡 **Intermediate** | Perform an asynchronous action for each item in a stream with controlled parallelism to dramatically improve performance. |\n| [Process Items in Batches](./content/published/stream-process-in-batches.mdx) | 🟡 **Intermediate** | Group items into chunks for efficient bulk operations, like database inserts or batch API calls. |\n| [Process collections of data asynchronously](./content/published/process-a-collection-of-data-asynchronously.mdx) | 🟡 **Intermediate** | Process collections of data asynchronously in a lazy, composable, and resource-safe manner using Effect's Stream. |\n| [Process a Large File with Constant Memory](./content/published/stream-from-file.mdx) | 🟡 **Intermediate** | Create a data pipeline from a file on disk, processing it line-by-line without loading the entire file into memory. |\n| [Automatically Retry Failed Operations](./content/published/stream-retry-on-failure.mdx) | 🟡 **Intermediate** | Build a self-healing pipeline that can automatically retry failed processing steps using a configurable backoff strategy. |\n| [Manage Resources Safely in a Pipeline](./content/published/stream-manage-resources.mdx) | 🟠 **Advanced** | Ensure resources like file handles or connections are safely acquired at the start of a pipeline and always released at the end, even on failure. |\n\n## Application Configuration\n\n| Pattern | Skill Level | Summary |\n| :--- | :--- | :--- |\n| [Access Configuration from the Context](./content/published/access-config-in-context.mdx) | 🟡 **Intermediate** | Access your type-safe configuration within an Effect.gen block by yielding the Config object you defined. |\n| [Define a Type-Safe Configuration Schema](./content/published/define-config-schema.mdx) | 🟡 **Intermediate** | Use Effect.Config primitives to define a schema for your application's configuration, ensuring type-safety and separation from code. |\n| [Provide Configuration to Your App via a Layer](./content/published/provide-config-layer.mdx) | 🟡 **Intermediate** | Use Config.layer(schema) to create a Layer that provides your configuration schema to the application's context. |\n\n## Modeling Time\n\n| Pattern | Skill Level | Summary |\n| :--- | :--- | :--- |\n| [Accessing the Current Time with Clock](./content/published/accessing-current-time-with-clock.mdx) | 🟡 **Intermediate** | Use the Clock service to access the current time in a testable, deterministic way, avoiding direct calls to Date.now(). |\n| [Representing Time Spans with Duration](./content/published/representing-time-spans-with-duration.mdx) | 🟡 **Intermediate** | Use the Duration data type to represent time intervals in a type-safe, human-readable, and composable way. |\n| [Beyond the Date Type - Real World Dates, Times, and Timezones](./content/published/beyond-the-date-type.mdx) | 🟡 **Intermediate** | Use the Clock service for testable access to the current time and prefer immutable primitives for storing and passing timestamps. |\n\n## Project Setup \u0026 Execution\n\n| Pattern | Skill Level | Summary |\n| :--- | :--- | :--- |\n| [Execute Synchronous Effects with Effect.runSync](./content/published/execute-with-runsync.mdx) | 🟢 **Beginner** | Use Effect.runSync at the 'end of the world' to execute a purely synchronous Effect and get its value directly. |\n| [Execute Asynchronous Effects with Effect.runPromise](./content/published/execute-with-runpromise.mdx) | 🟢 **Beginner** | Use Effect.runPromise at the 'end of the world' to execute an asynchronous Effect and get its result as a JavaScript Promise. |\n| [Set Up a New Effect Project](./content/published/setup-new-project.mdx) | 🟢 **Beginner** | Initialize a new Node.js project with the necessary TypeScript configuration and Effect dependencies to start building. |\n| [Execute Long-Running Apps with Effect.runFork](./content/published/execute-long-running-apps-with-runfork.mdx) | 🟠 **Advanced** | Use Effect.runFork at the application's entry point to launch a long-running process as a detached fiber, allowing for graceful shutdown. |\n| [Create a Reusable Runtime from Layers](./content/published/create-reusable-runtime-from-layers.mdx) | 🟠 **Advanced** | Compile your application's layers into a reusable Runtime object to efficiently execute multiple effects that share the same context. |\n| [Create a Managed Runtime for Scoped Resources](./content/published/create-managed-runtime-for-scoped-resources.mdx) | 🟠 **Advanced** | Use Layer.launch to safely manage the lifecycle of layers containing scoped resources, ensuring finalizers are always run. |\n\n## Advanced Dependency Injection\n\n| Pattern | Skill Level | Summary |\n| :--- | :--- | :--- |\n| [Manually Manage Lifecycles with `Scope`](./content/published/manual-scope-management.mdx) | 🟠 **Advanced** | Use `Scope` directly to manage complex resource lifecycles or when building custom layers. |\n\n## Custom Layers\n\n| Pattern | Skill Level | Summary |\n| :--- | :--- | :--- |\n| [Manually Manage Lifecycles with `Scope`](./content/published/manual-scope-management.mdx) | 🟠 **Advanced** | Use `Scope` directly to manage complex resource lifecycles or when building custom layers. |\n\n## Dependency Injection\n\n| Pattern | Skill Level | Summary |\n| :--- | :--- | :--- |\n| [Create a Service Layer from a Managed Resource](./content/published/scoped-service-layer.mdx) | 🟡 **Intermediate** | Use `Layer.scoped` with `Effect.Service` to transform a managed resource into a shareable, application-wide service. |\n| [Compose Resource Lifecycles with `Layer.merge`](./content/published/compose-scoped-layers.mdx) | 🟡 **Intermediate** | Combine multiple resource-managing layers, letting Effect automatically handle the acquisition and release order. |\n\n## Application Architecture\n\n| Pattern | Skill Level | Summary |\n| :--- | :--- | :--- |\n| [Create a Service Layer from a Managed Resource](./content/published/scoped-service-layer.mdx) | 🟡 **Intermediate** | Use `Layer.scoped` with `Effect.Service` to transform a managed resource into a shareable, application-wide service. |\n| [Compose Resource Lifecycles with `Layer.merge`](./content/published/compose-scoped-layers.mdx) | 🟡 **Intermediate** | Combine multiple resource-managing layers, letting Effect automatically handle the acquisition and release order. |\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpauljphilp%2Feffectpatterns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpauljphilp%2Feffectpatterns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpauljphilp%2Feffectpatterns/lists"}