Skill

state-diagram

Create state machine diagram from behavior description. Use for lifecycle and workflow modeling.

From formal-specification
Install
1
Run in your terminal
$
npx claudepluginhub melodic-software/claude-code-plugins --plugin formal-specification
Tool Access

This skill is limited to using the following tools:

ReadGlobGrepWriteSkillTask
Skill Content

/state-diagram Command

Create state machine diagrams from behavior descriptions with optional implementation code.

Usage

/state-diagram "order lifecycle from creation to delivery"
/state-diagram "user account states" format=mermaid
/state-diagram "payment processing workflow" implementation=csharp
/state-diagram "document approval process" format=xstate implementation=typescript

Workflow

Step 1: Analyze Behavior Description

Parse the description to identify:

  • Entity being modeled (order, user, document)
  • Lifecycle stages or conditions
  • Triggers that cause state changes
  • Business rules and constraints

Step 2: Invoke State Machine Skill

Load the state-machine-design skill for:

  • State machine patterns and best practices
  • Notation syntax for chosen format
  • Implementation patterns

Step 3: Identify States

Extract states from the description:

  • Initial state (starting point)
  • Normal states (intermediate conditions)
  • Final states (terminal states)
  • Composite states (if nested behavior)

Step 4: Define Transitions

Map state changes:

  • Events/triggers that cause transitions
  • Guards (conditions that must be true)
  • Actions (side effects on transition)
  • Entry/exit actions for states

Step 5: Generate Diagram

Create the state machine diagram in chosen format:

  • PlantUML for detailed documentation
  • Mermaid for inline markdown
  • XState for executable TypeScript

Step 6: Generate Implementation (Optional)

If implementation requested:

  • C# with Stateless library pattern
  • TypeScript with XState machine
  • Transition table approach

Step 7: Output Result

Deliver:

  1. State machine diagram
  2. State/event/transition table
  3. Implementation code (if requested)
  4. Usage notes and edge cases

Format-Specific Output

PlantUML

@startuml
title Entity State Machine

[*] --> Initial : Create

state Initial {
  Initial : entry / initialize
}

Initial --> Active : Activate [isValid]
Active --> Completed : Complete
Completed --> [*]

@enduml

Mermaid

stateDiagram-v2
    [*] --> Initial : Create
    Initial --> Active : Activate
    Active --> Completed : Complete
    Completed --> [*]

XState (TypeScript)

import { createMachine } from 'xstate';

const machine = createMachine({
  id: 'entity',
  initial: 'initial',
  states: {
    initial: {
      on: { ACTIVATE: 'active' }
    },
    active: {
      on: { COMPLETE: 'completed' }
    },
    completed: {
      type: 'final'
    }
  }
});

Examples

Order Lifecycle

/state-diagram "e-commerce order from draft to delivered or cancelled" implementation=csharp

Output:

  • PlantUML diagram with all order states
  • C# implementation using Stateless library
  • Transition table with guards

Document Approval

/state-diagram "document approval with review, revision, and approval stages" format=mermaid

Output:

  • Mermaid state diagram
  • States: Draft, Submitted, UnderReview, NeedsRevision, Approved, Rejected
  • Parallel review tracks if applicable

User Account

/state-diagram "user account lifecycle including verification and suspension" format=xstate implementation=typescript

Output:

  • XState machine definition
  • States: Unverified, Active, Suspended, Deactivated
  • Guards for state transitions
  • Actions for notifications

State Machine Elements

States

TypeDescription
InitialStarting point (filled circle)
NormalRegular state
FinalEnd point (circled dot)
CompositeContains sub-states
HistoryRemembers last sub-state

Transitions

ElementDescription
EventTrigger for transition
GuardCondition [isValid]
ActionSide effect / notify

Integration

The command integrates with:

  • uml-modeling: UML state diagrams
  • openapi-design: API state documentation
  • requirements-elicitation: Behavior requirements
  • test-strategy: State transition tests
Similar Skills
ui-ux-pro-max

UI/UX design intelligence for web and mobile. Includes 50+ styles, 161 color palettes, 57 font pairings, 161 product types, 99 UX guidelines, and 25 chart types across 10 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind, shadcn/ui, and HTML/CSS). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, and check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, and mobile app. Elements: button, modal, navbar, sidebar, card, table, form, and chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, and flat design. Topics: color systems, accessibility, animation, layout, typography, font pairing, spacing, interaction states, shadow, and gradient. Integrations: shadcn/ui MCP for component search and examples.

49.4k
Stats
Parent Repo Stars40
Parent Repo Forks6
Last CommitFeb 15, 2026