backend-enum-use

Create feature-rich PHP enums following Laravel conventions with SCREAMING_SNAKE_CASE case names, backed enum values (string or int), helper methods for labels and comparisons, validation rules, and comprehensive Pest tests. Use this skill when converting hardcoded strings or magic numbers to type-safe enums, creating categorical data types like statuses, types, roles or categories, adding enum-based validation to forms or APIs, refactoring magic strings into structured types, or defining a fixed set of allowed values in your application. This skill applies when working on files in app/Enums/ directory, creating enum classes, adding enum casts to models, or implementing enum validation rules.

⭐5stars🔀1forks📁View on GitHub🕐Updated Jan 11, 2026

When & Why to Use This Skill

This Claude skill automates the creation of feature-rich PHP enums following Laravel conventions. It enables developers to replace fragile magic strings and numbers with type-safe, backed enums (string or int) that include built-in helper methods for labels, validation rules, and comprehensive Pest tests, significantly improving code maintainability and type safety in backend applications.

Use Cases

  • Refactoring legacy code: Converting hardcoded strings or 'magic numbers' into structured, type-safe PHP enums to prevent runtime errors.
  • Categorical data modeling: Defining standardized sets of allowed values for user roles, order statuses, or product categories within the app/Enums/ directory.
  • Form and API validation: Implementing robust enum-based validation rules for Laravel requests to ensure incoming data matches predefined constants.
  • Eloquent model integration: Adding enum casts to database models to automatically transform raw database values into rich PHP enum objects.
  • Automated testing: Generating comprehensive Pest test suites to verify enum logic, label translations, and state transitions.
nameBackend Enum Use
descriptionCreate feature-rich PHP enums following Laravel conventions with SCREAMING_SNAKE_CASE case names, backed enum values (string or int), helper methods for labels and comparisons, validation rules, and comprehensive Pest tests. Use this skill when converting hardcoded strings or magic numbers to type-safe enums, creating categorical data types like statuses, types, roles or categories, adding enum-based validation to forms or APIs, refactoring magic strings into structured types, or defining a fixed set of allowed values in your application. This skill applies when working on files in app/Enums/ directory, creating enum classes, adding enum casts to models, or implementing enum validation rules.

Backend Enum Use

When to use this skill

  • When converting hardcoded strings or magic numbers to type-safe enums
  • When creating categorical data types (statuses, types, roles, categories, etc.)
  • When adding enum-based validation to forms, API requests, or database columns
  • When refactoring magic strings into structured, type-safe types
  • When defining a fixed set of allowed values for a field or property
  • When implementing state machines or workflow statuses
  • When working on files in app/Enums/ directory
  • When creating enum classes with helper methods (label(), description(), etc.)
  • When adding enum casts to Eloquent models
  • When implementing Laravel validation rules for enum values
  • When writing tests for enum functionality and transitions

This Skill provides Claude Code with specific guidance on how to adhere to coding standards as they relate to how it should handle backend enum use.

Instructions

For details, refer to the information provided in this file: backend enum use