effect-context-witness

Choose Effect Context.Service witness or capability patterns to decouple runtime dependencies from schemas.

22|1|Updated Apr 14, 2026
One-click install
npx skills add https://github.com/mpsuesser/pi-effect-harness --skill effect-context-witness
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: effect-context-witness
Source: https://github.com/mpsuesser/pi-effect-harness/tree/main/harnesses/effect/skills/effect-context-witness
Command: npx skills add https://github.com/mpsuesser/pi-effect-harness --skill effect-context-witness

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps you stop hard-coupling ephemeral runtime data to your Effect schemas by choosing the right Context pattern—witness (existence/value) versus capability (behavior)—so your domain models stay minimal and persistence-friendly.

Core Features & Use Cases

  • Witness pattern for soft coupling: remove non-essential fields from schemas (like request/correlation IDs or transaction markers) and inject them via Context.Service, keeping persisted data clean.
  • Capability pattern for operations: model reusable behavior (like generation/validation, clock operations, or logging methods) as a Context service so business logic can depend on functions, not globals.
  • Decision framework + testing guidance: apply clear rules for when to use witness vs capability and provide injection strategies that make testing straightforward.

Quick Start

Use effect-context-witness to refactor a Context dependency so non-persisted fields are removed from the schema and provided via a Context.Service witness instead.

Frequently Asked Questions about effect-context-witness

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

FAQPage Schema
How do I decouple runtime context from Effect schemas?

Use Context.Service witnesses to remove non-persisted fields like correlation or transaction IDs from Effect schemas, keeping persisted data clean. This decouples runtime dependency injection from your domain model by providing non-essential fields via separate context services.

When should I use the witness pattern versus the capability pattern in Effect-TS?

Use the witness pattern for existence or value injection like request context, and the capability pattern for operational behavior like validation, clock, or logging. This distinction ensures you model dependencies correctly by separating data existence from functional operations.

How do I model dependency injection for operational behavior in Effect?

Model reusable operations like generation, validation, or database access as Context services using the capability pattern. This allows business logic to depend on explicit functions rather than globals, requiring type-level service specifications for proper injection.

Can I test Effect schemas that use Context.Service witnesses?

Yes, Context.Service witnesses provide straightforward testing strategies for Effect schemas. By decoupling ephemeral runtime data and operational capabilities, you can inject mock dependencies during testing to isolate and verify schema behavior.

Why are non-persisted fields causing issues in my Effect schema design?

Hard-coupling ephemeral runtime data like transaction markers to Effect schemas pollutes persisted data. Removing these non-essential fields and providing them via Context witnesses keeps domain models minimal and persistence-friendly.

Does the capability pattern require explicit type-level service requirements in Effect?

Yes, modeling behavior as capabilities requires explicit type-level service requirements in Effect. This ensures business logic declares its operational dependencies like clock or logging methods at the type level for safe dependency injection.