agentleFS
ScrapybaraScrapybara/agent-skills/skills/effect-ts/SKILL.md

effect-ts

Skill0 starsChanged 49 days agoMITView on GitHub

Comprehensive guidance for building applications with Effect.ts - a TypeScript library for typed functional effects with dependency injection, structured concurrency, and resilient error handling. Core type: Effect<Success, Error, Requirements> → See references/core/creating-effects.md → See references/core/composition.md → See references/core/error-handling.md → See references/services/README.md → See references/services/runtime.md

18 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use shadcn, web-design-guidelines and 1 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • DatabricksSkill

    shadcn

    Manages shadcn components and projects — adding, searching, fixing, debugging, styling, and composing UI. Provides project context, component docs, and usage examples. Applies when working with shadcn/ui, component registries, presets, --preset codes, or any project with a components.json file. Also triggers for "shadcn init", "create an app with --preset", or "switch to --preset".

    Also in 3 projects that use this

  • VercelSkill

    web-design-guidelines

    Review UI code for Web Interface Guidelines compliance. Use when asked to "review my UI", "check accessibility", "audit design", "review UX", or "check my site against best practices".

    Also in 3 projects that use this

  • GoogleSkill

    grill-me

    A relentless interview to sharpen a plan or design.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 18 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use platform-specific runMain for real applications:

    line 197

“Common” is measured: kept by at least 6 in 10 of the 18 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Effect.ts Skill

Comprehensive guidance for building applications with Effect.ts - a TypeScript library for typed functional effects with dependency injection, structured concurrency, and resilient error handling.

Quick Reference

import { Effect, Context, Layer, Data, Config, Schema, Schedule } from "effect";
import { NodeRuntime } from "@effect/platform-node"; // For applications

Core type: Effect<Success, Error, Requirements>

  • Success - The value type on success
  • Error - The error type (typed errors!)
  • Requirements - Services/dependencies needed to run

Quick Decision Trees

"How do I create an Effect?"

Do you have a value already?
├─ Yes, synchronous value → Effect.succeed(value)
├─ Yes, but computation might throw → Effect.try(() => riskyValue)
├─ No, need to compute
│  ├─ Synchronous computation → Effect.sync(() => compute())
│  └─ Asynchronous computation
│     ├─ Returns Promise → Effect.promise(() => asyncOp())
│     ├─ Promise might reject → Effect.tryPromise(() => asyncOp())
│     └─ Callback-based → Effect.async((resume) => { ... })
└─ Want to fail immediately → Effect.fail(error)

→ See references/core/creating-effects.md

"How do I compose Effects?"

Combining multiple Effects?
├─ Sequential, need previous result → Effect.gen (generator syntax)
├─ Sequential, transform result → .pipe(Effect.map(...))
├─ Sequential, chain to new Effect → .pipe(Effect.flatMap(...))
├─ Parallel, independent operations → Effect.all([a, b, c])
├─ Parallel, first to succeed → Effect.race([a, b])
├─ Parallel, with concurrency limit → Effect.all(effects, { concurrency: 5 })
└─ Conditional execution → Effect.if / Effect.when

→ See references/core/composition.md

"How do I handle errors?"

Need to handle errors?
├─ Define typed error → class MyError extends Data.TaggedError("MyError")<{...}>
├─ Handle specific error type → .pipe(Effect.catchTag("MyError", handler))
├─ Handle all errors → .pipe(Effect.catchAll(handler))
├─ Recover with fallback → .pipe(Effect.orElse(() => fallback))
├─ Transform error type → .pipe(Effect.mapError(transform))
├─ Catch and rethrow → .pipe(Effect.tapError(logError))
└─ Ignore errors (return Option) → .pipe(Effect.option)

→ See references/core/error-handling.md

"How do I use dependency injection?"

Need dependency injection?
├─ Define service interface → class MyService extends Context.Tag("MyService")<...>
├─ Create implementation → Layer.succeed(MyService, implementation)
├─ Implementation needs other services → Layer.effect(MyService, Effect.gen(...))
├─ Compose layers → Layer.merge / Layer.provide
├─ Provide at runtime edge → Effect.provide(layer)
└─ Access service in Effect → yield* MyService (in generator)

→ See references/services/README.md

"How do I run an Effect?"

Need to execute the Effect?
├─ In application entry point
│  ├─ Simple run → Effect.runPromise(effect)
│  ├─ Run and exit process → Effect.runMain(effect)
│  └─ Get sync result → Effect.runSync(effect)
├─ Long-running application
│  ├─ Managed runtime → ManagedRuntime.make(layer)
│  └─ Singleton pattern → Runtime as module variable
└─ Testing → Effect.runPromise with test layers

→ See references/services/runtime.md

"How do I add retry/resilience?"

Need retry logic?
├─ Fixed retry count → Schedule.recurs(n)
├─ Fixed delay between retries → Schedule.spaced(duration)
├─ Exponential backoff → Schedule.exponential(base)
├─ Combine strategies → Schedule.union / Schedule.compose
├─ Add jitter → Schedule.jittered
└─ Apply to Effect → effect.pipe(Effect.retry(schedule))

→ See references/patterns/retry.md

Generator Syntax (Preferred)

const program = Effect.gen(function* () {
  const user = yield* getUser(id);
  const posts = yield* getPosts(user.id);
  return { user, posts };
});

Why generators?

  • Reads like async/await
  • Full type inference
  • Automatic error channel composition
  • Better stack traces

Tagged Errors (Preferred)

class UserNotFound extends Data.TaggedError("UserNotFound")<{
  readonly userId: string;
}> {}

class NetworkError extends Data.TaggedError("NetworkError")<{
  readonly url: string;
  readonly cause: unknown;
}> {}

// Type-safe error handling
effect.pipe(
  Effect.catchTag("UserNotFound", (e) => Effect.succeed(null)),
  Effect.catchTag("NetworkError", (e) => retryWithBackoff(e.url)),
);

Service Pattern

// 1. Define interface
class Database extends Context.Tag("Database")<
  Database,
  {
    readonly query: (sql: string) => Effect.Effect<unknown[], SqlError>;
  }
>() {}

// 2. Create implementation
const DatabaseLive = Layer.succeed(Database, {
  query: (sql) =>
    Effect.tryPromise({
      try: () => db.query(sql),
      catch: (e) => new SqlError({ cause: e }),
    }),
});

// 3. Use in program
const program = Effect.gen(function* () {
  const db = yield* Database;
  return yield* db.query("SELECT * FROM users");
});

// 4. Provide layer at edge
program.pipe(Effect.provide(DatabaseLive));

Running Applications

Use platform-specific runMain for real applications:

// Node.js - handles SIGINT/SIGTERM, proper exit codes
import { NodeRuntime } from "@effect/platform-node";
NodeRuntime.runMain(program);

// Bun
import { BunRuntime } from "@effect/platform-bun";
BunRuntime.runMain(program);

// Browser
import { BrowserRuntime } from "@effect/platform-browser";
BrowserRuntime.runMain(program);

For simple scripts, use Effect.runPromise(program) at the edge.

Essential Functions (Start Here)

These 15 functions cover most use cases:

CategoryFunctions
CreatingEffect.succeed, Effect.fail, Effect.sync, Effect.tryPromise
ComposingEffect.gen, Effect.map, Effect.flatMap, Effect.tap, Effect.andThen
RunningEffect.runPromise
ErrorsEffect.catchTag, Effect.catchAll
ResourcesEffect.acquireRelease, Effect.acquireUseRelease
DIEffect.provide, Effect.provideService

Essential Imports

ImportPurpose
EffectCore effect type and operations
ContextService tags for dependency injection
LayerService implementations
DataTagged errors, case classes
SchemaRuntime validation
ConfigConfiguration management
ScheduleRetry/repeat policies
ScopeResource management
RuntimeEffect execution
ManagedRuntimeLong-running runtimes
Option, EitherData types
MatchPattern matching

Reference Index

Core Concepts

TopicReference
Effect Fundamentalsreferences/core/README.md
Creating Effectsreferences/core/creating-effects.md
Composition & Pipelinesreferences/core/composition.md
Error Handlingreferences/core/error-handling.md
Resource Managementreferences/core/resources.md

Services & DI

TopicReference
Services Overviewreferences/services/README.md
Layersreferences/services/layers.md
Runtimereferences/services/runtime.md

Patterns

TopicReference
Patterns Overviewreferences/patterns/README.md
HTTP Clientsreferences/patterns/http-clients.md
Configurationreferences/patterns/config.md
Retry & Resiliencereferences/patterns/retry.md
Concurrencyreferences/patterns/concurrency.md

Troubleshooting

TopicReference
Common Gotchasreferences/gotchas.md

Reading Order

TaskStart WithThen Read
Learning Effectcore/README → core/creating-effectscore/composition
Adding error handlingcore/error-handlinggotchas
Setting up DIservices/README → services/layersservices/runtime
Building HTTP clientpatterns/http-clientspatterns/retry
Production setuppatterns/configservices/runtime
Debugging issuesgotchascore/error-handling

Schema Quick Reference

Schema provides runtime validation with type inference:

import { Schema } from "effect";

const User = Schema.Struct({
  name: Schema.String.pipe(Schema.minLength(1)),
  email: Schema.String.pipe(Schema.pattern(/^[^@]+@[^@]+$/)),
  age: Schema.Number.pipe(Schema.int(), Schema.positive()),
});

type User = Schema.Schema.Type<typeof User>;

// Decode unknown data
const result = Schema.decodeUnknown(User)(rawData);

// In Effect pipeline
effect.pipe(Effect.flatMap((data) => Schema.decodeUnknown(User)(data)));

See Also

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.