Skip to content

feat: preserve user-set env vars across remote config sourcing#7

Open
busla wants to merge 1 commit intomainfrom
feat/preserve-user-env-overrides
Open

feat: preserve user-set env vars across remote config sourcing#7
busla wants to merge 1 commit intomainfrom
feat/preserve-user-env-overrides

Conversation

@busla
Copy link
Copy Markdown
Contributor

@busla busla commented Apr 21, 2026

Summary

  • Save ANTHROPIC_* and CLAUDE_CODE_* env vars before sourcing the cached remote config, restore them after
  • User-exported env vars (via .envrc, shell, direnv) always win over remote defaults
  • Enables per-project model overrides without modifying any shared config

Usage

# In project .envrc or exported in shell:
export ANTHROPIC_MODEL=opus-4-7
export ANTHROPIC_DEFAULT_OPUS_MODEL=opus-4-7

# Wrapper preserves these across remote config sourcing
claude

Test plan

  • Set ANTHROPIC_MODEL=opus-4-7 in a project .envrc, run claude, confirm model is opus-4-7
  • Run claude without overrides, confirm remote config defaults still apply
  • Confirm middleware.sh still works after remote config sourcing
  • Confirm --clear-cache still works

🤖 Generated with Claude Code

The remote config (claude-env.sh) unconditionally exports ANTHROPIC_MODEL
and other vars, clobbering any values the user set via .envrc, shell
exports, or direnv. This makes it impossible to override the default
model per-project.

Save ANTHROPIC_* and CLAUDE_CODE_* env vars before sourcing the remote
config, then restore them after. User-exported env vars always win over
remote defaults.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant