What this skill teaches your AI coding agent
The State-Machine Component Architecture playbook eliminates UI bugs caused by independent boolean state flags. Developers and agents often declare separate flags like isLoading, isError, and isSuccess in component state, allowing impossible combinations (such as loading and error simultaneously true) to render corrupted views. This skill mandates that state be modeled as a single discriminated union (idle, loading, success, error) where each state node strictly defines its accessible payload data and allowable transitions.
State-Machine Component Architecture is an open-source UI skill that replaces boolean flags with discriminated unions to eliminate impossible UI states.
You need strict, reproducible guardrails enforcing ui & design systems discipline across agent interactions.
You are building quick disposable prototypes where architectural consistency and test verification are unnecessary.
Activation boundaries & prompt triggers
- 💬 "User prompts: "Component design playbook eliminating impossible UI states by replacing ind...""
- 💬 "User asks to implement async UI flows, complex forms, modals, or stateful client widgets."
- 💬 "When autonomous agent needs strict protocol guardrails"
- ⛔ Explicitly model states as a finite state union: idle, loading, success, or error.
- ⛔ Impossible states (such as loading: true AND error: true) must be made unrepresentable in TypeScript.
- ⛔ Every error state must provide an actionable retry recovery path for the user.
Inject into Claude.ai, Claude Code, or Cursor
Choose your agent runtime to install the playbook directly into local configuration.
.cursor/rules/finite-state-ui-components.mdc---description: Component design playbook eliminating impossible UI states by replacing independent booleans with explicit discriminated unions and state machines.globs: *alwaysApply: false---# Finite-State UI Component ArchitectureWhen building interactive components with asynchronous or multi-step logic:1. BAN INDEPENDENT BOOLEANS: - DO NOT combine `isLoading`, `isError`, `isSuccess` booleans that enable impossible states (e.g. `isLoading && isError`).2. DISCRIMINATED STATE UNIONS: - Explicitly define states as mutually exclusive discriminated unions: `type ComponentState = { status: 'idle' } | { status: 'loading' } | { status: 'success', data: Data } | { status: 'error', error: Error };`3. DETERMINISTIC TRANSITIONS: - Model user actions as events handled through explicit reducer transitions.Interactive file tree manifest & playbook viewer
Click any file to audit instructions, verification scripts, and architectural references before installation.
SKILL.md---
name: finite-state-ui-components
description: "Component design playbook eliminating impossible UI states by replacing independent booleans with explicit discriminated unions and state machines."
version: 1.0.0
license: MIT
compatibility: [claude-3-5-sonnet, cursor, windsurf, cline]
---
# State-Machine Component Architecture
The State-Machine Component Architecture playbook eliminates UI bugs caused by independent boolean state flags. Developers and agents often declare separate flags like isLoading, isError, and isSuccess in component state, allowing impossible combinations (such as loading and error simultaneously true) to render corrupted views. This skill mandates that state be modeled as a single discriminated union (idle, loading, success, error) where each state node strictly defines its accessible payload data and allowable transitions.
## Core Guardrails
- ⛔ Explicitly model states as a finite state union: idle, loading, success, or error.
- ⛔ Impossible states (such as loading: true AND error: true) must be made unrepresentable in TypeScript.
- ⛔ Every error state must provide an actionable retry recovery path for the user.
## Autonomous Activation Triggers
When user prompts:
- "User prompts: "Component design playbook eliminating impossible UI states by replacing ind...""
- "User asks to implement async UI flows, complex forms, modals, or stateful client widgets."
- "When autonomous agent needs strict protocol guardrails"
Verified behavioral proof of work
Identical prompt executed with and without this skill under autonomous coding loops.
Execute State-Machine Component Architecture under autonomous coding loops
2- // Baseline code3+ // Deterministic scoped patch complying with all protocol invariantsExecution safety and file access boundaries
Agent skills with executable scripts can run shell or Python utilities. Always audit scripts before execution.
- Scope: Bound to active workspace branch.
- Network Calls: Zero outbound network calls.
- AST Syntax Gate: Pre-flight verification blocks breaking mutations.
Operational triage & resolution runbook
Skill not triggering during user conversational prompt▼
Agent system prompt does not associate task keywords with the skill's trigger boundary.
Reference the skill name explicitly in your prompt (e.g., "Follow the rules in finite-state-ui-components to perform this refactoring").
Conflicting rules with root project instructions▼
Global instructions (.cursorrules or CLAUDE.md) contradict the skill's invariants.
Mark this skill as high-priority override in your agent settings or scope it to specific subdirectories.
Context window saturation warning▼
Multiple skills loaded simultaneously without progressive disclosure.
Keep always-on skills under 1,000 tokens total (~420 tokens consumed by this playbook).
Skill vs. MCP Server vs. Plain System Prompt
| Primitive | Best Used When | Token Cost | Execution Risk |
|---|---|---|---|
| Agent Skill (`SKILL.md`) | Multi-step domain workflows & procedural guardrails | Low (~400 tokens) | Minimal (AST verified) |
| MCP Server | External system integrations (APIs, live databases) | Zero (until called) | Scoped by tool permissions |
| Plain System Prompt | Simple style guidelines & tone preferences | High (Always in context) | High drift risk |
Composable peers & official repository
Combine with Frontend Design Standards & Anti-Template Aesthetic for complementary agent steering across testing and refactoring.
Inspect SkillCombine with Responsive Viewport & Container Query Optimization for complementary agent steering across testing and refactoring.
Inspect SkillCombine with Tailwind CSS Strict Token & Utility Architecture for complementary agent steering across testing and refactoring.
Inspect Skill