effect-context-witness

Guides choosing between Context.Service witness and capability patterns for dependency injection in Effect.

1|Updated Aug 24, 2026
One-click install
npx skills add https://github.com/lambdasolver2/opencode-effect-harness --skill effect-context-witness-lambdasolver2
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: effect-context-witness
Source: https://github.com/lambdasolver2/opencode-effect-harness/tree/main/packages/module-typescript/assets/skills/effect-context-witness
Command: npx skills add https://github.com/lambdasolver2/opencode-effect-harness --skill effect-context-witness-lambdasolver2

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires effect.

What problem does it solve? When building Effect applications, developers struggle to decide whether a dependency should be modeled as a simple witness (a value that exists in the environment) or a full capability (a service with operations), and whether fields belong in the domain schema or should be injected via Context. Wrong choices lead to bloated schemas, hard coupling, and difficult testing. ## Core Features & Use Cases - Witness vs Capability Decision Framework: Provides a decision table mapping needs (presence, operations, mocking, side effects) to the correct Context.Service pattern. - Hard vs Soft Coupling Guidance: Shows how to remove non-persisted fields (correlation IDs, request IDs, timestamps) from Schema definitions and inject them as witnesses instead. - Testing Implications: Demonstrates how witnesses are trivially provided with Effect.provideService while capabilities require full implementations. - Use Case: When modeling an Order or PaymentIntent, keep only persisted data in the Schema and inject CorrelationId, RequestId, and Clock values through Context, yielding explicit dependencies in the Effect type signature. ## Quick Start Ask the assistant to review your Effect service definitions and decide whether each dependency should be a witness or a capability using the effect-context-witness guidance.

Frequently Asked Questions about effect-context-witness

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I choose between a witness and a capability in Effect Context.Service?

Use a witness when you only need a value to exist in the environment, such as a correlation ID or tenant marker. Use a capability when you need operations like generating, validating, logging, or querying, or when you need multiple implementations and behavior mocking.

Should correlation IDs be fields in my Effect Schema?

No, correlation IDs should not be in the schema unless they must be persisted. Remove them from the Schema and inject them via a Context.Service witness, keeping domain models minimal and making dependencies explicit in the Effect type signature.

How do I test Effect code that depends on a Context witness?

Provide the witness value directly with Effect.provideService, passing a plain test value such as a fixed serial string. Witnesses require no implementation, unlike capabilities which need a full object with all operations defined.

When should I use a capability service instead of a witness in Effect?

Use a capability when you need behavior such as a Clock now() operation, a Logger with structured methods, a database with query operations, or serial generation and validation. Capabilities also suit cases needing multiple implementations or mocked behavior.

What is the difference between hard and soft coupling in Effect schemas?

Hard coupling places a field directly in the Schema, forcing every value to include it and requiring schema changes to modify it. Soft coupling removes the field from the schema and injects it via Context, making it easy to test, change, or remove without touching persisted data.