effect-machine

Create type-safe state machines for Effect-based workflows with schemas and transitions.

53|Updated Jan 25, 2026
One-click install
npx skills add https://github.com/cevr/effect-machine --skill effect-machine
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: effect-machine
Source: https://github.com/cevr/effect-machine/tree/main/skills/effect-machine
Command: npx skills add https://github.com/cevr/effect-machine --skill effect-machine

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

effect-machine removes the brittleness of ad-hoc async state handling by giving you a single typed model for state, events, transitions, and side effects.

Core Features & Use Cases

  • Schema-first states & events: Define states/events as Effect-compatible schemas so constructors, validation, and serialization come from one place.
  • Typed transition handlers: Implement state transitions with type-safe event payloads, including reply-bearing events for ask/reply flows.
  • State-scoped effects & async orchestration: Use spawn/task/background, automatic cancellation on state exit, plus timeouts and postpone buffering for real workflow control.
  • Testing, replay, and lifecycle hooks: Simulate machines, assert paths/reaches, replay transitions with stubbed side effects, and integrate recovery/durability for persistence.

Quick Start

Tell the AI: "Create an effect-machine for a Checkout workflow with typed schemas for states and events, state-scoped charging logic via spawn, a timeout that transitions to a failure state, and an ask/reply event that returns the current total amount."

Frequently Asked Questions about effect-machine

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

FAQPage Schema
How do I build type-safe state machines for Effect-based async workflows?

You can build type-safe state machines for Effect workflows by defining State and Event schemas, wiring transition handlers via Machine.make().on, and running scoped side effects with Machine.spawn to ensure reliable async orchestration.

What is the best way to handle timeouts and retries in an actor model workflow?

Handling timeouts and retries in an actor model workflow involves defining transition handlers with Machine.timeout for automated state changes and using state-scoped effects via spawn to manage automatic cancellation upon state exit.

Can I use typed ask/reply communication for multi-state business flows in Effect?

Typed ask/reply communication is supported by implementing reply-bearing events within transition handlers, allowing multi-state business flows to request and return specific typed payloads like a current total amount during execution.

How do you test and replay state machine transitions with stubbed side effects?

Testing and replaying state machine transitions requires simulating machines to assert execution paths, stubbing side effects for deterministic replay, and integrating lifecycle recovery hooks to validate durability under failure scenarios.

Does this state machine approach support postponing or buffering events until a state is ready?

The state machine approach supports postponing or buffering events through Machine.postpone, allowing incoming events to wait safely until the workflow transitions to a state capable of processing them.

When should I not use schema-driven state machines for async orchestration?

Schema-driven state machines might be unnecessary for simple, linear async tasks lacking multi-state flows, timeouts, or actor-style communication, where ad-hoc async handling suffices without structured transition modeling.