Syntax
Basic Example
Value Rules
| Rule | Valid | Invalid |
|---|---|---|
| Must start with letter | Active, _Internal | 1Active, @Special |
| Alphanumeric + underscores | InProgress, Status_2 | In-Progress, Status@2 |
| No spaces | InProgress | In Progress |
| No duplicates | Each value unique | Two Active values |
| Non-empty | At least one value | Empty enum |
Enum Attributes
@@alias
Changes how the entire enum is rendered in prompts while keeping the original name in code.In prompts, this enum appears as “Account Status” instead of “Status”.
@@dynamic
@@dynamic
Allows modifying enum values at runtime. Useful for loading values from databases or configuration.At runtime:See Dynamic Types for details.
Value Attributes
@alias
Renames a specific value for the LLM while keeping the original name in code. Also used when parsing LLM output.The LLM sees
in_progress and on_hold, but your code uses InProgress and OnHold.@description
Adds context to help the LLM understand when to select this value.
@skip
@skip
Excludes this value from prompts and parsing. Useful for deprecated or internal-only values.The LLM will only see
Active and Inactive.Complete Examples
Simple Classification
Multi-line Descriptions
With Aliases
Issue Categories
Account Types
Usage in Classes
Usage in Functions
As Return Type
As Parameter
Literal Alternative
For simple cases, you can use literal types instead of enums:- Descriptions for values
- Aliases
- Reusability across multiple functions
- Dynamic runtime values
In Prompt Rendering
When used in prompts, enums are automatically formatted:Generated Code
Best Practices
- Naming: Use PascalCase for enum names and values
- Descriptions: Add
@descriptionto clarify when each value should be used - Size: Keep enums focused (typically 3-10 values)
- Aliases: Use
@aliaswhen the code name differs from the LLM-friendly name - Documentation: Add docstrings (
///) to explain the enum’s purpose - Skip: Use
@skipfor deprecated values rather than removing them - Literals: For 2-3 simple values, consider literals instead of enums
Dynamic Enums
For values loaded from databases or external sources:Related
- Class → - Use enums in class properties
- Function → - Use enums as parameters and return types
- Types → - Full type system reference
- Dynamic Types → - Runtime enum modification