The Skript book · Appendix A

Language Reference

This appendix compresses the entire language into tables and one grammar. Nothing here is new; everything here is complete.

The grammar

program    = { rule | function | statement } ;
rule       = "when" event-phrase NEWLINE INDENT block DEDENT ;
function   = "to" name-phrase NEWLINE INDENT block DEDENT ;
block      = { statement } ;
statement  = action { "and" action }
           | "if" condition ["then"] block ["otherwise" block]
           | "repeat" NUMBER "times" block
           | ["repeat"] "for each" NAME "in" expr block
           | ["repeat"] "while" condition block ;
action     = built-in-action | name-phrase        (* a function call *) ;
expr       = sum { "," sum }                      (* comma builds a list *) ;
sum        = prod { ("+"|"-") prod } ;
prod       = value { ("*"|"/") value } ;
value      = STRING | NUMBER | "true" | "false" | FIELD ;
condition  = see the conditions table ;

Lexical rules: indentation defines blocks (two spaces per level; a tab counts as two spaces); one statement per line; # begins a comment outside strings; strings take "…" or '…' with backslash escapes and {field} interpolation; operators require surrounding spaces; keywords are case-insensitive; top-level items (when rules, to definitions) may appear in any order; a file of bare statements runs in script mode.

Events

Phrase (examples)KeyDemo fields in the simulator
a new lead arrives / a lead is createdlead.createdname, phone, email, source, budget
a form is submittedform.submittedform, name, email, message
a message arrivesmessage.receivedfrom, name, channel, text
an invoice is paidinvoice.paidnumber, amount, name
a deal is wondeal.wonname, amount, owner
when "custom.key" happensas quotednone (supply with --data)

Actions

ActionFormNotes
scorescore it with aisets score (0–100) and heat (hot/warm/cold)
assignassign [it] to "Name"routes the event's subject
replyreply on <channel> "…"message inline or as quoted line(s) indented beneath
sendsend <channel> [to "addr"] "…"channels: whatsapp, email, sms, instagram, webchat, slack
tagadd tag "label"tags accumulate
taskcreate task "title" [for "Name"]title interpolates
waitwait N second(s)/minute(s)/hour(s)/day(s)simulated locally; real delay in production
setset name to exprcreates or replaces a variable
addadd expr to namelist → push; number → add; string → append; unset → set
incrincrease/decrease name by exprunset name counts as 0
loglog "…" / say "…"trace note; no external effect anywhere
stopstophalts the run immediately

Conditions

FormMeaning
x is v / x is not vequality / inequality (string-compared for words)
x is above N (over, greater than, more than)numeric >
x is below N (under, less than)numeric <
x is at least Nnumeric >=
x contains "t"substring, case-insensitive
xtruthy: set, non-zero, non-empty, not false
score is hot/warm/coldheat band; requires prior scoring (hot >= 75, warm >= 45)

Conditions are atomic — no and/or inside one. Compose with nested if (conjunction) or sequential ifs (disjunction).

Data types

TypeLiteralsOperations
number42, 3.5, -1+ - * /, schoolbook precedence, left-assoc
string"hi", 'hi'+ joins (either side); {name} interpolates
booleantrue, falseconditions; bare-name truthiness
listv1, v2, v3for each … in; add … to pushes

Coercion: + with a string joins as text; other arithmetic requires numbers and errors otherwise. An unset name used as a value is the name itself as a word.

Limits and guarantees

LimitValueOn breach
while iterations1,000error naming the loop
function call depth16error naming the function
trace display400 linesdisplay truncates; execution continues
network / filesystem / importsnone existnot expressible in the language

The CLI

CommandPurpose
skript run f.skript [--event k] [--data json] [--score n] [--json]execute against a simulated event
skript check f.skriptparse only; line-numbered errors; exit 1 on failure
skript new [name]scaffold a starter file
skript add <name>install a marketplace package into the current directory
skript install-editorhighlighting + snippets for VS Code-family editors
skript version / skript helpthe obvious

skode is an alias for skript. Install: curl -fsSL https://developer.skode.ai/skript/install.sh | bash (Node >= 18).