effect-concurrency-testing

Test Effect concurrency primitives including PubSub, Deferred, Latch, fibers, and streams.

3|Updated Apr 1, 2026
One-click install
npx skills add https://github.com/mpsuesser/opencode-effect-enforcer --skill effect-concurrency-testing-mpsuesser
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: effect-concurrency-testing
Source: https://github.com/mpsuesser/opencode-effect-enforcer/tree/main/skills/effect-concurrency-testing
Command: npx skills add https://github.com/mpsuesser/opencode-effect-enforcer --skill effect-concurrency-testing-mpsuesser

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing deterministic tests for concurrent Effect code is difficult: fibers race, PubSub subscriptions miss events, and TestClock gets misused for non-time-dependent logic. This Skill provides proven patterns for testing Effect's concurrency primitives without flaky race conditions. ## Core Features & Use Cases - Fiber Coordination Patterns: Use Effect.yieldNow, Latch, Deferred, and fiber.pollUnsafe() to coordinate and inspect fibers deterministically. - PubSub and SubscriptionRef Testing: Verify published events with scoped subscriptions, readiness signals, and latch-gated stream subscriptions. - Stream and Interruption Testing: Collect stream results, verify finalizers, and assert interruption with Exit.hasInterrupts and Cause.hasInterruptsOnly. - Use Case: When testing a service that publishes user events to a PubSub, subscribe inside Effect.scoped, trigger the service method, and assert the exact events received with PubSub.takeAll. ## Quick Start Ask the agent to write a deterministic test for a concurrent Effect workflow using the effect-concurrency-testing skill, for example testing a PubSub event publisher or a latch-coordinated fiber.

Frequently Asked Questions about effect-concurrency-testing

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

FAQPage Schema
How do I test Effect PubSub events deterministically?▼

Subscribe inside Effect.scoped, publish events, then use PubSub.takeAll or PubSub.takeUpTo to assert received values. For concurrent publishers, signal subscription readiness with a Deferred before publishing so no messages are dropped.

When should I use Latch vs Deferred in Effect tests?▼

Use Latch as a gate that blocks fibers until opened, ideal for waiting on stream elements or coordinating multiple fibers. Use Deferred when one fiber must signal another with a value, such as confirming a subscription is registered.

Should I use TestClock or Effect.yieldNow for fiber testing?▼

Use Effect.yieldNow for simple fiber scheduling in non-time-dependent code. Reserve TestClock.adjust only for genuinely time-dependent behavior like delays, timeouts, or schedules, since misusing TestClock adds unnecessary complexity.

How do I test fiber interruption in Effect?▼

Fork the effect, call Fiber.interrupt, then Fiber.await the result and assert with Exit.hasInterrupts. To verify the cause contains only interruption, combine Exit.isFailure with Cause.hasInterruptsOnly.

Why does my SubscriptionRef stream test miss events?▼

The subscription likely starts after the first mutation, so earlier changes are never observed. Gate the test with a Latch opened via Stream.tap so the subscription is confirmed active before calling SubscriptionRef.update.