state-machine-modeling

Define finite state machine lifecycle specifications for domain objects with guards and side effects.

4|Updated May 16, 2026
One-click install
npx skills add https://github.com/machenjie/rd-skills --skill state-machine-modeling-machenjie
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: state-machine-modeling
Source: https://github.com/machenjie/rd-skills/tree/main/src/foundation/capabilities/state-machine-modeling
Command: npx skills add https://github.com/machenjie/rd-skills --skill state-machine-modeling-machenjie

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It eliminates fragile, scattered status-check logic by modeling each domain lifecycle as a strict finite state machine with explicit states, allowed/illegal transitions, guards, side effects, events, and audit requirements.

Core Features & Use Cases

  • Lifecycle modeling as an authoritative FSM: define mutually exclusive and exhaustive states, including terminal and failure/recovery states.
  • Explicit transition enforcement: specify allowed transitions with named triggers/actors and guard conditions so unlisted transitions are rejected with domain exceptions.
  • Safe operational behavior: design timeout, recovery, idempotency for external side effects, and post-commit event emission to prevent duplicates and stuck records.
  • Use case: when orders, payments, subscriptions, jobs, approvals, or workflows need clear rules to prevent double charges, duplicate fulfillment, or illegal cancellations.

Quick Start

Ask the agent to produce a versioned finite state machine specification (states, transition table, illegal transitions, timeouts, recovery transitions, idempotency design, and concurrency controls) for your chosen domain object and workflow.

Frequently Asked Questions about state-machine-modeling

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

FAQPage Schema
How do I prevent duplicate fulfillment and double charges in order lifecycles?

Model order lifecycles as strict finite state machines with explicit transition enforcement, idempotency for retried external effects, and concurrency controls to reject unlisted transitions and race-condition duplicates.

What is a finite state machine for domain modeling?

A finite state machine for domain modeling is an authoritative lifecycle specification that enumerates mutually exclusive and exhaustive states, allowed transitions with named triggers, guards, side effects, and audit records for business objects like payments, subscriptions, and workflows.

How do I define allowed and illegal state transitions for a payment workflow?

Define allowed and illegal state transitions for a payment workflow by specifying named triggers, actor roles, and guard conditions in a transition table, applying strict default illegality so any unlisted transition is rejected with a domain exception.

How do you handle stuck records and timeout recovery in job lifecycles?

Handle stuck records and timeout recovery in job lifecycles by defining explicit timeout and recovery exits for in-progress states, ensuring post-commit side effects and emitted events allow safe retries without leaving records in a blocked terminal state.

Does finite state machine modeling work for approval and ticket workflows with external side effects?

Finite state machine modeling works for approval and ticket workflows with external side effects by defining post-commit event emission, idempotency for retried operations, and audit records that track every state change and emitted event.

When should I not use finite state machine lifecycle modeling?

Avoid finite state machine lifecycle modeling for stateless data objects or simple CRUD operations where business rules and external side effects do not depend on explicit state changes, as the overhead of enumerating allowed transitions and guards provides no value.