From effect-ts
This skill should be used ANY TIME you're writing TypeScript with Effect, especially when the user asks about "Effect type", "creating effects", "running effects", "Effect.gen", "Effect.succeed", "Effect.fail", "Effect.sync", "Effect.promise", "Effect.tryPromise", "Effect.runPromise", "Effect.runSync", "pipe", "andThen", "flatMap", "map", "Effect basics", or needs to understand the fundamental Effect<Success, Error, Requirements> type and how to create, compose, and run effects.
npx claudepluginhub andrueandersoncs/claude-skill-effect-ts --plugin effect-tsThis skill uses the workspace's default tool permissions.
**Before writing ANY Effect code, you MUST read and follow the [Code Style](../code-style/SKILL.md) skill ([view on GitHub](https://github.com/andrueandersoncs/claude-skill-effect-ts/blob/main/skills/code-style/SKILL.md)).** This skill covers core APIs and composition only — the Code Style skill defines the mandatory patterns, forbidden anti-patterns, and idiomatic conventions that apply to ALL...
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Checks Next.js compilation errors using a running Turbopack dev server after code edits. Fixes actionable issues before reporting complete. Replaces `next build`.
Before writing ANY Effect code, you MUST read and follow the Code Style skill (view on GitHub). This skill covers core APIs and composition only — the Code Style skill defines the mandatory patterns, forbidden anti-patterns, and idiomatic conventions that apply to ALL Effect code you produce. Every code example you generate must conform to those rules.
Effect is the foundational type in Effect-TS representing a computation that may succeed with value A, fail with error E, or require context R:
Effect<Success, Error, Requirements>;
// Also written as: Effect<A, E, R>
The key insight: Effects are descriptions of programs, not executed code. They must be explicitly run.
import { Effect } from "effect";
const success = Effect.succeed(42);
const failure = Effect.fail(new Error("Something went wrong"));
const lazy = Effect.sync(() => {
console.log("Computing...");
return Math.random();
});
// Sync that may throw (converts exception to typed error)
const mayThrow = Effect.try({
try: () => someLegacyFunction(),
catch: (error) => new LegacyError({ cause: error }),
});
// For JSON parsing, prefer Schema.parseJson (type-safe and validated)
const UserInput = Schema.parseJson(
Schema.Struct({
name: Schema.String,
value: Schema.Number,
}),
);
const parsed = Schema.decodeUnknown(UserInput)(userInput);
// From Promise (untyped error)
const fromPromise = Effect.promise(() => fetch("/api/data"));
// From Promise with typed error
const fromPromiseTyped = Effect.tryPromise({
try: () => fetch("/api/data"),
catch: (error) => new FetchError({ cause: error }),
});
import { Effect, pipe } from "effect";
const program = pipe(
Effect.succeed(1),
Effect.map((n) => n + 1),
Effect.flatMap((n) => Effect.succeed(n * 2)),
Effect.andThen((n) => Effect.succeed(`Result: ${n}`)),
);
The generator syntax (Effect.gen) provides cleaner, more readable code:
const program = Effect.gen(function* () {
const a = yield* Effect.succeed(1);
const b = yield* Effect.succeed(2);
const result = a + b;
return `Sum: ${result}`;
});
Equivalent to:
const program = Effect.succeed(1).pipe(
Effect.flatMap((a) => Effect.succeed(2).pipe(Effect.flatMap((b) => Effect.succeed(`Sum: ${a + b}`)))),
);
Effects are descriptions that must be run to produce values:
import { Effect } from "effect";
const program = Effect.succeed(42);
const result = await Effect.runPromise(program);
const syncResult = Effect.runSync(Effect.succeed(42));
const exit = await Effect.runPromiseExit(program);
| Method | Use Case |
|---|---|
Effect.runPromise | Async effect → Promise (throws on failure) |
Effect.runPromiseExit | Async effect → Promise (never throws) |
Effect.runSync | Sync effect → value (throws on async/failure) |
Effect.runSyncExit | Sync effect → Exit (throws on async) |
Effect.succeed(5).pipe(Effect.map((n) => n * 2));
const getUser = (id: number) => Effect.succeed({ id, name: "Alice" });
const getPosts = (userId: number) => Effect.succeed([{ title: "Post 1" }]);
const program = getUser(1).pipe(Effect.flatMap((user) => getPosts(user.id)));
Effect.succeed(42).pipe(
Effect.tap((n) => Effect.log(`Got value: ${n}`)),
Effect.map((n) => n * 2),
);
// Tuple of effects
const tuple = Effect.all([Effect.succeed(1), Effect.succeed("hello"), Effect.succeed(true)]); // Effect<[number, string, boolean], never, never>
// Object of effects
const obj = Effect.all({
id: Effect.succeed(1),
name: Effect.succeed("Alice"),
}); // Effect<{ id: number; name: string }, never, never>
| Promise | Effect |
|---|---|
new Promise((resolve) => resolve(1)) | Effect.succeed(1) |
Promise.reject(error) | Effect.fail(error) |
promise.then(f) | effect.pipe(Effect.map(f)) |
promise.then(f) (f returns Promise) | effect.pipe(Effect.flatMap(f)) |
Promise.all([...]) | Effect.all([...]) |
await promise | yield* effect (in Effect.gen) |
Most Effect functions support both "data-first" and "data-last" (pipeable) styles:
// Data-last (pipeable) - recommended
Effect.succeed(1).pipe(Effect.map((n) => n + 1));
// Data-first
Effect.map(Effect.succeed(1), (n) => n + 1);
For the complete list of mandatory patterns, forbidden anti-patterns, and idiomatic conventions, see the Code Style skill (GitHub).
For comprehensive documentation on all Effect APIs, patterns, and advanced usage, consult the full Effect documentation at ${CLAUDE_PLUGIN_ROOT}/references/llms-full.txt.
Search for these sections: