state-diagram
Create state machine diagram from behavior description. Use for lifecycle and workflow modeling.
What this skill does
# /state-diagram Command
Create state machine diagrams from behavior descriptions with optional implementation code.
## Usage
```text
/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
```plantuml
@startuml
title Entity State Machine
[*] --> Initial : Create
state Initial {
Initial : entry / initialize
}
Initial --> Active : Activate [isValid]
Active --> Completed : Complete
Completed --> [*]
@enduml
```
### Mermaid
```mermaid
stateDiagram-v2
[*] --> Initial : Create
Initial --> Active : Activate
Active --> Completed : Complete
Completed --> [*]
```
### XState (TypeScript)
```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
```text
/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
```text
/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
```text
/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
| Type | Description |
|------|-------------|
| Initial | Starting point (filled circle) |
| Normal | Regular state |
| Final | End point (circled dot) |
| Composite | Contains sub-states |
| History | Remembers last sub-state |
### Transitions
| Element | Description |
|---------|-------------|
| Event | Trigger for transition |
| Guard | Condition `[isValid]` |
| Action | Side 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
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.