add-a-lifecycle-machine
Installation
SKILL.md
Add a lifecycle machine
Use this to learn the seam between XState and Effect. Copy packages/core/src/inspect-machine.ts when the work has states that matter. Keep a direct Effect when it does not.
Before changing Effect or XState code, read node_modules/effect/AGENTS.md. Then read the pinned XState and @xstate/effect source listed in AGENTS.md.
1. Write the states first
List the states and final results before writing the machine.
For file inspection, the states are reading, inspected, and unreadable. The final result is either Inspected with file stats or Unreadable with a FileStatsError.
Use an explicit result union when a known error should move the machine into a final state.
2. Put side effects in actors
Define each side effect with fromEffect outside the machine: