Skip to content

Shell Environment Inheritance

Workbench captures the full environment of your interactive login shell at launch and injects it as the lowest-precedence source into the env-provider dispatcher. This means tools installed via Homebrew, nvm, pyenv, SDKMAN, or any other shell-profile mechanism are visible to agents and terminals without extra configuration.

  1. Launch snapshot — on startup, Workbench records the process’s own environment as the baseline.
  2. Shell probe — a background thread spawns $SHELL -l -i -c 'printf "\0"; env -0' (or an equivalent fish script) and parses the NUL-delimited output. The leading NUL sentinel ensures any rc-file banner output is discarded.
  3. Diff — the probe result is compared against the baseline. Keys that are new or changed become the forwarded set; keys present in both with identical values become the inherited set (shown separately in Settings for reference).
  4. Denylist — a built-in denylist strips security-sensitive variables (LD_PRELOAD, DYLD_*, BASH_FUNC_*, etc.) and shell-presentation noise (PS1, STARSHIP_*, PROMPT_*). Users can add glob patterns in Settings to extend this list.
  5. Injection — the filtered forwarded vars are injected as precedence 0 (lowest) into the env-provider dispatcher, so plugin-provided values (direnv, mise, dotenv, Nix devshell) always win on collision.

The probe re-runs automatically when any of your shell rc files change (.zshrc, .bashrc, .bash_profile, .profile, .config/fish/config.fish, etc.).

The Environment section in Settings shows the captured shell environment and provides controls to manage it.

SettingDescriptionDefault
Forwarded variablesVariables from your shell that differ from the launch baseline. Values are masked by default; click Show values to reveal.
Inherited variablesVariables present in both your shell and the baseline with identical values (read-only, for reference).
ReloadRe-probe $SHELL and refresh the captured environment.
Disable shell envGlobally disable shell-env injection. Agents and terminals will not receive the captured variables. Other env providers (direnv, mise, etc.) are unaffected.Off
User deny patternsGlob patterns (one per line) for variables you want excluded from forwarding, on top of the built-in denylist.Empty
Built-in deny detailsExpandable list showing the hardcoded denylist entries.

Shell-env sits at the bottom of the env-provider stack:

PrecedenceSource
4 (highest)direnv
3mise
2dotenv
1Nix devshell
0 (lowest)Shell environment

If direnv exports GOPATH=/workspace/go and your shell has GOPATH=/home/you/go, direnv wins.

  • macOS / Linux — the probe runs the user’s $SHELL with login + interactive flags. Fish uses a dedicated script that avoids the POSIX env -0 incompatibility.
  • Windows — there is no shell probe. shell_path_is_cached() returns true immediately. Registry-based PATH refresh (winreg) is handled separately in env.rs.

Shell-env probe events are logged under the workbench::env tracing target. If the probe fails (missing shell binary, timeout, parse error), a warning is logged and the shell-env source is simply absent — agents fall back to the other env providers.


Original source: utensils.io/claudette