Environment variables
Every environment variable kscript reads. Most projects need none of them: settings belong in kscript.json and the config files. These are for what changes from one computer, container or run to the next, such as the environment a server runs in or where it keeps its data.
Set a variable for one command by putting it in front, or export it in your shell, CI settings or Dockerfile. Values from a project's .env files become environment variables too, unless one is already set.
KSCRIPT_ENV=staging kscript serve
export KSCRIPT_STACK_TRACE=1Running scripts
KSCRIPT_ENV
The environment a script or server runs in, such as staging or production. Its settings files (kscript.staging.json, .env.staging) are layered over the base ones, and the database connection for it is used. kscript --env wins over it, and sets it for the scripts it starts. More in The language.
When it isn't set: config.environment in kscript.json, else none.
KSCRIPT_ENV=production kscript serveKSCRIPT_STACK_TRACE
Set to 1 to show the .NET exception and stack trace under an error, as kscript --stack-trace does. 0 and false leave it off. More in Error codes.
When it isn't set: off.
KSCRIPT_STACK_TRACE=1 kscript app.kscriptKSCRIPT_ERROR_PATHS
Set to full and the error a script stops with names its file by its whole path, so an editor that runs scripts can link to the line. More in VS Code.
When it isn't set: paths relative to the folder.
KSCRIPT_ERROR_PATHS=full kscript tools/report.kscriptKSCRIPT_LOCALE
The locale for translations when the script doesn't choose one with locale(set: ...) and $config.i18n.locale isn't set. More in The language.
When it isn't set: the computer's language.
KSCRIPT_LOCALE=fr kscript invoice.kscriptKSCRIPT_INTERPRET
Set to 1 to run every statement through the interpreter instead of compiling loop and function bodies, to check whether the compiler changes what a script does. Scripts run several times slower. More in The language.
When it isn't set: loop and function bodies are compiled the first time they run.
KSCRIPT_INTERPRET=1 kscript solve.kscriptKSCRIPT_NO_REGIONS
Set to 1 to keep every variable of a compiled body in scopes found by name, as the interpreter does, to check whether slots change what a script does. More in The language.
When it isn't set: a function or loop body keeps the variables it declares in numbered slots.
KSCRIPT_NO_REGIONS=1 kscript solve.kscriptKSCRIPT_NO_TREES
Set to 1 to keep compiled bodies as chains of small functions rather than turning busy ones into .NET methods, to check whether that step changes what a script does. More in The language.
When it isn't set: a body with a loop, or one that has run 64 times, is compiled to a .NET method.
KSCRIPT_NO_TREES=1 kscript solve.kscriptKSCRIPT_NO_LOOPS
Set to 1 to run every compiled loop the one general way, without the copy that takes its variables to be numbers and lists, to check whether that copy changes what a script does. More in The language.
When it isn't set: a loop of plain number work gets a second, faster copy in its compiled method.
KSCRIPT_NO_LOOPS=1 kscript solve.kscriptCI
Set by CI services such as GitHub Actions. When it is set (and not false or 0), kscript test runs every test, as --all does. More in Testing.
When it isn't set: kscript test in a project runs only the tests a change since the last run can affect.
CI=true kscript testServing and Docker
KSCRIPT_SECRET
The app's secret: kscript serve signs live pages and components with it, and @signed_url(), @encrypt() and @decrypt() use keys made from it. Set it to a long random value so pages already open, signed links and encrypted values keep working after a restart, and so every server behind a load balancer accepts them. More in Components.
When it isn't set: a new random key each time kscript starts.
KSCRIPT_SECRET="$(openssl rand -hex 32)" kscript serveKSCRIPT_SERVE_IN_DOCKER
Tells kscript serve it is already inside a container, so it starts the web server instead of handing over to Docker. The Dockerfiles kscript make docker writes set it. Set it yourself in a custom image that runs kscript serve. More in Projects and kscript.json.
When it isn't set: kscript serve hands over to Docker when the project has a Compose file.
docker run -e KSCRIPT_SERVE_IN_DOCKER=1 my-app kscript serveKSCRIPT_SERVE_MIGRATE
Set to 1 and kscript serve applies pending migrations before it serves, and stops if one fails. kscript serve --docker sets it in the container, so you don't need to. More in Projects and kscript.json.
When it isn't set: migrations are left to kscript db migrate.
KSCRIPT_SERVE_MIGRATE=1 kscript serveKSCRIPT_LIVE_RELOAD
Set to 0 to turn off live reload in kscript serve, as --no-reload does, so open pages aren't refreshed when a file changes. kscript serve --docker --no-reload passes it into the container. More in Web pages.
When it isn't set: on.
KSCRIPT_LIVE_RELOAD=0 kscript serveKSCRIPT_SOURCE
The KScript checkout the Docker files kscript make docker writes build from, for an unpublished or modified runtime. It is read by docker compose, not by kscript. More in Projects and kscript.json.
When it isn't set: the released KScript source.
KSCRIPT_SOURCE=/absolute/path/to/kscript docker compose up --buildProjects and data
KSCRIPT_STORAGE_ROOT
Moves every app's folders to <root>/<app>/<kind>, such as <root>/notes/data: KScript.Auth's users and sessions, @storage() files and the file cache. It needs an absolute path. It is handy for tests, portable installs and containers. More in App folders: KScript.Storage.
When it isn't set: each app's usual folders for this computer.
KSCRIPT_STORAGE_ROOT=/var/lib/kscript/storage kscript serveKSCRIPT_PROJECT_DATA_ROOT
The folder relative auth and SQLite paths in kscript.json are under, instead of the project folder, such as when the project folder is read-only. It needs an absolute path, and a path that leaves it is an error. More in App folders: KScript.Storage.
When it isn't set: the project folder.
KSCRIPT_PROJECT_DATA_ROOT=/var/lib/kscript/project kscript serveKSCRIPT_TEMPLATES
The folder of your own kscript make project templates. kscript make templates project copies the built-in ones there to start from. More in Projects and kscript.json.
When it isn't set: ~/.kscript/templates.
KSCRIPT_TEMPLATES=~/work/kscript-templates kscript make project shop --template apiDATABASE_URL
The database to use when kscript.json and the config files don't set one, such as postgres://app:secret@localhost:5432/app. More in Databases: KScript.Data.
When it isn't set: data/app.sqlite in the project folder.
DATABASE_URL=postgres://app:secret@localhost:5432/app kscript serveLanguage models
ANTHROPIC_API_KEY
The API key KScript.AI sends to Claude. Scripts never hold the key themselves. More in The language.
When it isn't set: KScript.AI uses ANTHROPIC_AUTH_TOKEN, or the ant auth login profile.
ANTHROPIC_API_KEY=sk-ant-... kscript triage.kscriptANTHROPIC_AUTH_TOKEN
An OAuth token KScript.AI sends instead of an API key, when ANTHROPIC_API_KEY isn't set. Without either, it uses the profile ant auth login saved. More in The language.
When it isn't set: KScript.AI uses the ant auth login profile, if there is one.
ANTHROPIC_AUTH_TOKEN=... kscript triage.kscriptANTHROPIC_BASE_URL
Sends KScript.AI's requests to another host, such as a proxy or a stand-in server for tests. More in The language.
When it isn't set: Anthropic's API.
ANTHROPIC_BASE_URL=http://127.0.0.1:8765 kscript triage.kscriptKSCRIPT_AI_MODEL
The model llm and @llm() use when a script doesn't name one with model:. More in The language.
When it isn't set: claude-opus-5-5.
KSCRIPT_AI_MODEL=claude-haiku-5-5 kscript triage.kscriptInstalling and updating
KSCRIPT_VERSION
The release the install script installs, such as v0.34.0. The Dockerfiles kscript make project writes take it as a build argument to pin one. To run another version on a computer that already has kscript, use kscript version use or KSCRIPT_USE. More in Install and editors.
When it isn't set: the latest release.
curl -fsSL https://raw.githubusercontent.com/kylepantall/kscript/master/install.sh | KSCRIPT_VERSION=v0.34.0 shKSCRIPT_USE
The version of KScript to run, for every command in this terminal or just one: an exact release such as 0.50.0, a series such as 0.50 (its newest release) or latest. It wins over the project's kscript.json and the computer's default. A version that isn't on the computer yet is downloaded the first time, and checked against its release's SHA256SUMS. More in /guide/install#switching-versions.
When it isn't set: the project's "kscript" setting, else the default from kscript version use.
KSCRIPT_USE=0.49.0 kscript testKSCRIPT_SWITCHED
Set by kscript for the version of KScript it runs for you (see KSCRIPT_USE), so that version runs the command itself. You don't set it. More in /guide/install#switching-versions.
When it isn't set: not set.
kscript versionKSCRIPT_INSTALL
The folder the install script puts kscript in. The binary goes in its bin folder. More in Install and editors.
When it isn't set: ~/.kscript, or %LOCALAPPDATA%\Programs\kscript on Windows.
curl -fsSL https://raw.githubusercontent.com/kylepantall/kscript/master/install.sh | KSCRIPT_INSTALL=/opt/kscript shKSCRIPT_NO_MODIFY_PATH
Set to 1 and the install script doesn't add kscript to your shell profile or your Windows PATH. More in Install and editors.
When it isn't set: the install script adds kscript to your PATH.
curl -fsSL https://raw.githubusercontent.com/kylepantall/kscript/master/install.sh | KSCRIPT_NO_MODIFY_PATH=1 shKSCRIPT_REPO
The GitHub repository the install scripts, kscript update, kscript version, kscript compile and kscript ide install download releases from, such as a fork. kscript says which repository it used when it isn't the usual one. More in Install and editors.
When it isn't set: kylepantall/kscript.
KSCRIPT_REPO=my-org/kscript kscript updateGITHUB_TOKEN
A GitHub token kscript update and kscript ide install send with their requests, so they aren't limited the way requests without one are, such as on a shared CI runner. More in Install and editors.
When it isn't set: requests go without a token.
GITHUB_TOKEN=ghp_... kscript updateTerminal output
NO_COLOR
Set to anything and kscript, echo and KScript.Terminal print without colours. More in Testing.
When it isn't set: colours are used in a terminal.
NO_COLOR=1 kscript testFORCE_COLOR
Set to 1 to keep colours when the output isn't a terminal, such as in CI logs. 0 and false turn them off. More in Testing.
When it isn't set: colours are used only in a terminal.
FORCE_COLOR=1 kscript test | tee test.logTERM
When it is dumb, kscript prints without colours.
When it isn't set: set by your terminal.
TERM=dumb kscript checkCOLUMNS
How wide kscript's tables, lines of dots and wrapped text are, instead of the terminal's own width.
When it isn't set: the terminal's width, or 80.
COLUMNS=120 kscript db status