You have been using if informally since Chapter 3. This chapter lays out the full decision toolkit: every condition the language understands, the otherwise branch, chaining, and the emergency brake.
The shape of a decision
if <condition> then <steps when it holds> otherwise <steps when it does not>
then is optional — pure politeness. otherwise (or its synonym else) is also optional, must sit at the same indentation as its if, and owns its own indented steps. Decisions nest freely: an if inside an if reads exactly as you would hope.
when a new lead arrives if budget is above 1000 then if source is "referral" then log "big budget AND a referral" otherwise log "big budget, cold source" otherwise log "modest budget"
▶ example.skript — Skode Skript · local simulation ● event: lead.created → name: Ada Lovelace · phone: +1 555 0100 · email: [email protected] ✓ if budget above 1000 → yes ✓ if source is "referral" → yes • log → big budget AND a referral ✔ done in 2.1ms
Every condition the interpreter evaluates appears in the trace with a ✓ or ✗, which turns debugging a decision tree from guesswork into reading.
The complete condition catalogue
This is every form a condition can take — the whole list, not a sample:
| Condition | Holds when |
|---|---|
x is <value> | x equals the value (text comparison for words, exact for numbers/booleans) |
x is not <value> | the opposite |
x is above N / is over N / is greater than N / is more than N | x is numerically greater |
x is below N / is under N / is less than N | x is numerically smaller |
x is at least N | x is greater than or equal |
x contains "text" | the text appears inside x, ignoring case |
x (a bare name) | x is truthy — set, non-zero, non-empty, not false |
score is hot / warm / cold | the AI heat band matches (Chapter 12; requires scoring first) |
Two demonstrations of corners people meet early. contains ignores case — deliberately, because human data arrives in every capitalisation:
when a form is submitted if message contains "pricing" then log "route to sales"
▶ example.skript — Skode Skript · local simulation ● event: form.submitted → form: Contact us · name: Grace Hopper · email: [email protected] ✓ if message contains "pricing" → yes • log → route to sales ✔ done in 2.1ms
And there is no and/or inside a condition. Skript keeps conditions atomic; you express conjunction by nesting (as in the first example) and disjunction by writing two ifs. This is a real limit accepted on purpose: compound boolean algebra is where sentence-languages stop reading like sentences. When you feel the pinch, reach for a function (Chapter 10) whose name states the combined meaning.
Chaining steps with and
Within a single line, and chains steps that belong together:
when a new lead arrives set plan to "starter" and add tag "self-serve" and log "{name} filed under {plan}"
▶ example.skript — Skode Skript · local simulation ● event: lead.created → name: Priya · phone: +1 555 0100 · email: [email protected] ✎ set plan → = "starter" ⚑ add tag "self-serve" → tagged • log → Priya filed under starter ✔ done in 2.1ms — tags: self-serve
The chain runs left to right and is pure sequencing — the steps do not become conditional on each other. Style guidance: two or three short steps that form one thought, chain; anything longer, one per line. And a reassurance about quotes: and inside a string is text, never a chain — add tag "food and drink" is one tag.
Stopping early
stop halts the entire run, immediately, from anywhere — the rest of the rule, enclosing loops, everything:
when a new lead arrives if email is "" then log "no email — nothing to do" and stop log "this line is never reached"
▶ example.skript — Skode Skript · local simulation ● event: lead.created → name: Ada Lovelace · phone: +1 555 0100 · email: ✓ if email is "" → yes • log → no email — nothing to do ■ stop → skript halted ✔ done in 2.1ms
The guard-clause pattern above — check a disqualifier, stop early, keep the happy path unindented — is the single best structuring habit for rules that would otherwise nest five levels deep. The trace marks the halt with ■, and the run ends cleanly; stop is a decision, not an error.
Loops — the other half of control flow — are next, and they follow the same philosophy: a small number of forms, each shaped like something you would say.