effect-layer-design

Design and compose Effect v4 layers for explicit dependency management.

1|Updated Aug 24, 2026
One-click install
npx skills add https://github.com/lambdasolver2/opencode-effect-harness --skill effect-layer-design-lambdasolver2
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: effect-layer-design
Source: https://github.com/lambdasolver2/opencode-effect-harness/tree/main/packages/module-typescript/assets/skills/effect-layer-design
Command: npx skills add https://github.com/lambdasolver2/opencode-effect-harness --skill effect-layer-design-lambdasolver2

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires effect.

What problem does it solve? Structuring services and their dependencies in Effect v4 applications is error-prone without clear patterns for layer construction, composition, resource cleanup, and error handling, leading to tangled dependency graphs and leaked resources. ## Core Features & Use Cases - Layer Construction Patterns: Covers simple layers, layers with dependencies, and resource-managed layers using Layer.effect with acquireRelease for automatic Scope handling. - Composition Strategies: Explains merge, provide, provideMerge, and defaultLayer conventions, including when to use Layer.suspend for deferred composition. - Advanced Concurrency Pattern: Provides a SynchronizedRef plus Deferred state machine for sharing in-flight work across concurrent callers. - Use Case: When building a service like a Database layer that needs Config, acquires a connection, and must be swappable with a test implementation, this Skill guides the exact layer structure, naming conventions, and composition approach. ## Quick Start Ask the assistant to design an Effect v4 layer for a Database service that depends on Config, manages its connection lifecycle, and can be swapped with a test implementation.

Frequently Asked Questions about effect-layer-design

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

FAQPage Schema
How do I create an Effect layer with dependencies?

Use Layer.effect with Effect.gen to yield the dependency service inside the constructor, then return the new service via Service.of. The layer type becomes Layer<Output, Error, Dependency>, making the requirement explicit in the type signature.

What is the difference between Layer.merge and Layer.provide in Effect?

Layer.merge combines independent layers in parallel, unioning both outputs and requirements. Layer.provide chains layers sequentially, satisfying the inner layer's requirements with the outer layer and removing them from the output type.

Does Effect v4 still need Layer.scoped for resource cleanup?

No. In Effect v4, Layer.effect automatically handles the Scope lifecycle, so Layer.scoped is no longer needed. Acquire resources with Effect.acquireRelease or Effect.addFinalizer directly inside the Layer.effect constructor.

When should I use Layer.provideMerge instead of Layer.provide?

Use Layer.provideMerge when building test layer stacks where multiple downstream layers need access to the same upstream services. It satisfies the dependency while keeping it in the output type, unlike Layer.provide which removes it.

When should I use Layer.suspend for deferred composition?

Use Layer.suspend only for real circular-import or module-evaluation hazards, runtime-selected layer variants, or recursive layer graphs. In the normal case, compose defaultLayer directly with Layer.provide without deferral.

How do I share one execution across concurrent callers in Effect?

Combine SynchronizedRef.modifyEffect with a Deferred-based state machine. The atomic modify ensures only one execution starts, while concurrent callers awaiting the same Deferred share the in-flight result.