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 do
This is premium content.
You get extra details.
else
This 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 do
You must be 18+ to use this.
elif @age below 21 do
Some features restricted.
else
Full access granted.
end @age

Case

Use case for deterministic branch selection based on enum values:

case @tier do
free: Basic support only.
pro: Priority support during business hours.
enterprise: 24/7 dedicated support.
end @tier

With Bounded Integers

case @step do
1: 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 do
version_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=true
case @tier do
free: Basic support.
pro: Priority support during business hours.
enterprise: 24/7 dedicated support.
end @tier

Compiles to:

Priority support during business hours.

Next Steps