Effect Enforcer
OpenCode V2 plugin for Effect v4 skills, guidance, and pattern enforcement
6
近 30 天 +4
946
近 7 天 202
49.9
生态多维模型
2 天前
2026-10-02
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-effect-enforcer@0.3.0"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-effect-enforcer@0.3.0"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D opencode-effect-enforcerOpenCode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
Spend less time teaching your coding agent Effect.
If you keep reminding your agent to use typed errors, decode with Schema, or check the current API, this plugin gives those reminders a permanent home in OpenCode V2. It includes Effect guidance and skills the agent can consult while working, plus checks that send common mistakes back for correction after edits.
How it helps
Guidance is included before every model call. Four documents cover Effect-first design, schema-first modeling, typed dependencies, and how to choose the relevant skills.
Skills explain how to use specific Effect APIs. The agent loads the relevant guides through OpenCode's native skill tool, with 53 to choose from across services, streams, HTTP, SQL, React, AI, and more.
Patterns check the code after edits. 45 tested checks look for common TypeScript and TSX mistakes and return correction advice and relevant skill suggestions to the agent for its next turn.
Checks run after successful write, edit, patch, and apply_patch calls.
Edits and patches are checked only in newly added text; full-file writes and new
files are checked in full. Feedback asks the agent to fix valid findings or
explain intentional exceptions. Checks are advisory and do not block writes.
The bundled guidance and skills target Effect 4.0.0 (stable).
See the rc.116 → 4.0.0 migration audit
and complete upstream release notes.
Install
Add the plugin to opencode.jsonc in your project, or
~/.config/opencode/opencode.jsonc for all projects:
{
"$schema": "https://opencode.ai/config.json",
"plugins": ["opencode-effect-enforcer"],
}
Start a new session. OpenCode installs the package automatically.
Explore what's included
Browse the guidance, find a skill for your next task, or see what the patterns look for.
Guidance (4)
- Effect-First Development: Defines the Effect-first operating model, laws, templates, boundaries, and review checklist.
- Agent Rules: Routes agents to the right skills and authoritative Effect v4 source references.
- Effect, and the Near-Inexpressible Majesty of Layers: Explains services, Layers, typed dependencies, and testable implementations.
- Parse, don't validate: Shows how refined types preserve validation knowledge and make illegal states unrepresentable.
Skills (53)
Modeling and core APIs
effect-error-handling: Model typed failures, inspect causes, report errors, and recover precisely.effect-schema-v4: Use current Effect Schema v4 APIs and migrate away from v3 patterns.effect-schema-composition: Compose schemas with transformations, filters, validation, andSchema.decodeTo.effect-domain-modeling: Build schema-backed domain entities, ADTs, guards, orders, and matchers.effect-domain-predicates: Derive reusable predicates and orderings for domain types.effect-pattern-matching: Match discriminated unions and Effect results exhaustively.effect-optics: Read and immutably update nested data with lenses, prisms, and traversals.effect-typeclass-design: Design typeclasses with curried signatures and dual data-first/data-last APIs.effect-graph: Construct, traverse, analyze, and render immutable graphs.
Services, lifecycle, and concurrency
effect-context-witness: Choose between service witnesses and capability-based dependency injection.effect-service-implementation: Implement focused Effect services without monolithic interfaces.effect-layer-design: Design and compose Layers with explicit dependency wiring.effect-scope: Manage resource acquisition, finalization, and scope ownership safely.effect-fiber: Fork, supervise, interrupt, and coordinate fibers and keyed fiber collections.effect-parallelization: Run, race, gate, and concurrency-limit Effect computations.effect-scheduling: Define retries, repeats, polling, backoff, pacing, and timeouts withSchedule.effect-cache: Cache effectful lookups with TTL, invalidation, deduplication, and scoped entries.effect-batching: Batch and deduplicate requests withRequest,RequestResolver, andSqlResolver.effect-stream: Build resource-safe streaming pipelines with transformations, concurrency, and codecs.effect-pubsub-event-bus: Implement typed publish/subscribe event buses with PubSub and Stream.effect-workflow: Build durable workflows, activities, queues, clocks, and compensating transactions.
Platform and runtime integration
effect-platform-abstraction: Keep filesystem, process, HTTP, crypto, and terminal code portable.effect-platform-layers: Provide platform implementations cleanly at application boundaries.effect-managed-runtime: Run Effect services inside frameworks and runtimes Effect does not own.effect-filesystem: Perform platform-independent file I/O through Effect'sFileSystem.effect-path: Join, resolve, normalize, and convert paths through Effect'sPathservice.effect-command-executor: Spawn, stream, pipe, and safely manage child processes.effect-socket: Build TCP, Unix-domain, and WebSocket clients, servers, and framed transports.effect-cli: Build type-safe command-line interfaces with arguments, options, commands, and Layers.
HTTP, RPC, and persistence
effect-http-api: Define typed HTTP APIs with schemas, security, handlers, clients, and OpenAPI.effect-http-client: Make typed outgoing HTTP requests with decoding, retries, streaming, and test transports.effect-http-server: Serve routes, middleware, uploads, static files, streams, and WebSockets.effect-rpc-api: Define shared typed RPC contracts, middleware, errors, and streaming procedures.effect-rpc-client: Consume RPC contracts over HTTP, WebSocket, TCP, workers, or in-memory transports.effect-rpc-server: Implement and serve RPC handlers with middleware, streaming, and interruption support.effect-rpc-cluster: Build clustered RPC entities, sharding, singletons, cron jobs, and workflows.effect-sql: Query databases and build schemas, models, resolvers, repositories, and migrations.
AI and MCP
effect-ai-language-model: Generate text, structured output, streams, and tool calls throughLanguageModel.effect-ai-prompt: Construct and compose prompts from messages and multimodal parts.effect-ai-tool: Define type-safe AI tools, toolkits, schemas, and handlers.effect-ai-provider: Configure provider Layers, models, runtime overrides, and fallback execution plans.effect-ai-streaming: Consume AI start/delta/end streams with safe accumulation and history updates.effect-ai-chat: Build persistent multi-turn chats and agentic tool-calling loops.effect-mcp-server: Expose MCP tools, resources, and prompts over stdio or HTTP.
Frontend state and composition
effect-atom-state: Manage reactive React state with Effect Atom.effect-atom-rpc: Build cached, invalidating, SSR-aware RPC atoms for React clients.effect-react-composition: Compose React components around explicit Effect Atom state and behavior.
Configuration, operations, and testing
effect-config: Load, validate, compose, and test typed configuration sources.effect-observability: Add structured logs, traces, metrics, and OTLP or Prometheus export.effect-wide-events: Design information-rich canonical log events for observability.effect-testing: Test Effect programs, services, Layers, time, errors, and properties.effect-concurrency-testing: Test fibers, PubSub, Deferred, Latch, SubscriptionRef, and concurrent streams.effect-incremental-migration: Migrate Promise-based modules incrementally while preserving required compatibility.
Patterns (45)
Types, modeling, and collections
avoid-any: Flags assertions toanyorunknownthat erase type safety.casting-awareness: Reviews type assertions and suggests decoding, guards, orsatisfies.avoid-ts-ignore: Detects@ts-ignoreand@ts-expect-errorsuppressions.avoid-non-null-assertion: Detects TypeScript non-null assertions.avoid-object-type: Rejects impreciseObjectand{}type annotations.prefer-option-over-null: Reviews nullable unions that may be better represented byOption.avoid-option-getorthrow: Replaces unsafeOption.getOrThrowcalls with explicit handling.avoid-schema-suffix: Encourages schema constants named after their domain concepts.prefer-schema-class: ReviewsSchema.Structwhere decoded values need class identity.avoid-direct-json: Reviews direct JSON methods in favor of schema JSON codecs.prefer-match-over-switch: Replaces nativeswitchstatements with exhaustive Effect matching.avoid-direct-tag-checks: Replaces direct_tagcomparisons with exported refinements or predicates.imperative-loops: Replaces imperative loops with functional collection transformations.prefer-arr-sort: Replaces native array sorting withArr.sortand explicitOrder.
Errors and Effect boundaries
avoid-data-tagged-error: Reviews public or serializedData.TaggedErrorvalues for schema-backed errors.avoid-untagged-errors: Reviews rawErrorconstruction and discrimination in recoverable code.avoid-try-catch: Replacestry/catchin Effect code with typed Effect constructors.throw-in-effect-gen: Detects thrown exceptions inside Effect generators and functions.effect-catchall-default: Reviews broad catch-and-default recovery that may hide failures.effect-promise-vs-trypromise: UsesEffect.tryPromisewhen Promise rejection must enter the error channel.effect-run-in-body: KeepsEffect.runSync,runPromise, andrunForkat runtime boundaries.prefer-effect-fn: Wraps service methods with named, tracedEffect.fndefinitions.avoid-yield-ref: Replaces direct yielding of Ref, Deferred, Fiber, and Latch with explicit operations.
Services, concurrency, and time
context-tag-extends: Replaces legacy service-tag APIs withContext.Service.avoid-mutable-state: Reviews mutableletstate inside Effect services in favor ofRef.yield-in-for-loop: Replaces effectful loop bodies with Effect or STM collection combinators.require-effect-concurrency: Requires explicit concurrency for Effect collection combinators.prefer-duration-values: Replaces numeric time literals with typedDurationvalues.use-clock-service: Replaces JavaScriptDateoperations with testable DateTime or Clock effects.use-random-service: ReplacesMath.random()with Effect's testable Random service.use-console-service: Replaces native console calls with Effect logging or Console services.
Platform, I/O, and configuration
avoid-native-fetch: Replaces nativefetchwith Effect HTTP client modules.use-http-client-service: Replacesnode:httpandnode:httpswith EffectHttpClient.use-filesystem-service: Replaces Node filesystem imports with EffectFileSystem.avoid-sync-fs: Detects synchronous filesystem operations.stream-large-files: Reviews whole-file reads of likely large or unbounded inputs.use-path-service: Replaces Node path imports with Effect'sPathservice.use-temp-file-scoped: Requires scoped temporary files and directories with automatic cleanup.use-command-executor-service: Replacesnode:child_processwith Effect process services.avoid-node-imports: Catches Node imports not covered by a more specific platform rule.avoid-platform-coupling: Prevents binding packages from hardwiring Bun or Node platform Layers.avoid-process-env: Replaces direct environment access with Effect Config.prefer-redacted-config: Requires secret-like configuration values to remain redacted.
React and testing conventions
avoid-react-hooks: Reviews React state and effects for Effect Atom alternatives.avoid-expect-in-if: Prevents conditional assertions that allow tests to pass without checking behavior.
License
同类生态推荐
Speech Act Theory
opencode-speech-act-theory
OpenCode plugin that converts unstructured instructions into structured rules using speech act theory and deontic logic.
Skills Tui
opencode-skills-tui
OpenCode TUI plugin that shows skills and loaded state in the sidebar
Tui
@skwid138/opencode-tui
Configurable TUI plugin for OpenCode — custom logo and prompt placeholders