state-machine-transition

Adds states and transitions to Bob The Skull's finite state machine with entry/exit actions, timeouts, and events.

Updated Nov 21, 2025
One-click install
npx skills add https://github.com/want2bet/BobTheSkull5 --skill state-machine-transition
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: state-machine-transition
Source: https://github.com/want2bet/BobTheSkull5/tree/main/.claude/skills/state-machine-transition
Command: npx skills add https://github.com/want2bet/BobTheSkull5 --skill state-machine-transition

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides a robust pattern for adding new states and transitions to Bob The Skull's finite state machine, including entry/exit actions, timeouts, and event-driven transitions, while preserving system stability.

Core Features & Use Cases

  • Add New States: Extend the State enum with well-scoped, documented states.
  • Define Transitions: Explicitly outline valid from→to transitions and timeouts.
  • Entry/Exit Actions: Implement side-effects for entering/exiting states and publish StateChangedEvent.
  • Testing Guidance: Includes a pattern for unit tests of new transitions.

Quick Start

  1. Define a new state in the State enum.
  2. Add VALID_TRANSITIONS entry for the new state.
  3. Implement enter<state>() and optional exit<state>() methods.
  4. Register event handlers to trigger transitions, e.g., on_your_trigger_event.
  5. Add timeout handling in _on_timeout if needed.

Frequently Asked Questions about state-machine-transition

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

FAQPage Schema
How do I add new states to a finite state machine?

Add new states by extending the State enum with well-scoped, documented state definitions. Define corresponding entries in VALID_TRANSITIONS to specify allowed transitions from each new state, and implement _enter_<state>() and _exit_<state>() methods to handle entry and exit actions when the FSM transitions into or out of that state.

What's the best way to define valid transitions between FSM states?

Define valid transitions explicitly in a VALID_TRANSITIONS structure that maps each state to its allowed destination states. This pattern preserves system stability by preventing invalid state changes and serves as the single source of truth for your FSM's control flow and event-driven behavior.

How do I implement entry and exit actions when transitioning between states?

Implement _enter_<state>() methods to execute logic when entering a state and optional _exit_<state>() methods for cleanup or side-effects when leaving. Register event handlers to trigger transitions and publish StateChangedEvent to notify observers of state changes and associated entry/exit action outcomes.

Can I add timeouts to FSM state transitions?

Yes. Define state timeouts in a STATE_TIMEOUTS structure and implement _on_timeout() method to handle timeout-driven transitions. This allows states to automatically transition after a specified duration, enabling time-based state machine behavior alongside event-driven transitions.

What testing approach should I use for new FSM transitions?

Unit test new transitions by verifying state changes, validating entry/exit action execution, confirming StateChangedEvent publication, and checking timeout behavior. The Skill includes a pattern for comprehensive transition testing to ensure stability when extending the FSM.

Do I need to wire event handlers manually for each transition?

Yes. Register event handlers explicitly to trigger transitions—for example, on_your_trigger_event methods that call the state transition logic. This explicit wiring ensures clarity about which events drive which state changes and maintains full control over your FSM's event-driven behavior.