.claude/skills/ts-effect-ts/SKILL.md
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.
npx skillsauth add eliferjunior/Claude effect-tsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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.
Every Effect value has three type parameters:
// 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: "[email protected]" })
)
// DatabaseError is NOT caught — it propagates up in the type
);
// 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: "[email protected]" }),
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))
);
// 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.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: "[email protected]", age: 25, role: "user", createdAt: new Date() }));
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.
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.
Effect.tryPromise — wrap existing async code first, then gradually adopt more Effect patternsreadonly _tag = "ErrorName" enables catchTag for precise error handlingpipe everything — Effect uses pipe-based composition; avoid nestingrunPromise inside Effects — compose Effects together, run once at the entry point{ concurrency: 5 } not hidden behind promise poolsdevelopment
Expert guidance for Fireworks AI, the platform for running open-source LLMs (Llama, Mixtral, Qwen, etc.) with enterprise-grade speed and reliability. Helps developers integrate Fireworks' inference API, fine-tune models, and deploy custom model endpoints with function calling and structured output support.
development
Convert any website into clean, structured data with Firecrawl — API-first web scraping service. Use when someone asks to "turn a website into markdown", "scrape website for LLM", "Firecrawl", "extract website content as clean text", "crawl and convert to structured data", or "scrape website for RAG". Covers single-page scraping, full-site crawling, structured extraction, and LLM-ready output.
tools
Expert guidance for Firebase, Google's platform for building and scaling web and mobile applications. Helps developers set up authentication, Firestore/Realtime Database, Cloud Functions, hosting, storage, and analytics using Firebase's SDK and CLI.
development
When the user needs to build file upload functionality for a web application. Use when the user mentions "file upload," "image upload," "upload endpoint," "multipart upload," "presigned URL," "S3 upload," "file validation," "upload to cloud storage," or "accept user files." Handles upload endpoints, file validation (type, size, magic bytes), cloud storage integration, and upload status tracking. For image/video processing after upload, see media-transcoder.