enum-driven-state-authoring

Model state as sum types with enum variants from initial code design.

2|Updated Oct 24, 2021
One-click install
npx skills add https://github.com/jul-sh/dotfiles --skill enum-driven-state-authoring
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: enum-driven-state-authoring
Source: https://github.com/jul-sh/dotfiles/tree/main/dotfiles/.claude/skills/enum-driven-state-authoring
Command: npx skills add https://github.com/jul-sh/dotfiles --skill enum-driven-state-authoring

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers avoid common pitfalls in state management by guiding them to model distinct states as sum types (enums with variants) from the initial code design, preventing complex conditional logic and optional field hell.

Core Features & Use Cases

  • Sum Type Modeling: Guides the creation of sum types for entities with distinct modes, phases, or lifecycle states.
  • Avoids Optional Fields: Prevents the use of optional fields that depend on other fields, leading to more robust and predictable code.
  • Use Case: When building a user authentication flow, model states like Guest, LoggedIn, and Suspended as distinct enum variants, each holding only the necessary data for that state, rather than using optional fields on a single User object.

Quick Start

When writing new code, model state as sum types from the start.

Frequently Asked Questions about enum-driven-state-authoring

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

FAQPage Schema
How do I model state with sum types to avoid optional fields in TypeScript?

Model state with sum types by defining enum variants for distinct lifecycle phases, each holding only necessary data. This prevents optional field hell and complex conditional logic in TypeScript by ensuring invalid states are unrepresentable at compile time.

What is the best way to handle polymorphic entities in Rust?

The best way to handle polymorphic entities in Rust is modeling state as sum types from initial design. Using enums with variants prevents derived boolean properties and optional fields dependent on other fields, ensuring robust code behavior.

When should I use enums instead of boolean flags for workflow states in Kotlin?

Use enums for workflow states in Kotlin when entities have distinct modes or phases. Sum types prevent complex conditional logic and avoid anti-patterns like derived boolean properties, replacing them with predictable variant-based transitions.

Does Python support sum types for async data state management?

Python can model state as sum types for async data by using enums with variants. This guides developers to create distinct modes for connection or workflow states, preventing optional field hell during asynchronous operations.

Why does using optional fields dependent on other fields cause state management issues?

Using optional fields dependent on other fields causes state management issues because it allows invalid states and requires complex conditional logic. Modeling state as sum types with enum variants eliminates this anti-pattern, ensuring only valid data combinations exist.