CLI Reference

July 16, 2026 · View on GitHub

Complete reference for the sage command-line interface.

Top-Level Invocations

CommandMeaningNotes
sageStart the interactive REPLSame as sage --repl
sage --replStart the interactive REPLMulti-line blocks are supported
sage --helpPrint CLI usageShows compiler, tooling, and REPL entry points
sage -c "source"Execute a source stringRuns without loading a file
sage <file.sage> [arg ...]Run a Sage source fileExtra arguments are available through sys.args()
sage <file.sgvm>Run a compiled SGVM binaryRuns via integrated MetalVM engine
sage --lspStart the LSP server on stdin/stdoutsage-lsp is the standalone companion binary
sage fmt <file>Format a file in placePrints Formatted: <file> on success
sage fmt --check <file>Check formatting without rewritingExit code 1 when formatting is needed
sage lint <file>Run the static linterExit code 1 when issues are found
sage check <file>Type-check annotationsValidates annotations against inferred types

Compiler And Codegen Commands

CommandOutput DefaultSupported Options
sage --compile-to-lily <input.sage><input>.lily-o <path>
sage --compile-from-lily <input.lily><input>.sage-o <path>
sage --emit-c <input.sage><input>.c-o <path>, -O0-O3, -g
sage --compile <input.sage><input-without-.sage>-o <path>, --cc <compiler>, -O0-O3, -g
sage --emit-vm <input.sage><input>.svm-o <path>, -O0-O3, -g
sage --sgvm <input.sage><input>.sgvm-o <path>, -O0-O3, -g
sage --emit-llvm <input.sage><input>.ll-o <path>, -O0-O3, -g
sage --compile-llvm <input.sage><input-without-.sage>-o <path>, -O0-O3, -g
sage --emit-asm <input.sage><input>.s-o <path>, --target <arch[-profile]>, -O0-O3, -g
sage --compile-native <input.sage>hosted: executable; non-hosted: .o-o <path>, --target <arch[-profile]>, -O0-O3, -g
sage --emit-pico-c <input.sage><input>.pico.c-o <path>
sage --compile-pico <input.sage>.tmp/<name> build dir + <name>.uf2-o <dir>, --board <name>, --name <program>, --sdk <path>, --chip <type>
sage --compile-bare <input.sage><input-without-.sage>.elf-o <path>, --target <arch>, -O0-O3, -g
sage --compile-uefi <input.sage><input-without-.sage>.efi-o <path>, --target x86_64|aarch64, -O0-O3, -g
sage --emit-kotlin <input.sage><input>.kt-o <path>
sage --compile-android <input.sage>Gradle project dir--package, --app-name, --min-sdk
sage --jit <input.sage> -o <bin><bin> executableJIT self-extracting executable with module bundling

Option Semantics

OptionApplies ToMeaning
-o <path>All emit/compile commandsOutput file or output directory depending on command
--cc <compiler>--compileOverrides the host C compiler; defaults to cc
--target <arch[-profile]>--emit-asm, --compile-nativeTarget architecture/profile. Base arch: x86-64, x86_64, aarch64, arm64, rv64, riscv64, mips, mips32, mips74k. Profile suffixes: -baremetal, -osdev, -uefi
-O0 / -O1 / -O2 / -O3C, LLVM, and native codegenOptimization pass level
-gC, LLVM, asm, and native compile/emitEnables debug information in the generated output
--runtime ast|bytecode|jit|aotRun commandsRuntime mode selection
--jitRun commandsEnable JIT profiling; if used with -o, compiles to a self-extracting executable with bundled module dependencies
--aotRun commandsEnable AOT compilation
--verbose / -vAllGate internal compiler diagnostic messages
--math-workRun commandsConfigure math execution modes
--gc:tracing|arc|orcRun/compileGarbage collector mode
--board <name>--compile-picoPico board name; defaults to pico
--name <program>--compile-picoProgram name for generated files; defaults to input basename
--sdk <path>--compile-picoPico SDK path; falls back to PICO_SDK_PATH
--chip <type>--compile-picoChip type: rp2040, rp2350-arm, rp2350-riscv; defaults to rp2040
--package--compile-androidApplication package name
--app-name--compile-androidApplication display name
--min-sdk--compile-androidMinimum Android SDK level

Target profiles

  • hosted (default, no suffix) — current behavior, executable-oriented flow.
  • -baremetal / -osdev — emits freestanding entry symbol (sage_entry) and object-oriented native output.
  • -uefi — emits efi_main entry symbol (freestanding object; full PE/COFF image linking is planned).

REPL Commands

See Tooling_Guide.md for the full REPL command table.