docs DocsCapabilitiesGitHub
Guides / Environment variables
Guides / Environment variables

Environment Variables

Env Vars Live on Profiles

Agent definitions are binary-only. All env vars, secrets, and settings belong on the profile. The same claude binary uses different API keys in different profiles:

# ~/.config/aide/config.yaml
agents:
  claude:
    binary: claude
# ~/.config/aide/profiles/personal.yaml
agent: claude
env:
  GITHUB_TOKEN: "{{ .secrets.personal_key }}"
# ~/.config/aide/profiles/work.yaml
agent: claude
env:
  GITHUB_TOKEN: "{{ .secrets.work_key }}"

Literal Values

Pass a plain string and aide forwards it unchanged. No secrets file required:

env:
  AWS_PROFILE: "work"
  AWS_REGION: "us-east-1"

Template Syntax

Three variables are available inside {{ }} expressions:

Example using all three:

# ~/.config/aide/profiles/work.yaml
agent: claude
secret: work
env:
  GITHUB_TOKEN: "{{ .secrets.github_token }}"
  PROJECT_ROOT: "{{ .project_root }}"
  AGENT_TMPDIR: "{{ .runtime_dir }}"

Setting Env Vars

aide env set KEY VALUE writes a literal value to the CWD-matched profile:

aide env set AWS_PROFILE work
aide env set AWS_REGION us-east-1
aide env set CONTEXT_VAR value --profile work

Referencing Secrets in Env Vars

Use --secret-key to write a template expression that references a key in the profile’s secret store, rather than a raw value. --global is required because secrets are profile-scoped:

aide env set GITHUB_TOKEN --secret-key github_token --global
aide env set GITHUB_TOKEN --secret-key github_token --profile work --global
aide env set GITHUB_TOKEN --pick --global

The profile must already have a secret store bound (via aide profile set-secret <name>) before using --secret-key or --pick. To read from a different store without changing the profile binding, pass --secret-store <name> explicitly alongside --secret-key or --pick.

Pass --pick instead of --secret-key to open an interactive picker. aide decrypts the secrets file and presents available keys to choose from.

Listing Env Vars

aide env list shows all env vars for the CWD-matched profile with source annotations:

Profile: work
  GITHUB_TOKEN   ← secrets.github_token
  AWS_REGION          = us-east-1
  PROJECT_ROOT        ← project_root
  AGENT_TMPDIR        ← runtime_dir

Use --profile to target a specific profile:

aide env list --profile work

Removing Env Vars

aide env remove KEY deletes an env var from the CWD-matched profile:

aide env remove GITHUB_TOKEN
aide env remove AWS_REGION --profile work

Gateway Keys, Protocol Tokens, and Multiplexer Vars

aide removes provider keys (ANTHROPIC_API_KEY, OPENROUTER_API_KEY, and every key a gateway preset knows) and any inherited AIDE_GW_* variable from the environment the agent inherits. A key exported in your shell therefore reaches a harness only through a gateway you chose, which injects it as AIDE_GW_<NAME>_KEY. Provider endpoints and cloud switches (ANTHROPIC_BASE_URL, CLAUDE_CODE_USE_BEDROCK) belong in a gateway, not in env:.

In addition, every launch scrubs:

Clean Env Mode

Enable with --clean-env at launch or clean_env: true in the sandbox config. The agent starts with only aide-injected vars. aide preserves standard vars (PATH, HOME, USER, SHELL, TERM, LANG, TMPDIR, XDG_RUNTIME_DIR, XDG_CONFIG_HOME) and strips all other inherited shell environment:

# ~/.config/aide/profiles/work.yaml
agent: claude
sandbox:
  clean_env: true

Clean env mode prevents credential leakage from the parent shell and makes the agent’s environment predictable and controlled within a given configuration.