Core Effect foundations and style for a coding agent. Use when starting an Effect task, choosing operators, or structuring a small pipeline.
Purpose: Provide a compact, go-to checklist for writing idiomatic Effect TypeScript with data-first pipe style, minimal imperative code, and strong typing. Optimized for a coding agent with limited context.
Effect<E, A, R>).pipe() style for readabilityEffect.gen for sequential logic; Effect.all for parallelismEffect.succeed, failures with Effect.failData.TaggedError and recover with catchTag(s)anyR (requirements) is not never, provide layers explicitlyconst value = Effect.succeed(42)
const failure = Effect.fail(new MyError())
const result = value.pipe(
Effect.map((n) => n * 2),
Effect.tap((n) => Effect.log(`n=${n}`))
)
const program = Effect.gen(function* () {
const a = yield* getA()
const b = yield* getB(a)
return b
})
const both = yield* Effect.all([left(), right()], { concurrency: "unbounded" })
Effect.mapEffect.flatMapEffect.andThenEffect.tapEffect.provide/layers (see layers skill)Layer.merge, Layer.provideEffect.gen: write sequential code with yield* for each EffectEffect.all(values, { concurrency }): run independent Effects concurrentlyEffect.catchTags(...): recover only specific typed errorsLayer.merge(a, b): compose dependencies once, reuse everywhereEffect.runPromise(...): bridge Effects to async workflowsimport { Effect, Match, Data } from "effect"
class UnsupportedPlatformError extends Data.TaggedError("UnsupportedPlatformError")<{
readonly platform: string
readonly arch: string
}>{}
const detectPlatform = (rawPlatform: string, rawArch: string) => Effect.gen(function* () {
const platform = yield* Match.value(rawPlatform).pipe(
Match.when("darwin", () => Effect.succeed("darwin" as const)),
Match.when("linux", () => Effect.succeed("linux" as const)),
Match.orElse(() => Effect.fail(new UnsupportedPlatformError({ platform: rawPlatform, arch: rawArch })))
)
const arch = yield* Match.value(rawArch).pipe(
Match.when("x64", () => Effect.succeed("x64" as const)),
Match.when("arm64", () => Effect.succeed("aarch64" as const)),
Match.when("aarch64", () => Effect.succeed("aarch64" as const)),
Match.orElse(() => Effect.fail(new UnsupportedPlatformError({ platform: rawPlatform, arch: rawArch })))
)
return { platform, arch }
})
program.pipe(
Effect.catchTag("DomainError", () => Effect.succeed(fallback)),
Effect.catchAll((e) => Effect.fail(new WrappedError({ cause: e })))
)
Effect.gen, Effect.all, .pipe(Effect.try/tryPromiseEffect.gen—always yield* an EffectR requirements → provide layers or adjust architectureCRITICAL: Search local Effect source before implementing
The full Effect source code is available at docs/effect-source/. Always search the actual implementation before writing Effect code.
docs/effect-source/effect/src/Effect.tsdocs/effect-source/effect/src/Layer.tsdocs/effect-source/effect/src/Data.tsdocs/effect-source/effect/src/Match.ts# Find Effect.gen implementation and patterns
grep -rF "Effect.gen" docs/effect-source/effect/src/
# Find all map/flatMap/andThen variants
grep -rF "export" docs/effect-source/effect/src/Effect.ts | grep -F "map"
grep -rF "export" docs/effect-source/effect/src/Effect.ts | grep -F "flatMap"
grep -rF "export" docs/effect-source/effect/src/Effect.ts | grep -F "andThen"
# Study error handling patterns
grep -rF "catchTag" docs/effect-source/effect/src/
grep -rF "catchAll" docs/effect-source/effect/src/
grep -rF "TaggedError" docs/effect-source/effect/src/
# Find Effect.all concurrency patterns
grep -rF "Effect.all" docs/effect-source/effect/src/
docs/effect-source/effect/src/Effect.ts for the implementationdocs/effect-source/effect/test/ for usage examplesReal source code > documentation > assumptions
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer