effect-patterns-concurrency

Structure Effect-TS asynchronous workflows with race, semaphore, Ref, and PubSub patterns.

Updated Jan 24, 2026
One-click install
npx skills add https://github.com/scotttrinh/nook --skill effect-patterns-concurrency-scotttrinh
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: effect-patterns-concurrency
Source: https://github.com/scotttrinh/nook/tree/main/.agents/skills/effect-patterns-concurrency
Command: npx skills add https://github.com/scotttrinh/nook --skill effect-patterns-concurrency-scotttrinh

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Effect-TS concurrency patterns help developers implement robust, efficient concurrent workflows by providing reusable abstractions for common coordination tasks.

Core Features & Use Cases

  • Race: Use Effect.race to obtain the fastest result while interrupting losers; suitable for multi-source queries or timeouts.
  • Rate Limiting: Use Semaphore to cap concurrent operations to prevent resource exhaustion (DB connections, API limits).
  • Shared State: Use Ref to safely mutate shared state across fibers with atomic updates.
  • Parallel Composition: Use Effect.all and Effect.forEach to process independent tasks in parallel with optional concurrency limits.
  • Coordination: Use Latch for barrier synchronization among workers; fan-out/fan-in patterns.
  • Event Broadcasting: Use PubSub to publish events to multiple subscribers in a decoupled fashion.

Quick Start

Experiment by implementing small TS examples that demonstrate racing data sources, limiting concurrency with a Semaphore, incrementing a shared Ref across fibers, running a batch of tasks in parallel with Effect.forEach, coordinating with a Latch, and broadcasting events via PubSub. Install the Effect library and run with ts-node or your TS build tool, then modify parameters to observe behavior.

Frequently Asked Questions about effect-patterns-concurrency

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

FAQPage Schema
How do I limit concurrency in Effect-TS to prevent resource exhaustion?

Use a Semaphore to limit concurrency in Effect-TS, capping concurrent operations to prevent resource exhaustion when managing database connections or external API rate limits. This pattern safely coordinates multiple fibers within a single process.

What is the best way to race multiple data sources in Effect-TS?

Use Effect.race to obtain the fastest result from multiple data sources while interrupting the losing operations. This concurrency pattern is suitable for multi-source queries and implementing timeouts in TypeScript.

How do I safely mutate shared state across multiple fibers in Effect-TS?

Use Ref to safely mutate shared state across multiple fibers in Effect-TS with atomic updates. This pattern ensures safe concurrent coordination without race conditions when incrementing values across asynchronous workflows.

Can I broadcast events to multiple subscribers using Effect-TS?

Yes, you can broadcast events to multiple subscribers in Effect-TS using PubSub. This pattern decouples event publishers from subscribers, allowing you to distribute events across multiple fibers in a decoupled fashion.

Do I need TypeScript tooling to implement Effect-TS concurrency patterns?

Yes, implementing Effect-TS concurrency patterns requires the Effect library and TypeScript tooling. You can run and experiment with these patterns using ts-node or your preferred TypeScript build tool to observe behavior.

How does Latch coordination work for barrier synchronization in Effect-TS?

Latch provides barrier synchronization among workers in Effect-TS, enabling fan-out/fan-in patterns where multiple fibers must wait before proceeding. This coordination pattern structures complex asynchronous workflows safely.