Control Flow
.prompt supports three control flow constructs: if, case, and vary. All resolve at compile time.
If / Elif / Else
Use if for conditional content:
if @is_premium is true doThis is premium content.You get extra details.elseThis is free content.Upgrade to premium for more!end @is_premium
Operators
| Operator | Meaning |
|---|---|
is | Equality |
not | Inequality |
above | Greater than |
below | Less than |
min | Greater than or equal |
max | Less than or equal |
between | Inclusive range |
Chained Conditions
if @age below 18 doYou must be 18+ to use this.elif @age below 21 doSome features restricted.elseFull access granted.end @age
Case
Use case for deterministic branch selection based on enum values:
case @tier dofree: Basic support only.pro: Priority support during business hours.enterprise: 24/7 dedicated support.end @tier
With Bounded Integers
case @step do1: Start with the basics.2: Build on step 1.3: Add more complexity.4: Refine your approach.5: Complete the process.end @step
Vary
Use vary for random or seeded variation. Perfect for A/B testing or adding variety:
vary @variation doversion_a: Try this approach first.version_b: Try this alternative.version_c: Here is another way.end @variation
Pass a seed parameter to get deterministic results. Without seed, each call selects randomly.
Compile-Time Resolution
All control flow resolves at compile time. The LLM receives only the selected branch:
# Input: tier=pro, is_premium=truecase @tier dofree: Basic support.pro: Priority support during business hours.enterprise: 24/7 dedicated support.end @tier
Compiles to:
Priority support during business hours.Next Steps
- Fragments — Compose from reusable pieces
- Versioning — Manage changes over time