Generate a state machine

Use this guide when you already have a Sismic YAML statechart and want to generate Python source from it.

Generate to a file

uv run state-mate path/to/machine.yaml --output generated/machine.py

State Mate creates missing parent directories for the output file.

The short form is equivalent:

uv run state-mate path/to/machine.yaml -o generated/machine.py

Generate to stdout

Omit --output:

uv run state-mate path/to/machine.yaml

This is useful when composing State Mate with shell tools or when you only want to inspect the generated result.

Fail the build for unsupported statecharts

State Mate exits with a Click error when either Sismic cannot import the document or the imported statechart contains unsupported features.

That makes it suitable for build automation:

uv run state-mate model/order.yaml -o generated/order_machine.py

A non-zero exit code indicates that generation did not succeed.

Keep generated code reproducible

Treat the Sismic YAML and State Mate version as the source inputs. Regenerate the Python module rather than hand-editing it, because the generated file is a projection of the statechart rather than the primary model.