---
name: "agentic-workflow-state-machine"
description: "Enforce deterministic, auditable state transitions across multi-stage agent workflows."
metadata:
  author: "XState"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "build fsm agent workflow"
  - "enforce deterministic state transitions"
  - "define agent state machine"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Finite State Machine (FSM) Agent State Engine

Constrains autonomous agents to explicit Finite State Machines: defining valid states (Planning, Executing, Verifying, Complete), allowed transitions, entry/exit hooks, and transition guard conditions.

## When to Invoke
Invoke this skill whenever you need to:
- build fsm agent workflow
- enforce deterministic state transitions
- define agent state machine

## Execution SOP & Rules
1. Define states explicitly: INITIAL, PLANNING, EXECUTING, AUDITING, TERMINATED.
2. Define strict allowed transition mappings (e.g. PLANNING can only transition to EXECUTING or FAILED).
3. Evaluate guard conditions before executing state transitions.
4. Reject any model-generated actions that attempt invalid state transitions.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
