Environment variables

Every session writes a .env.ecluse file in the worktree. ecluse up --json and ecluse env return these as JSON.

VariableDescription
ECLUSE_SLOTSlot number (integer, 1–max_slots)
ECLUSE_MODEActive mode (container, host, or hybrid)
ECLUSE_SLUGSession name (the slug passed to ecluse up)
PORTAlias for the first native [[services]] entry — framework-compatible
ECLUSE_<NAME>_PORTPer-service port — one per [[services]] entry

Example

Config:

[[services]]
name = "api"
base_port = 3000

[[services]]
name = "postgres"
run = "docker"
base_port = 5432

Session feat-foo on slot 2:

ECLUSE_SLOT=2
ECLUSE_MODE=hybrid
ECLUSE_SLUG=feat-foo
PORT=3002
ECLUSE_API_PORT=3002
ECLUSE_POSTGRES_PORT=5434

Using env vars in your app

For most frameworks, PORT is all you need. For multi-service apps, read ECLUSE_<NAME>_PORT directly:

// Node
const port = process.env.PORT;
const dbPort = process.env.ECLUSE_POSTGRES_PORT;
# Python
import os
port = os.environ["PORT"]
db_port = os.environ["ECLUSE_POSTGRES_PORT"]