effect-patterns-concurrency

Provide Effect-TS concurrency patterns for race, timeout, semaphore, and shared state coordination.

785|26|Updated Jun 22, 2025
One-click install
npx skills add https://github.com/PaulJPhilp/EffectPatterns --skill effect-patterns-concurrency
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: effect-patterns-concurrency
Source: https://github.com/PaulJPhilp/EffectPatterns/tree/main/config/.claude-plugin/plugins/effect-patterns/skills/effect-patterns-concurrency
Command: npx skills add https://github.com/PaulJPhilp/EffectPatterns --skill effect-patterns-concurrency

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a curated set of Effect-TS concurrency patterns to help developers design robust, scalable, and maintainable concurrent applications. It tackles the complexity of coordinating many fibers, controlling resource usage, and reacting to asynchronous events.

Core Features & Use Cases

  • Race and timeout patterns for fastest result and deadline enforcement
  • Semaphore-based rate limiting to cap concurrent tasks
  • Shared state coordination with Ref and atomic updates
  • Parallel work with Effect.all and forEach using controlled concurrency
  • Fan-out/fan-in and barrier synchronization with Latch
  • Event distribution via PubSub and robust producer-consumer pipelines with Queue
  • Lifecycle and background task patterns using runFork, Scope, and graceful shutdown

Quick Start

Run a minimal script that imports Effect and uses Effect.race to compare two tasks, then applies a bounded concurrency pattern to limit parallel executions. This demonstrates the core primitives of the concurrency patterns in this skill and lets you tweak latency and concurrency 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 when running parallel tasks?

To limit concurrency in Effect-TS, you can use a Semaphore to cap concurrent tasks or apply bounded concurrency patterns with Effect.all and forEach. This controls parallel executions and prevents resource exhaustion in scalable applications.

What is the best way to handle race conditions and timeouts in Effect-TS?

Handling race conditions and timeouts in Effect-TS involves using Effect.race to select the fastest result from competing tasks and applying timeout patterns for strict deadline enforcement. This ensures fault-tolerant execution when multiple asynchronous operations compete.

How do I coordinate shared state and synchronize fibers in Effect-TS?

To coordinate shared state and synchronize fibers in Effect-TS, use Ref for atomic state updates and Latch for barrier synchronization. These primitives enable safe fan-out/fan-in workloads and event-driven coordination across concurrent operations.

Can I build a producer-consumer pipeline with PubSub and Queue in Effect-TS?

Yes, you can build robust producer-consumer pipelines in Effect-TS using PubSub for event distribution and Queue for managing buffered work. This combination supports scalable, event-driven architectures with coordinated background processing.

How do I manage resource lifecycle and graceful shutdown for background tasks in Effect-TS?

Managing resource lifecycle and graceful shutdown in Effect-TS requires using runFork to spawn background tasks and Scope to track resource allocation. This pattern ensures resources are safely released when concurrent operations complete or cancel.