Setup Scripts
Each repository can have an optional setup script that runs automatically whenever a new worktree is created for a session. Useful for installing dependencies, copying configuration files, or any other per-worktree initialization.
Configuring
Set a setup script when adding a repo, or update it later:
- Chat
- CLI
- MCP
"set the setup script for my-repo to npm install"
boss repo update my-repo --setup-script "npm install"
update_repo
Clear it with an empty string:
- Chat
- CLI
- MCP
"clear the setup script for my-repo"
boss repo update my-repo --setup-script ""
update_repo
Detected setup commands
When you add a repository, Bossanova inspects the repository without running any repository code and proposes the first matching setup command in this order:
- Makefile target: a
Makefiletarget namedsetup-worktree,setup, orbootstrap(in that order), including targets defined in literal relativeincludefiles. - Executable setup script: an executable regular file at
script/setup,scripts/setup.sh, orbin/setup(in that order; symlinks are not adopted). - Lockfile install:
pnpm-lock.yaml(pnpm install --frozen-lockfile),package-lock.json(npm ci),yarn.lock(yarn install --immutablewhen.yarnrc.ymlis present, otherwiseyarn install --frozen-lockfile),bun.lockorbun.lockb(bun install),uv.lock(uv sync), orGemfile.lock(bundle install). - Tool versions:
mise.tomlor.mise.toml(mise installwhenmiseresolves in your login shell), or.tool-versions(mise installwhenmiseresolves, otherwiseasdf installwhenasdfresolves).
A .devcontainer/devcontainer.json or .devcontainer.json file that declares
postCreateCommand is reported as evidence only and is not adopted.
In the TUI add-repository wizard's open flow, the Setup command field is
pre-filled with the detected command and shows a Detected from … note.
Accepting the pre-filled value stores the detected structured command, editing
the field stores your custom text instead, and clearing the field registers the
repository with no setup command. In the clone flow, leaving Setup command
empty adopts whatever setup command is detected in the repository after cloning.
Environment variables
The following environment variables are available to the setup script:
| Variable | Description |
|---|---|
REPO_DIR | Path to the main git repository (the original clone). |
WORKTREE_DIR | Path to the worktree being set up. |
These let you reference files in the main repo without hardcoding paths.
For example, to copy an .env file into each new worktree:
- Chat
- CLI
- MCP
"set the setup script for my-repo to copy .env into the worktree and then run npm install"
boss repo update my-repo \
--setup-script 'cp "$REPO_DIR/.env" "$WORKTREE_DIR/.env" && npm install'
update_repo
Every key in the worktree .env reaches every agent session in that
worktree. Rather than copying your whole .env, write only the keys
agents need into the worktree (for example, filter it with
grep -E '^(export )?(LINEAR_API_KEY|SENTRY_ORG)=' "$REPO_DIR/.env" > "$WORKTREE_DIR/.env")
and leave other secrets in the main checkout.
Automatic .env loading
Once a worktree contains a .env file, Bossanova loads it into the
environment of every agent session it starts in that worktree; you do
not need to source it or run direnv yourself. This is why the setup
script above copies .env into the worktree: the copy makes the file
present, and Bossanova picks it up automatically from there.
The daemon (bossd) runs under your OS service manager with no
interactive shell, so a normal shell's direnv/.env machinery never runs
for these sessions. To make repo-local variables available anyway,
Bossanova reads <worktree>/.env and overlays it beneath the
session's managed environment when it launches the agent. This applies to
interactive chats, resumed/woken chats, scheduled (cron) sessions,
headless runs, and automated repair runs alike.
A common use is resolving ${VAR} placeholders in a project's
.mcp.json. For example, an MCP server configured with an
Authorization: Bearer ${LINEAR_API_KEY} header only authenticates if
LINEAR_API_KEY is present in the session environment; putting it in the
worktree .env is enough. See the MCP guide.
Precedence and format
- Managed values win. The overlay is lowest-precedence: Bossanova's
own
BOSS_*variables and internal session values are never overridden by a repo.env, even if it defines the same key. - CLI-redirecting keys are ignored.
BOSS_SETTINGS_PATH,BOSS_KEYRING_BACKEND,BOSS_WEB_PORT,BOSS_CLOUD_URLandBOSSD_ORCHESTRATOR_URLin a worktree.envare never passed to a session, so a development daemon's settings in your.envcannot point agents at a different Bossanova instance. Values Bossanova sets itself are unaffected. - Missing is fine. A worktree with no
.env(or an empty/unreadable one) is a no-op: nothing is loaded and the session starts normally. - The parser is intentionally minimal. Blank lines and
#comment lines are ignored; an optional leadingexportis stripped; one pair of surrounding quotes is removed from a value. There is no variable interpolation, no multiline values, and no inline-comment stripping (a value may legitimately contain#). Keep.envfiles to simpleKEY=valuelines.
Values loaded from
.envare treated as secrets and are never logged.