본문으로 건너뛰기
cccskills
무료GitHub에 공개

effect-ts

Build robust TypeScript applications with Effect — type-safe error handling, concurrency, dependency injection, and streaming. Use when someone asks to "handle errors without try-catch", "type-safe error handling in TypeScript", "dependency injection without classes", "concurrent TypeScript", "Effect library", "replace try-catch with typed errors", or "functional programming in TypeScript". Covers Effect, Layer, Schedule, Stream, and Schema.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(2)

  • SKILL.md8.0 KB
  • _scores.json1.3 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Effect-TS

Overview

Effect is a TypeScript library that makes errors, dependencies, and async operations explicit in the type system. Instead of try-catch with unknown errors, every function declares exactly what can go wrong. Instead of global imports, every dependency is tracked in the type. The result: code that's easier to test, refactor, and reason about.

When to Use

  • Business logic where knowing every possible error matters (payments, auth, data pipelines)
  • Applications with complex dependency graphs that need testability
  • Concurrent operations that need structured concurrency (not just Promise.all)
  • Data validation and transformation pipelines
  • Replacing error-prone try-catch chains with typed error handling

Instructions

Core Concept: Effect<Success, Error, Requirements>

Every Effect value has three type parameters:

  • Success: what it returns when it works
  • Error: what errors it can produce
  • Requirements: what services/dependencies it needs
// core.ts — Effect basics: typed errors and pipe
import { Effect, pipe } from "effect";

// Define typed errors (not just Error/string)
class UserNotFound {
  readonly _tag = "UserNotFound";
  constructor(readonly userId: string) {}
}

class DatabaseError {
  readonly _tag = "DatabaseError";
  constructor(readonly cause: unknown) {}
}

// Function that can fail with typed errors
//           Success ───┐  Error ──────────────────────────┐  Requirements ─┐
//                      ▼                                   ▼                ▼
const getUser = (id: string): Effect.Effect<User, UserNotFound | DatabaseError, never> =>
  pipe(
    Effect.tryPromise({
      try: () => db.user.findUnique({ where: { id } }),
      catch: (e) => new DatabaseError(e),
    }),
    Effect.flatMap((user) =>
      user ? Effect.succeed(user) : Effect.fail(new UserNotFound(id))
    )
  );

// Handle specific errors
const getUserOrDefault = (id: string) =>
  pipe(
    getUser(id),
    Effect.catchTag("UserNotFound", () =>
      Effect.succeed({ id: "default", name: "Guest", email: "guest@example.com" })
    )
    // DatabaseError is NOT caught — it propagates up in the type
  );

Dependency Injection with Layers

// services.ts — Dependency injection without classes
import { Effect, Context, Layer } from "effect";

// Define a service interface
class UserRepo extends Context.Tag("UserRepo")<
  UserRepo,
  {
    findById: (id: string) => Effect.Effect<User | null, DatabaseError>;
    create: (data: NewUser) => Effect.Effect<User, DatabaseError>;
  }
>() {}

// Business logic that REQUIRES UserRepo (tracked in type)
const getUser = (id: string) =>
  pipe(
    UserRepo,                    // Access the service
    Effect.flatMap((repo) => repo.findById(id)),
    Effect.flatMap((user) =>
      user ? Effect.succeed(user) : Effect.fail(new UserNotFound(id))
    )
  );
//   ^? Effect<User, UserNotFound | DatabaseError, UserRepo>
//                                                  ^^^^^^^^ dependency tracked!

// Production implementation
const UserRepoLive = Layer.succeed(UserRepo, {
  findById: (id) =>
    Effect.tryPromise({
      try: () => prisma.user.findUnique({ where: { id } }),
      catch: (e) => new DatabaseError(e),
    }),
  create: (data) =>
    Effect.tryPromise({
      try: () => prisma.user.create({ data }),
      catch: (e) => new DatabaseError(e),
    }),
});

// Test implementation
const UserRepoTest = Layer.succeed(UserRepo, {
  findById: (id) => Effect.succeed({ id, name: "Test", email: "test@test.com" }),
  create: (data) => Effect.succeed({ id: "new-id", ...data }),
});

// Run with real dependencies
Effect.runPromise(
  pipe(getUser("123"), Effect.provide(UserRepoLive))
);

// Run with test dependencies
Effect.runPromise(
  pipe(getUser("123"), Effect.provide(UserRepoTest))
);

Concurrency and Scheduling

// concurrent.ts — Structured concurrency with Effect
import { Effect, Schedule, Duration } from "effect";

// Run tasks concurrently with a limit
const processItems = (items: string[]) =>
  Effect.forEach(items, (item) => processItem(item), {
    concurrency: 5,    // Max 5 concurrent
    batching: true,     // Batch database calls
  });

// Retry with exponential backoff
const resilientFetch = (url: string) =>
  pipe(
    Effect.tryPromise(() => fetch(url).then((r) => r.json())),
    Effect.retry(
      Schedule.exponential(Duration.seconds(1)).pipe(
        Schedule.compose(Schedule.recurs(3)),  // Max 3 retries
        Schedule.jittered,                      // Add random jitter
      )
    ),
  );

// Timeout
const withTimeout = pipe(
  slowOperation(),
  Effect.timeout(Duration.seconds(5)),
);

// Race — first to complete wins
const fastest = Effect.race(
  fetchFromPrimary(),
  fetchFromFallback(),
);

Schema — Runtime Validation + Type Inference

// schema.ts — Validation with Effect Schema (replaces Zod)
import { Schema } from "effect";

const User = Schema.Struct({
  id: Schema.UUID,
  name: Schema.String.pipe(Schema.minLength(2), Schema.maxLength(100)),
  email: Schema.String.pipe(Schema.pattern(/^[^@]+@[^@]+\.[^@]+$/)),
  age: Schema.Number.pipe(Schema.int(), Schema.between(13, 120)),
  role: Schema.Literal("user", "admin"),
  createdAt: Schema.Date,
});

// Type is inferred — no duplicate definition
type User = Schema.Schema.Type<typeof User>;

// Decode (parse + validate)
const parseUser = Schema.decodeUnknown(User);
const result = Effect.runSync(parseUser({ id: "...", name: "Kai", email: "kai@example.com", age: 25, role: "user", createdAt: new Date() }));

Examples

Example 1: Build a payment processing pipeline

User prompt: "Build a payment flow with typed errors for each failure case — card declined, insufficient funds, fraud detected, network timeout."

The agent will define tagged error types for each failure, compose the payment pipeline with Effect.pipe, add retry for network errors, and propagate card/fraud errors to the caller with full type information.

Example 2: Testable service with dependency injection

User prompt: "I want to test my business logic without hitting the database."

The agent will define services as Effect Context.Tags, write business logic that depends on service interfaces, create Layer.succeed implementations for both production and test, and run the same logic against fake data in tests.

Guidelines

  • Start with Effect.tryPromise — wrap existing async code first, then gradually adopt more Effect patterns
  • Tag your errors — readonly _tag = "ErrorName" enables catchTag for precise error handling
  • Layers for DI — define service interfaces with Context.Tag, implement with Layer
  • pipe everything — Effect uses pipe-based composition; avoid nesting
  • Don't runPromise inside Effects — compose Effects together, run once at the entry point
  • Schema over Zod — Effect Schema integrates with the Effect ecosystem and is more composable
  • Concurrency is explicit — { concurrency: 5 } not hidden behind promise pools
  • Learning curve is real — Effect is powerful but complex; introduce gradually to a team
  • Effect is a runtime — it manages execution; don't mix with raw Promises inside Effects

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Scripts and configures production rendering in Autodesk 3ds Max with the V-Ray and Corona renderers: output size and files, render elements, denoising, light mix, batch and command-line rendering, and network rendering. Use when a user asks to set up a production render, render several cameras in one batch, render from the command line or on a render farm, add render passes for compositing, or cut render time for archviz and product shots.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

TerminalSkills/skills1722026년 10월 14일 업데이트

Covers scripting Autodesk 3ds Max, the 3D modeling and rendering application, with MAXScript and Python (pymxs): scene manipulation, object creation, material assignment, camera and light setup, batch operations, and file I/O. Use when tasks involve automating repetitive 3ds Max workflows, batch processing scenes, running scripts headless with 3dsmaxbatch, creating custom tools, or scripting scene setup for archviz, product visualization, or VFX.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

TerminalSkills/skills1722026년 10월 14일 업데이트

3proxy

무료

3proxy is a small open-source proxy server that runs HTTP/HTTPS, SOCKS4/5, SNI and TCP/UDP port-mapping proxies from one config file. Use when a user asks to set up an HTTP or SOCKS5 proxy, add proxy users and passwords, write 3proxy access rules, chain or rotate upstream (parent) proxies, limit bandwidth, connections or monthly traffic per user, run 3proxy in Docker, or fix a 3proxy.cfg that will not start.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

TerminalSkills/skills1722026년 10월 14일 업데이트

Builds Agent2Agent (A2A) servers and clients, the open protocol (originally from Google, now under the Linux Foundation) that lets AI agents from different frameworks call each other. Use when the user wants to create an A2A-compliant agent, build an Agent Card, implement task management, connect agents across frameworks, set up agent discovery, handle streaming responses, implement push notifications, or orchestrate multi-agent workflows. Trigger words: a2a, agent to agent, agent2agent, a2a protocol, a2a server, a2a client, agent card, agent interoperability, agent collaboration, multi-agent, agent discovery, a2a sdk, a2a task.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

TerminalSkills/skills1722026년 10월 14일 업데이트

Plans a controlled experiment (A/B test) so its result can be trusted: writes the hypothesis, picks one primary metric and the guardrails, computes sample size and run time, specifies how visitors are assigned and when exposure is logged, and reads out the result with a confidence interval. Use when someone says "set up an A/B test", "split test this page", "how many visitors do I need", "how long should the experiment run", "is this result significant", "can I stop the test early", or wants to test a headline, price, layout or onboarding change against the current version.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

TerminalSkills/skills1722026년 10월 14일 업데이트

ably

무료

Ably is a hosted realtime messaging service: clients publish and subscribe to named channels over WebSockets, see who is present, replay message history, and resume after a dropped connection. Use when a user asks to "add realtime updates", "push live notifications to the browser", "show who is online", "add a chat room with typing indicators", "publish from a serverless function", or "authenticate Ably clients without exposing the API key". Covers the ably 2.x JavaScript SDK (Realtime and REST), JWT token authentication, presence, history and rewind, batch publishing, and the @ably/chat 1.x SDK.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

TerminalSkills/skills1722026년 10월 14일 업데이트

TerminalSkills의 스킬 모두 보기

이 스킬의 문제 신고