effect-ts-patterns

Implement typed Effect-TS patterns for effects, errors, and dependencies.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/aitchwhy/dotfiles --skill effect-ts-patterns
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: effect-ts-patterns
Source: https://github.com/aitchwhy/dotfiles/tree/main/config/agents/skills/effect-ts-patterns
Command: npx skills add https://github.com/aitchwhy/dotfiles --skill effect-ts-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides comprehensive patterns for Effect-TS, enabling developers to write highly robust, type-safe, and composable code by making effects, errors, and dependencies explicit in the type system. It eliminates untyped exceptions and simplifies complex asynchronous logic.

Core Features & Use Cases

  • Effect<A, E, R> Type System: Guides on understanding and utilizing the core Effect type, which explicitly declares success (A), error (E), and required services (R) in its signature.
  • Service Pattern (DI): Defines services with Context.Tag and implements them with Layer for powerful, type-safe dependency injection, ensuring clear separation of concerns.
  • Typed Errors: Uses Data.TaggedError for defining and recovering from specific, type-safe errors, making error handling explicit and exhaustive.
  • Advanced Operations: Patterns for retries with schedules, timeouts, parallel execution, and resource management (acquireRelease), building resilient applications.
  • Use Case: A developer is building a complex data processing pipeline that involves multiple external API calls and database interactions, each with potential failures. They can use this skill to define each step as an Effect, manage dependencies with Layers, handle errors with catchTag, and implement retries, ensuring a resilient and type-safe pipeline.

Quick Start

Refactor the 'fetchUserData' function in 'src/services/user.ts' to return an 'Effect<User, NetworkError, HttpClient>', explicitly defining its success, error, and dependency types.

Frequently Asked Questions about effect-ts-patterns

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

FAQPage Schema
How do I handle typed errors in TypeScript without throwing exceptions?▼

Use Effect-TS with Data.TaggedError to define specific, recoverable errors as part of your Effect type signature. This makes errors explicit in the type system and enables exhaustive error handling with catchTag, eliminating untyped exceptions.

What's the best way to manage dependencies in a TypeScript application?▼

Define services using Context.Tag and compose them with Layers for type-safe dependency injection. This approach provides clear separation of concerns and ensures dependencies are wired explicitly, making the service graph visible in your types.

How do I structure async operations with explicit success, error, and dependency types?▼

Use the Effect<A, E, R> type to encode success value A, error type E, and required services R directly in the type signature. This forces the compiler to track all effects, errors, and dependencies, enabling type-safe composition of complex async workflows.

Can I use Effect-TS patterns for building HTTP APIs and handling failures?▼

Yes. Effect-TS integrates with HttpApiBuilder to construct type-safe HTTP endpoints. Combine Effect<A, E, R> for request handlers, Layer for service provisioning, and catchTag for specific error recovery to build resilient, composable APIs.

How do I implement retries and timeouts in functional TypeScript?▼

Effect-TS provides schedule-based retries and timeout operations as composable Effect transformations. Use these patterns alongside service Layers to build resilient pipelines that automatically recover from transient failures with explicit control over retry logic.

What makes Effect-TS better than Promise-based error handling?▼

Effect-TS makes errors, dependencies, and async behavior part of the type system using Effect<A, E, R>, enabling compile-time exhaustiveness checking and explicit dependency tracking. Promises leave error types and dependencies implicit, making failures harder to reason about and compose reliably.