enum-driven-state-refactoring
CommunityEliminate invalid states with sum types.
Authorjul-sh
Version1.0.0
Installs0
System Documentation
What problem does it solve?
This Skill helps refactor code that uses optional fields or parallel booleans to represent state, making illegal states structurally impossible and improving code safety.
Core Features & Use Cases
- State Modeling: Transforms ambiguous, optional-based state representations into strict, type-safe sum types (enums/discriminated unions).
- Code Safety: Prevents invalid state combinations at compile time, reducing runtime errors and the need for manual validation.
- Use Case: Refactor a
UserStatusenum that currently uses optional fields likedata?anderror?into distinct variants likeUserStatus.Loading,UserStatus.Success(Data), andUserStatus.Error(Error).
Quick Start
Refactor the provided TypeScript interface to use a discriminated union for its state.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: enum-driven-state-refactoring Download link: https://github.com/jul-sh/dotfiles/archive/main.zip#enum-driven-state-refactoring Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 223,000+ vetted skills library on demand.