Skip to main content

Configuration

Formatsโ€‹

.json, .jsonc, .json5, .yaml, .yml, .toml.

JS/TS (.js, .ts, .mjs, .cjs, .mts, .cts) need node on PATH and jiti in this project (npm i -D jiti), or --jiti npx.

Prefer YAML or TOML unless you need a programmed config.

Discoveryโ€‹

Default base name is stack.config. The first existing file wins. Extensions are tried in this order:

.js, .ts, .mjs, .cjs, .mts, .cts, .json, .jsonc, .json5, .yaml, .yml, .toml

Search paths:

  1. {cwd}/{configFile}{ext} โ€” e.g. stack.config.yaml
  2. {cwd}/.config/{name-without-.config}{ext} โ€” e.g. .config/stack.yaml
  3. {cwd}/.config/{configFile}{ext} โ€” e.g. .config/stack.config.yaml

If both stack.config.ts and stack.config.yaml exist, TypeScript wins and needs node plus jiti. Pass --config stack.config.yaml to force YAML.

Also loaded from the current working directory (not the home directory):

  • .env โ€” interpolated (${VAR} / $VAR); does not override already-set env vars; keys starting with _ are skipped.
  • .stackrc โ€” rc-style KEY=VALUE (dotted keys)

YAML, JSON, and TOML values are not interpolated. JS/TS configs can read process.env after .env loads.

extends is supported for local paths only. package.json is not read as config.

Precedenceโ€‹

Lowest to highest:

  1. Built-in defaults
  2. Configuration files (main file, local extends, CWD .stackrc)
  3. Environment variables (TUNNEL=true, NODE_ENV overlays, STACKRUN_JITI)
  4. CLI (--json, --tunnel, --command, --jiti)

NODE_ENV selects $<envName> and $env.<envName> overlays inside a layer (for example $development).

Referenceโ€‹

Top-level keys:

KeyTypeDefaultNotes
commandsarray[]Required to run
beforestring array[]Sequential hooks before services. Failure aborts the run.
afterstring array[]Sequential hooks after commands have exited (ok, fail, or Ctrl+C). Empty/omitted is a no-op.
processobjectsee belowProcess-manager options.

commandsโ€‹

Entries without a string run are ignored.

FieldTypeDescription
runstringShell command to run (required).
namestringLog prefix. Truncated to prefixLength (default 10) and printed as [name]; only that token is colored
prefixstringOptional log token. When set, used as-is (not sliced). Else name (sliced).
cwdstringWorking directory
envmapEnvironment variables (string or boolean)
colorstringPrefix color (red, green, yellow, blue, magenta, cyan, white)
tunnelobjectOptional per-command tunnel

A command may also be a bare string: commands: ["echo hello"].

before / afterโ€‹

String arrays. Each item runs sequentially in a shell with inherited stdio.

before failure aborts โ€” no commands, no after. Empty/omitted before / after is a no-op (no error).

after always runs once commands have exited (ok, fail, or Ctrl+C). killOthers only kills siblings. A failed after hook still fails the run.

processโ€‹

process:
killOthers: failure
handleInput: true
colors: auto
prefixLength: 10
cwd: .

process.cwd is the default working directory for commands and hooks that omit cwd. A per-command cwd wins.

Child logs look like [api] โ€ฆ. Color is on the bracketed name only.

extends: [a, b] treats a as higher-priority defaults than b (main file and .stackrc still win over both).

Environment variablesโ€‹

VariableEffect
TUNNEL=trueSame as --tunnel (exact string "true", not 1 / yes)
NODE_ENVSelects $development / $production / $test (and $env.<name>) overlays
STACKRUN_JITISame as --jiti (local or npx). JS/TS configs only.
STACKRUN_BINARYnpm wrapper only. Path to a native stackrun binary.
STACKRUN_CACHEnpm wrapper only. Cache dir (default ~/.cache/stackrun).
STACKRUN_SKIP_DOWNLOADnpm wrapper only. 1 skips GitHub download.

JS/TS configโ€‹

Needs node on PATH and jiti importable from this project (npm i -D jiti).

export default {
commands: [
{ name: "api", run: "npm run dev", cwd: "./api" },
{ name: "web", run: "npm run dev", cwd: "./web" },
],
};
stackrun --config ./stack.config.ts
stackrun --config ./stack.config.ts --jiti npx