Skip to content

Basic Syntax

Vibe has two ways to declare variables: let for mutable values and const for immutable values.

let count = 0
let name: text = "Alice"
count = count + 1 // OK - can reassign
const API_KEY = "sk-..."
const MAX_RETRIES: number = 3
// API_KEY = "new" // Error - cannot reassign const

Mark variables as private to exclude them from AI context:

private let apiSecret = "sensitive-data"
let publicInfo = "This is visible to AI"
// When AI processes prompts, it won't see apiSecret
do "Summarize the available data"

Use double quotes, single quotes, or backticks:

let s1 = "double quoted"
let s2 = 'single quoted'
let s3 = `template with {variable} interpolation`

Backticks support multi-line strings:

let poem = `Roses are red,
Violets are blue,
Vibe is great,
And so are you.`

All string types support {variable} interpolation:

let name = "Alice"
let greeting = "Hello {name}!" // "Hello Alice!"

Use backslash to escape braces:

let literal = "Use \{braces\} literally" // "Use {braces} literally"
let path = "C:\\Users\\name" // "C:\Users\name"
let integer = 42
let negative = -10
let decimal = 3.14
let yes = true
let no = false
let maybe: text = null // Type annotation required
let data: json = null // OK - type is explicit
// let empty = null // Error: cannot infer type from null
let empty: text[] = []
let numbers = [1, 2, 3]
let names = ["Alice", "Bob", "Carol"]

Use + to concatenate arrays:

let a = [1, 2]
let b = [3, 4]
let combined = a + b // [1, 2, 3, 4]
let person = { name: "Alice", age: 30 }
let config = { timeout: 5000, retries: 3 }
OperatorDescription
+Addition / string / array concatenation
-Subtraction
*Multiplication
/Division
%Modulo
let sum = 10 + 5 // 15
let greeting = "Hello, " + name // String concatenation
OperatorDescription
==Equal
!=Not equal
<Less than
>Greater than
<=Less than or equal
>=Greater than or equal
OperatorDescription
andLogical AND
orLogical OR
notLogical NOT (unary)
if x > 0 and x < 100 {
print("In range")
}
if not isValid {
print("Invalid")
}
let person = { name: "Alice", age: 30 }
let name = person.name // "Alice"
let items = ["a", "b", "c", "d", "e"]
let first = items[0] // "a"
let third = items[2] // "c"
// Negative indices count from the end
let last = items[-1] // "e"
let secondLast = items[-2] // "d"

Python-style slicing with [start:end] syntax:

let items = [1, 2, 3, 4, 5]
let slice = items[1:3] // [2, 3]
let fromStart = items[:2] // [1, 2]
let toEnd = items[3:] // [4, 5]
// Negative indices in slices
let allButLast = items[:-1] // [1, 2, 3, 4]
let lastTwo = items[-2:] // [4, 5]
let middle = items[1:-1] // [2, 3, 4]
// Single-line comment
let x = 42 // Inline comment
/* Multi-line
block comment */