effect-program-design
它能做什么
它指导 AI 智能体用 TypeScript 构建 Effect 应用,包括清晰的服务、类型化错误,以及便于测试的层。适用于使用 Effect 库并希望代码易于维护的开发者。
适用场景
- ✓当你在 Effect 应用中构建或修改服务或层时。
- ✓当你需要在 Effect 程序中使用类型化错误、配置或后台工作线程时。
- ✓当你希望测试能在真实边界处替换为模拟依赖时。
技能链接
https://github.com/humanlayer/humanlayer/blob/main/.claude/skills/effect-program-design/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我在 Effect 应用中添加一个发送邮件的服务,要有完善的错误处理和测试。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会先检查你项目的约定和已安装的 Effect 版本,然后编写遵循该库模式的代码。它使用小型服务接口,让每个部分都便于测试。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Effect Program Design
Build production Effect v4 programs with small domain-shaped interfaces, typed success and error channels, declared dependencies, observable operation boundaries, and tests that substitute layers at real seams. This skill combines broad Effect mechanics with HumanLayer's deep-module, capture-before-narrow, and real-seam design standards.
Source rule
Check these before guessing:
- the nearest
CLAUDE.md/AGENTS.mdand project-local conventions; - the installed
effect,@effect/*, and related package versions and declarations; - the Effect v4 docs at https://effect-ts-effect-smol.mintlify.app/;
- the pinned/upstream source (
~/projects/effect-smol) when docs do not settle an API.
unstable-tagged modules (effect/http, effect/rpc, effect/process, ...) can change between beta/minor versions. Typecheck examples against the installed version. Local
project conventions take precedence unless the task explicitly changes them.
References
Read only the references relevant to the task; read all matching branches when work crosses concerns.
- Public module depth and domain-shaped APIs:
references/DEEP_MODULES.md. Read this any time you are modifying or creating services or layers - this is the core of our effect philosophy! - Service tags, live layers, file placement,
Effect.fn, or runtime composition:references/SERVICES_LAYERS.md. - Tagged errors, capture-before-narrow, spans, logs, or Sentry:
references/ERRORS_OBSERVABILITY.md. - Records, schemas, variants, optionality, brands, decoding, or construction:
references/SCHEMA_DATA_MODELING.md. - Config, env vars, providers, or secrets:
references/CONFIG_SECRETS.md. - HTTP/SDK/DB boundaries, Drizzle rows, JSONB, or transactions:
references/BOUNDARIES_PERSISTENCE.md. - Scopes, acquisition, concurrency, best-effort work, or workflow transitions:
references/RESOURCES_CONCURRENCY.md. - Retry, repeat, polling, pacing, backoff, or workers:
references/SCHEDULING_WORKERS.md. - Streams, queues, pubsub, pagination, backpressure, or long-lived consumers:
references/STREAMS.md. - Memoization, TTL caches, request dedupe, or batching:
references/CACHING_BATCHING.md. - Outgoing HTTP, provider adapters, status/decode handling, or HTTP retry:
references/HTTP_CLIENTS.md. - Effect tests, test services, clocks, synchronization, fakes, or real seams:
references/TESTING.md. - Platform-neutral services and the native-API boundary:
references/PLATFORM.md. - Node runtime, filesystem, path, crypto, child processes, sockets/WebSocket, Redis, or workers:
references/PLATFORM_NODE.md. - Effect Atom or React reactive Effect state:
references/EFFECT_ATOM.md. - TypeScript safety, Predicate refinements, Match dispatch, naming, collections, imports, and escape hatches:
references/TYPESCRIPT_CONTRACTS.md. - Local exemplars and foils:
references/REPOSITORY_EXAMPLES.md.
The creed
Deep modules. The interface is the cost and the hidden implementation is the benefit. Public operations use domain inputs and outputs; callers do not supply credentials, clients, rows, or other internals.
Everything stays in Effect. Keep expected failures in
E, dependencies inR, and resources in scopes. Do not pass services, layers, effects, or errors as ordinary values when composition expresses the relationship.Two-tier errors. Classify rich internal failures, capture them, then narrow to a small caller-actionable union. Prefer typed
catchTag/catchTags; never recover withinstanceof,Match, or manual_tagcomparisons. Respect the error channel! Errors stay in the error channel and are not passed as valuesObserve operations. Every public operation has a stable
Effect.fn("domain.operation"), an explicitEffect.withSpan, or both. Capture raw actionable/unexpected failures before narrowing or swallowing them.
Use Effect's logger to log info, errors, etc -yield* Effect.logError- do NOT pass in external loggers. Errors MUST also be captured to sentry as soon as they surface before they are re-mapped or transformed.someEffect.pipe( Effect.tapError(Effect.logError), Effect.tapError((e) => Effect.sync(() => Sentry.captureException(e))), )Test at real seams. Use
@effect/vitest, layers, deterministic test services, and real infrastructure where behavior depends on it. Assert both the result/error and externally v
常见问题
我需要已经懂 Effect 吗?
了解一些 TypeScript 会有帮助,但该技能会指导智能体使用 Effect 的模式。
它会匹配我已安装的 Effect 版本吗?
会。它会检查已安装的版本,并针对该版本对示例进行类型检查,因为某些模块在不同版本之间会有变化。
它涵盖 Effect 的哪些部分?
它涵盖服务、模式、错误、配置、并发、流、缓存和 HTTP 客户端。
详情
作者的原始描述
Design, write, review, and test production Effect v4 programs: deep services and layers, schemas, tagged errors, observability, Config, persistence, resources, concurrency, schedules, workers, streams, caches, HTTP clients, Effect platform services (Node filesystem/path/crypto/process/socket), and Effect Atom integrations. Use for any Effect application or adapter work.
repo: humanlayer/humanlayer
热度
- GitHub 星标
- 13k
- 排名
- #11384
- 许可证
- Apache-2.0
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
asd-ste100
13k教你的智能体把难懂的英文改写成短句、每句只有一个意思,方便人和其他软件阅读。
better-github-skill
13k帮你的智能体查看拉取请求的状态、阅读其审查评论,并借助现成的 GitHub 脚本找出 CI 构建失败的原因。
calldiff
13k帮你的智能体比较代码库中两个 git 版本之间的函数调用链,让代码审查能看出行为发生了什么变化。
chrome-devtools-cli
13k帮你的智能体通过终端控制 Chrome,打开页面、点击、填写表单,并截取页面快照,用于浏览器自动化和测试。