enum-driven-state-refactoring

Community

Eliminate 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 UserStatus enum that currently uses optional fields like data? and error? into distinct variants like UserStatus.Loading, UserStatus.Success(Data), and UserStatus.Error(Error).

Quick Start

Refactor the provided TypeScript interface to use a discriminated union for its state.

Dependency Matrix

Required Modules

None required

Components

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.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 223,000+ vetted skills library on demand.