luma-web-review-react-state-tagged-union

Reviews React component state design and flags invalid state combinations fixable with tagged unions.

17|1|Updated Dec 29, 2019
One-click install
npx skills add https://github.com/LumaKernel/dotfiles --skill luma-web-review-react-state-tagged-union-lumakernel
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: luma-web-review-react-state-tagged-union
Source: https://github.com/LumaKernel/dotfiles/tree/main/common/claude/skills/luma-web-review-react-state-tagged-union
Command: npx skills add https://github.com/LumaKernel/dotfiles --skill luma-web-review-react-state-tagged-union-lumakernel

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? React components often accumulate multiple useState hooks whose combinations allow impossible states (e.g., isLoading=true while data exists), creating bug-prone code that TypeScript cannot catch. This Skill audits your codebase and points out exactly where state should be modeled as tagged unions, useActionState, or useReducer. ## Core Features & Use Cases - Invalid State Detection: Finds coexisting boolean flags (isLoading, isSubmitting) and nullable data/error states that permit impossible combinations at the type level. - React 19 Modernization: Identifies form submission handlers manually managing loading/error/success that should use useActionState instead. - Structured Review Reports: Outputs findings with file:line, concrete invalid combinations, type definition suggestions, and high/medium/low priority ratings. - Use Case: Before a refactor, run this review across all .tsx files to get a prioritized list of components whose state logic should be converted to discriminated unions, complete with example type definitions. ## Quick Start Review all React components in this project for state design issues and report where tagged unions or useActionState should be used.

Frequently Asked Questions about luma-web-review-react-state-tagged-union

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

FAQPage Schema
How do I find invalid state combinations in React components?▼

Look for coexisting boolean flags like isLoading or isSubmitting alongside nullable data or error states, which allow impossible combinations such as loading with data present. This review enumerates components with two or more useState hooks and analyzes whether their state transitions are atomic.

When should I use a tagged union instead of multiple useState hooks?▼

Use a tagged union when multiple states change together, such as status plus associated data, so invalid combinations become unrepresentable at the type level. A discriminated union with a status field replaces separate isLoading, data, and error states.

When should I use useActionState vs useReducer in React 19?▼

Use useActionState for form submissions and Server Action calls where you currently manage loading, error, and success manually. Use useReducer when state transitions number three or more and each transition changes multiple fields, but only if useActionState does not already cover the case.

What signals indicate a React state design problem?▼

Key signals include three or more boolean flags in one component, setters always called together in pairs, and status strings stored separately from their associated data. These patterns mean most of the 2^n state combinations are invalid.

How are review findings prioritized?▼

Findings are rated high when an actual code path can reach an invalid state, medium when the type allows invalid states but current code avoids them, and low for minor improvements. Each finding includes file and line, the component name, and a concrete type definition suggestion.