mcpField
E
effect-ts

effect-ts

github.com/pproencaDevelopment221256 installsUpdated 12w ago
Repository

About effect-ts

A reference skill for developers writing or reviewing TypeScript that uses Effect. It organizes guidance by domain, from core concepts and error handling to concurrency, platform APIs, and migration.

Key features

  1. 01Domain-specific Effect references
  2. 02Typed errors and recovery patterns
  3. 03Services, layers, and resource safety
  4. 04Schema validation and transformation
  5. 05Concurrency, streams, and scheduling
  6. 06Migration guidance for related libraries

Use cases

  1. 01Reviewing code that uses Effect
  2. 02Designing services with dependency injection
  3. 03Validating and transforming data with Schema
  4. 04Migrating Promise-based code to Effect

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/pproenca/dot-skills --skill effect-ts

After installing, type/effect-tsin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

gotchas.md
metadata.json
references/
_sections.md
ai-integration.md
code-style.md
conc-concurrency.md
core-concepts.md
data-types.md
error-management.md
getting-paradigm.md
getting-started.md
micro-module.md
migration-guides.md
obs-observability.md
plat-platform.md
req-management.md
resource-management.md
sched-scheduling.md
schema-advanced.md
schema-basics.md
state-management.md
streams-and-sinks.md
test-testing.md

Details

From the project README

Effect TypeScript Best Practices

Effect is a TypeScript library for building complex, type-safe applications with structured error handling, dependency injection via services/layers, fiber-based concurrency, and resource safety.

When to Apply

  • Writing or reviewing TypeScript code that imports from effect, @effect/schema, or @effect/platform
  • Implementing typed error handling with Effect<Success, Error, Requirements>
  • Building services and layers for dependency injection
  • Working with Schema for data validation, decoding, and transformation
  • Using fiber-based concurrency (queues, semaphores, PubSub, deferred)
  • Processing data with Stream and Sink
  • Migrating from Promises, fp-ts, neverthrow, or ZIO to Effect

How to Use

This skill is organized by domain. Read the relevant reference file for the area you're working in.

Read First: The Paradigm

Always read this before diving into API references, especially when refactoring existing code to use Effect or writing new Effect services:

ReferenceWhen to Read
Think in Effect: The Paradigm ShiftBefore any other reference. Mental model shifts, refactoring recipes, anti-patterns, application architecture. Read this to understand HOW to think in Effect — the other files teach WHAT to type.
Core Foundations
ReferenceWhen to Read
Getting StartedCreating the Effect type, pipelines, generators, running effects
Error ManagementTyped errors, recovery, retrying, timeouts, sandboxing
Core ConceptsRequest batching, configuration management, runtime system
Data & Validation
ReferenceWhen to Read
Data TypesOption, Either, Cause, Chunk, DateTime, Duration, Exit, Data
Schema BasicsSchema intro, basic usage, classes, constructors, effect data types
Schema AdvancedTransformations, filters, annotations, error formatting, JSON Schema output
Architecture & Dependencies
ReferenceWhen to Read
Requirements ManagementServices, Layers, dependency injection, layer memoization
Resource ManagementScope, safe resource acquisition/release, caching
State ManagementRef, SubscriptionRef, SynchronizedRef for concurrent state
Concurrency & Streaming
ReferenceWhen to Read
ConcurrencyFibers, Deferred, Latch, PubSub, Queue, Semaphore
Streams and SinksCreating, consuming, transforming streams; sink operations
SchedulingBuilt-in schedules, cron, combinators, repetition
Platform & Observability
ReferenceWhen to Read
PlatformFileSystem, Command, Terminal, KeyValueStore, Path
ObservabilityLogging, metrics, tracing, Supervisor
TestingTestClock for time simulation; for service mocking and layer testing, see Requirements Management
Style, AI & Migration
ReferenceWhen to Read
Code StyleBranded types, pattern matching, dual APIs, guidelines, traits
AI IntegrationEffect AI packages for LLM tool use and execution planning
MicroLightweight Effect alternative for smaller bundles
Migration GuidesComing from Promises, fp-ts, neverthrow, or ZIO

Quick Reference — Common Patterns

The Effect Type
//         ┌─── Success type
//         │        ┌─── Error type
//         │        │      ┌─── Required dependencies
//         ▼        ▼      ▼
Effect<Success, Error, Requirements>
Creating Effects
import { Effect } from "effect"

// From sync values
const succeed = Effect.succeed(42)
const fail = Effect.fail(new Error("oops"))

// From sync code that may throw
const sync = Effect.try(() => JSON.parse(data))

// From promises
const async = Effect.tryPromise(() => fetch(url))

// From generators (recommended for complex flows)
const program = Effect.gen(function* () {
  const user = yield* getUser(id)
  const todos = yield* getTodos(user.id)
  return { user, todos }
})
Running Effects
// Async (returns Promise)
Effect.runPromise(program)

// With full Exit information
Effect.runPromiseExit(program)

// Sync (throws on async)
Effect.runSync(program)
Typed Errors
import { Data, Effect } from "effect"

class NotFound extends Data.TaggedError("NotFound")<{
  readonly id: string
}> {}

class Unauthorized extends Data.TaggedError("Unauthorized")<{}> {}

// Error type is tracked: Effect<User, NotFound | Unauthorized>
const getUser = (id: string) =>
  Effect.gen(function* () {
    // ...
  })
Services and Layers
import { Context, Effect, Layer } from "effect"

// Define a service
class UserRepo extends Context.Tag("UserRepo")<
  UserRepo,
  { readonly findById: (id: string) => Effect.Effect<User, NotFound> }
>() {}

// Use in effects — adds to Requirements channel
const program = Effect.gen(function* () {
  const repo = yield* UserRepo
  return yield* repo.findById("1")
})

// Implement with a Layer
const UserRepoLive = Layer.succeed(UserRepo, {
  findById: (id) => Effect.succeed({ id, name: "Alice" })
})

// Provide and run
program.pipe(Effect.provide(UserRepoLive), Effect.runPromise)
Schema Validation
import { Schema } from "effect"

const User = Schema.Struct({
  id: Schema.Number,
  name: Schema.String,
  email: Schema.String.pipe(Schema.pattern(/@/))
})

type User = typeof User.Type

// Decode (parse + validate)
const decode = Schema.decodeUnknownSync(User)
const user = decode({ id: 1, name: "Alice", email: "[email protected]" })
Pipelines
import { Effect, pipe } from "effect"

// Data-last (pipe style)
const result = pipe(
  getTodos,
  Effect.map((todos) => todos.filter((t) => !t.done)),
  Effect.flatMap((active) => sendNotification(active.length)),
  Effect.catchTag("NetworkError", () => Effect.succeed("offline"))
)

// Fluent (method style)
const result2 = getTodos.pipe(
  Effect.map((todos) => todos.filter((t) => !t.done)),
  Effect.flatMap((active) => sendNotification(active.length))
)

Gotchas

See gotchas.md for known failure points.

Comments

Markdown supported