API 与服务器(后端)28k · #9874
effect
它能做什么
它指导使用 Effect 库编写 TypeScript 代码,包括服务、模式、类型化错误和多步骤工作流。适合使用 Effect、并希望代码准确且符合当前版本的开发者。
适用场景
- ✓当你在编写或修改使用 Effect 的 TypeScript 代码时。
- ✓当你需要用 Effect 构建的类型化错误、模式或服务时。
- ✓当你希望根据库的源代码检查当前的 Effect v4 模式时。
技能链接
https://github.com/Kilo-Org/kilocode/blob/main/.opencode/skills/effect/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
请用这个技能帮我:https://github.com/Kilo-Org/kilocode/blob/main/.opencode/skills/effect/SKILL.md
阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
npx skills add Kilo-Org/kilocode --skill effect
下载 SKILL.md,放进智能体的技能文件夹。
curl -L https://raw.githubusercontent.com/Kilo-Org/kilocode/main/.opencode/skills/effect/SKILL.md -o SKILL.md
可以这样问 AI
“我的 TypeScript 后端需要一个服务,使用 Effect,包含类型化错误,并为请求数据提供一个模式。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体查阅当前 Effect 库的源代码,以获取准确的 API 和示例,遵循项目已有的模式,然后编写代码。它让 HTTP 处理程序保持简洁,并把业务规则放在服务中。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Effect
This codebase uses Effect for typed, composable TypeScript services, schemas, and workflows.
Source Of Truth
Use the current Effect v4 / effect-smol source, not memory or older Effect v2/v3 examples.
- If
.opencode/references/effect-smolis missing, clonehttps://github.com/Effect-TS/effect-smolthere. Do this in the project, not in the skill folder. - Search
.opencode/references/effect-smolfor exact APIs, examples, tests, and naming patterns before answering or implementing Effect-specific code. - Also inspect existing repo code for local house style before introducing new patterns.
- Prefer answers and implementations backed by specific source files or nearby repo examples.
Guidelines
- Prefer current Effect v4 APIs and project-local patterns over old blog posts, examples, or package-memory guesses.
- Use
Effect.gen(function* () { ... })for multi-step workflows. - Use
Effect.fn("Name")orEffect.fnUntraced(...)for named effects when adding reusable service methods or important workflows. - Prefer Effect
Schemafor API and domain data shapes. Use branded schemas for IDs andSchema.TaggedErrorClassfor typed domain errors when modeling new error surfaces. - Keep HTTP handlers thin: decode input, read request context, call services, and map transport errors. Put business rules in services.
- In Effect service code, prefer Effect-aware platform abstractions and dependencies over ad hoc promises where the surrounding code already does so.
- Keep layer composition explicit. Avoid broad hidden provisioning that makes missing dependencies hard to see.
- In tests, prefer the repo's existing Effect test helpers and live tests for filesystem, git, child process, locks, or timing behavior.
- Do not introduce
any, non-null assertions, unchecked casts, or older Effect APIs just to satisfy types. - Do not answer from memory. Verify against
.opencode/references/effect-smolor nearby code first.
Testing Patterns
- Use
testEffect(...)frompackages/opencode/test/lib/effect.tsfor tests that exercise Effect services, layers, runtime context, scoped resources, or platform integrations. - Use
it.live(...)for filesystem, git repositories, HTTP servers, sockets, child processes, locks, real time, and other live platform behavior. - Run tests from package directories such as
packages/opencode; never run package tests from the repo root. - Prefer explicit test layers over ad hoc managed runtimes. Keep dependency provisioning visible in the test file.
- Use scoped fixtures and finalizers for resources that must be cleaned up, including temporary directories, flags, databases, fibers, servers, and global state.
常见问题
它面向哪个 Effect 版本?
它面向 Effect v4,也称为 effect-smol,而不是较旧的 v2 或 v3 示例。
它在哪里查找 API?
它会搜索 effect-smol 源代码的本地副本,如果缺失则会克隆它。
错误如何处理?
领域错误使用带标签的错误类,以便能够通过类型进行处理。
详情
热度
- GitHub 星标
- 28k
- 排名
- #9874
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …