effect-dependency-injection

Compose Effect services with Context.Tag and Layer dependency injection.

187|20|Updated Nov 20, 2025
One-click install
npx skills add https://github.com/TheBushidoCollective/han --skill effect-dependency-injection
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: effect-dependency-injection
Source: https://github.com/TheBushidoCollective/han/tree/main/jutsu/jutsu-effect/skills/effect-dependency-injection
Command: npx skills add https://github.com/TheBushidoCollective/han --skill effect-dependency-injection

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill covers dependency injection patterns in Effect using Context and Layer, enabling modular service definitions and composable graphs.

Core Features & Use Cases

  • Context-based services: Type-safe service identifiers.
  • Layer composition: Build services with clear dependencies.
  • Async service wiring: Compose effects across multiple services.

Quick Start

Define a simple HttpClient Layer that depends on Config and Logger and expose a get method.

Frequently Asked Questions about effect-dependency-injection

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

FAQPage Schema
How do I set up dependency injection in Effect applications?

Dependency injection in Effect uses Context.Tag to define type-safe service identifiers and Layer to compose services with their dependencies. Define a Context.Tag for each service, build Layers that describe how to construct or acquire services, and provide those Layers to your program for deterministic initialization and error handling across multi-service architectures.

What's the difference between succeed, effect, and scoped when building Effect Layers?

Layer construction methods differ by lifecycle: succeed creates a Layer from a pure value with no setup; effect wraps an Effect to perform async initialization; scoped handles resource acquisition and release, ensuring cleanup runs when the Layer is torn down. Choose based on whether your service is stateless, needs async wiring, or manages resources.

Can I compose multiple services with shared dependencies in Effect?

Yes. Effect Layers compose into dependency graphs automatically. Define each service as a Layer with explicit Context.Tag dependencies, then combine them using Layer composition operators. Effect resolves the graph, initializes services in dependency order, and handles errors deterministically across the entire service tree.

How do I provide Layers to an Effect program?

Use Layer.provide to inject Layers into an Effect. Pass the Layer (or layered composition) to the program; Effect handles provision at runtime, setting up all required services before the program runs and tearing down scoped resources afterward with predictable sequencing.

Why use Context.Tag instead of passing services as function arguments?

Context.Tag enables type-safe service composition without threading arguments through deep call stacks. Services are stored in an implicit Context, reducing boilerplate and making dependency graphs explicit and testable. Layers then compose these tags into reusable, deterministic initialization logic.

What happens if a service fails to initialize in an Effect Layer?

Layer construction effects propagate errors through the dependency graph. If any service fails to initialize, the entire Layer provision fails with that error, preventing partial setup and ensuring consistency. Your program receives the error for handling or recovery before any code runs.