Statechart and state machine modeling for lifecycle and behavior specification
View on GitHubmelodic-software/claude-code-plugins
formal-specification
plugins/formal-specification/skills/state-machine-design/SKILL.md
January 21, 2026
Select agents to install to:
npx add-skill https://github.com/melodic-software/claude-code-plugins/blob/main/plugins/formal-specification/skills/state-machine-design/SKILL.md -a claude-code --skill state-machine-designInstallation paths:
.claude/skills/state-machine-design/# State Machine Design Skill
## When to Use This Skill
Use this skill when:
- **State Machine Design tasks** - Working on statechart and state machine modeling for lifecycle and behavior specification
- **Planning or design** - Need guidance on State Machine Design approaches
- **Best practices** - Want to follow established patterns and standards
## Overview
Design finite state machines and statecharts for modeling entity lifecycles, workflows, and system behavior.
## MANDATORY: Documentation-First Approach
Before designing state machines:
1. **Invoke `docs-management` skill** for state machine patterns
2. **Verify implementation patterns** via MCP servers (context7 for XState, etc.)
3. **Base all guidance on Harel statechart semantics**
## State Machine Concepts
### Core Elements
| Element | Description | Example |
|---------|-------------|---------|
| State | Condition the system can be in | `Draft`, `Submitted`, `Paid` |
| Transition | Change from one state to another | `Draft → Submitted` |
| Event | Trigger for a transition | `Submit`, `Pay`, `Cancel` |
| Guard | Condition that must be true | `[hasItems]`, `[isValid]` |
| Action | Side effect on transition | `sendNotification`, `updateDatabase` |
| Entry Action | Action when entering state | `onEnter: startTimer` |
| Exit Action | Action when leaving state | `onExit: stopTimer` |
### State Types
```csharp
public enum StateType
{
Initial, // Starting state (filled circle)
Normal, // Regular state
Final, // End state (circle with border)
Composite, // Contains sub-states
Parallel, // Concurrent regions
History, // Remember last sub-state
Choice // Decision point
}
```
## State Machine Notation
### PlantUML Syntax
```plantuml
@startuml
title Order State Machine
[*] --> Draft : Create
state Draft {
Draft : entry / initializeOrder
Draft : exit / validateOrder
}
Draft --> Submitted : Submit [hasItems]
Draft --> Cancelled :