Esc
Start typing to search...

CLI Reference

The keel unified command-line tool provides all Keel development utilities in a single binary.

Installation

See Installation for setup instructions.

Commands

keel run

Execute a Keel file or project.

keel run script.kl   # Run a specific file
keel run             # Run keel.toml main (inside a project directory)

keel -f

Shorthand for keel run:

keel -f script.kl

keel repl

Start the interactive REPL.

keel repl

See Using the REPL for details.

keel fmt

Format source code.

keel fmt file.kl             # Format in-place
keel fmt --check file.kl     # Check without modifying
keel fmt --stdout file.kl    # Print to stdout
keel fmt --width 80 file.kl  # Custom line width
echo 'let   x  =  42' | keel fmt  # Format from stdin

See the Formatter page for full documentation.

keel check

Type-check a Keel file without executing it.

keel check script.kl

Exits with code 0 if no errors are found. Useful for CI or editor integrations that want type checking without running the program.

keel lsp

Start the Language Server Protocol server.

keel lsp

The server communicates over stdio. See Language Server & Editor Setup for editor configuration.

keel tui

Open the terminal user interface — an integrated REPL, environment inspector, and DataFrame viewer.

keel tui
keel tui --module-root ./src        # Set the project root directory
keel tui --gateway-port 3000        # Expose an HTTP gateway for editor connections
keel tui --connection-file conn.json  # Use an existing Jupyter connection file

keel init

Initialize a new Keel project.

keel init                         # Initialize in the current directory
keel init my-project              # Create and initialize a new directory
keel init my-project --template pipeline   # Use a specific template

Available templates:

TemplateDescription
minimalBasic project with a single main file (default)
pipelineData pipeline with run and task
analysisScientific analysis with variables, imputation, and statistics

keel templates

List all available project templates.

keel templates

keel trace

Inspect compiler pipeline phases for a Keel file or inline source string — parsed AST, inferred types, bytecode, and VM execution trace.

The argument is treated as a file path if a file by that name exists; otherwise it is compiled directly as keel source.

keel trace "1 + 1"                # Inline source string
keel trace script.kl              # File path
keel trace script.kl --types      # Only inferred types
keel trace script.kl --bytecode --exec  # Bytecode and execution trace
keel trace "let x = 42" --focus "42"   # Narrow inline source to a fragment
keel trace script.kl --focus "3:1"     # Narrow to line 3, column 1
FlagOutput
--astParsed AST as JSON
--typesPer-binding inferred types
--bytecodeBytecode instruction table with source annotations
--execVM execution trace with register snapshots
--focus <str>Narrow all output to a source fragment or line:col position

See Tracing and Debugging for full documentation.

IO Security

File system IO is disabled by default for security.

VariableValuesEffect
KEEL_IO_DISABLED0 or falseEnable file/directory IO
KEEL_IO_READ_ONLY1 or trueAllow only read operations
KEEL_IO_SANDBOX/path/to/dirRestrict to directory

Examples

KEEL_IO_DISABLED=0 keel run script.kl                    # Enable IO
KEEL_IO_DISABLED=0 KEEL_IO_READ_ONLY=1 keel run script.kl # Read-only
KEEL_IO_DISABLED=0 KEEL_IO_SANDBOX=/tmp/sandbox keel run script.kl

Console operations (print, println, readLine) are always allowed.

HTTP Security

HTTP requests via the Http module are disabled by default.

VariableValuesEffect
KEEL_HTTP_DISABLED0 or falseEnable HTTP requests
KEEL_HTTP_ALLOWED_HOSTShost1,host2Restrict to listed hosts

Examples

KEEL_HTTP_DISABLED=0 keel run api-client.kl                    # Enable HTTP
KEEL_HTTP_DISABLED=0 KEEL_HTTP_ALLOWED_HOSTS=api.example.com keel run client.kl  # Restrict hosts

Request construction (Http.get, Http.withHeader, etc.) is always allowed — only Http.send requires HTTP to be enabled.

DataFrame Security

DataFrame file operations (readCsv, readJson, readParquet, writeCsv, writeJson) are enabled by default but can be restricted.

VariableValuesEffect
KEEL_DATAFRAME_DISABLED1 or trueDisable DataFrame file operations
KEEL_DATAFRAME_SANDBOX/path/to/dirRestrict file I/O to directory
KEEL_DATAFRAME_MAX_ROWS10000Limit rows loaded from files

Examples

KEEL_DATAFRAME_SANDBOX=/data keel run analysis.kl          # Restrict to /data
KEEL_DATAFRAME_MAX_ROWS=10000 keel run analysis.kl         # Limit row count
KEEL_DATAFRAME_DISABLED=1 keel run untrusted.kl            # Disable entirely

In-memory operations (select, filter, groupBy, etc.) are always allowed — only file I/O functions are affected by these controls.

For detailed information, see the IO Security Guide.

DateTime Security

DateTime operations can be disabled for untrusted code.

VariableValuesEffect
KEEL_DATETIME_DISABLED1 or trueDisable DateTime operations

Environment Variables

VariableDescription
NO_COLORDisable colored output
RUST_LOGEnable internal debug logging (e.g. RUST_LOG=debug for keel trace --exec)
KEEL_IO_DISABLED0 or false to enable file IO
KEEL_IO_READ_ONLY1 or true for read-only IO
KEEL_IO_SANDBOXRestrict IO to a directory
KEEL_HTTP_DISABLED0 or false to enable HTTP requests
KEEL_HTTP_ALLOWED_HOSTSComma-separated list of allowed HTTP hosts
KEEL_DATAFRAME_DISABLED1 or true to disable DataFrame operations
KEEL_DATAFRAME_SANDBOXRestrict DataFrame file I/O to a directory
KEEL_DATAFRAME_MAX_ROWSLimit rows loaded from files (e.g. 10000)
KEEL_DATETIME_DISABLED1 or true to disable DateTime operations

Exit Codes

CodeMeaning
0Success
1Compilation error
2Runtime error