一键导入
effect-patterns-services-agents
// Effect-TS service and agent patterns for this repo. Use when implementing or modifying services in packages/mcp-server, adding agents, or following Effect.Service, Layer, and error-handling conventions.
// Effect-TS service and agent patterns for this repo. Use when implementing or modifying services in packages/mcp-server, adding agents, or following Effect.Service, Layer, and error-handling conventions.
Effect-TS patterns for Core Concepts. Use when working with core concepts in Effect-TS applications.
Effect-TS patterns for Building Apis. Use when working with building apis in Effect-TS applications.
Effect-TS patterns for Building Data Pipelines. Use when working with building data pipelines in Effect-TS applications.
Effect-TS patterns for Concurrency Getting Started. Use when working with concurrency getting started in Effect-TS applications.
Effect-TS patterns for Concurrency. Use when working with concurrency in Effect-TS applications.
Effect-TS patterns for Domain Modeling. Use when working with domain modeling in Effect-TS applications.
| name | effect-patterns-services-agents |
| description | Effect-TS service and agent patterns for this repo. Use when implementing or modifying services in packages/mcp-server, adding agents, or following Effect.Service, Layer, and error-handling conventions. |
Use Effect's Service pattern for composable, type-safe dependency injection:
import { Effect, Context } from "effect"
export class MyService extends Context.Tag("MyService")<MyService, {
method: () => Effect.Effect<string>
}>() {}
const effect = Effect.gen(function* () {
const service = yield* MyService
const result = yield* service.method()
return result
})
Modern form with Effect.Service:
export class MyAgent extends Effect.Service<MyAgent>()("MyAgent", {
effect: Effect.gen(function* () {
return {
analyze: (input: string) => Effect.succeed("result")
}
})
})
Use this layout for agents and service modules:
agents/
├── analyzer/
│ ├── api.ts # Public interface
│ ├── schema.ts # Type definitions
│ ├── service.ts # Core logic
│ ├── types.ts # Domain types
│ └── __tests__/ # Test suite
Use tagged error types; recover with catchTag:
import { Data } from "effect"
export class APIError extends Data.TaggedError("APIError")<{
readonly status: number
readonly message: string
}> {}
Effect.catchTag("APIError", (err) => /* handle */)
Compose services via Effect.Layer; provide to the app with Effect.provide:
const appLayer = Layer.mergeAll(
ConfigService.layer,
CacheService.layer,
CircuitBreakerService.layer,
RateLimiterService.layer,
ReviewCodeService.layer,
)
Effect.provide(appEffect, appLayer)
workspace:* dependencies; run from project root.scripts/debug-blocking.ts for correct module resolution.