State Management

Implement mutable state in Effect-TS using Ref, SynchronizedRef, and SubscriptionRef.

8|Updated Jan 23, 2026
One-click install
npx skills add https://github.com/andrueandersoncs/claude-skill-effect-ts --skill state-management-andrueandersoncs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: State Management
Source: https://github.com/andrueandersoncs/claude-skill-effect-ts/tree/main/skills/state-management
Command: npx skills add https://github.com/andrueandersoncs/claude-skill-effect-ts --skill state-management-andrueandersoncs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Effect provides functional mutable state primitives to safely manage shared state in concurrent environments.

Core Features & Use Cases

  • Ref: basic mutable reference with get/set/update operations
  • SynchronizedRef: effectful updates with concurrency safety
  • SubscriptionRef: reactive state with change notifications
  • Use Case: coordinating counters, caches, and reactive configs in Effect-TS services

Quick Start

Install and import Ref, SynchronizedRef, and SubscriptionRef, then create and manipulate state inside an Effect program.

Frequently Asked Questions about State Management

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

FAQPage Schema
How do I manage shared mutable state safely in Effect-TS concurrent environments?

You can manage shared mutable state in Effect-TS using fiber-safe primitives like Ref, SynchronizedRef, and SubscriptionRef to safely handle concurrent updates. These state references provide get, set, and update operations without race conditions.

What is the difference between Ref and SynchronizedRef for state updates?

Ref provides basic mutable reference operations like get and set, while SynchronizedRef offers effectful updates with enhanced concurrency safety for coordinating state across multiple fibers. SynchronizedRef is needed when updates involve effects that must run sequentially.

How do I implement reactive state with change notifications in Effect-TS?

You implement reactive state in Effect-TS using SubscriptionRef, which provides built-in change notifications for reactive patterns across services. It allows services to subscribe and automatically react whenever the shared state is modified.

When do I need fiber-safe state primitives for coordinating counters and caches?

You need fiber-safe state primitives when coordinating counters, caches, or reactive configs across concurrent Effect-TS services. These mutable state references ensure safe shared updates and prevent race conditions during parallel fiber execution.

Can I use SubscriptionRef to coordinate reactive configs across Effect-TS services?

Yes, SubscriptionRef is specifically designed to coordinate reactive configs across Effect-TS services by emitting change notifications whenever state updates occur. This enables services to automatically react to shared configuration changes.