This guide takes you from an empty directory to a running CLS program. You will scaffold a project withDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/elfrask/cls/llms.txt
Use this file to discover all available pages before exploring further.
clx new, inspect the generated files, execute your first script, run the static type checker, and produce a packaged application — all in a few short commands. Make sure you have clx on your PATH before continuing (see Installation if you haven’t built it yet).
Create a new project
Use The
clx new to scaffold a project directory with a manifest and a starter source file:clx new generates two files:cls.json — the project manifest:src/main.clsx — the entry-point source file:entry field in cls.json points to this file. clx run (with no arguments) reads cls.json to know where to start.Run the project
Execute the project directly from its root directory:Output:You can also target a specific source file explicitly:To pass command-line arguments to your script, append them after Inside the script,
--:args contains each value as a String:Check types
Run the static type checker without executing the program:To target a specific file or enable strict mode (which enforces all type annotations):If no errors are found, the checker reports success. Any type mismatches, unresolved names, or missing annotations in strict mode are reported with file, line, and column information before your code ever runs.
Hello World in Detail
The entry point for every CLS program is themain function. It receives the command-line arguments as an array of strings and must return an integer exit code:
CLS uses semicolons to terminate statements and to close block declarations. A plain statement ends with
;. A block-opening declaration (function, if, while, class, structure, etc.) closes its curly-brace block with };. This is intentional and consistent across the entire language.Variables, Functions, and String Interpolation
Here is a slightly more involved example that demonstrates variable declarations, a helper function, and CLS string interpolation:vardeclares a mutable variable;constdeclares an immutable binding.- Type annotations (
name: String,a: int) are optional but recommended —clx check --strictenforces them. - String interpolation uses
$namefor simple identifiers and${expression}for any expression. - Functions are declared with
function, a parameter list, an optional-> ReturnTypearrow, and a body closed by};.
Async Example
CLS has first-classasync/await support. Async functions are declared with the async keyword and can await any async expression:
Next Steps
Language Syntax
The complete syntax reference — control flow, data structures, classes, interfaces, CMX markup, error handling, and the import system.
Type System
Primitive types, generic collections, union types, type aliases, and how the static checker enforces them.
clx CLI Reference
Every
clx subcommand with all flags — run, check, build, maptype, ast, repl, lsp, and the package manager commands.cls.json Config
Full schema reference for the project manifest — compiler targets, optimization levels, sandbox policies, and dependency management.