[BUG] env in ~/.claude/settings.json breaks OAuth authentication on macOS
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Setting any CLAUDE_CODE_* variables inside the env object of ~/.claude/settings.json completely breaks OAuth authentication. /login reports success and writes a valid token to the macOS Keychain, but every subsequent command — interactive and -p — returns Not logged in · Please run /login.
The same variables set via shell export (or inline VAR=value claude) do not break auth. The issue is specific to how settings.env is loaded during startup.
This is especially confusing because the variables involved (CLAUDE_CODE_AUTO_COMPACT_WINDOW, CLAUDE_CODE_SIMPLE, CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING) are unrelated to authentication, so the failure mode gives no hint about the root cause. I spent several hours doing clean reinstalls, Keychain wipes, and full configuration resets before identifying the env block as the trigger.
What Should Happen?
env entries in settings.json that are unrelated to authentication should not affect credential loading. At minimum, if this is an intended interaction, there should be a clear error message pointing to settings.env as the cause rather than a generic Not logged in.
Error Messages/Logs
Steps to Reproduce
- Fresh install of Claude Code on macOS (native installer), authenticated via /login with a subscription — confirmed working.
- Add to ~/.claude/settings.json:
"env": {
"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "400000",
"CLAUDE_CODE_SIMPLE": "1",
"CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING": "1"
}
- Start claude (any mode) — all commands return Not logged in · Please run /login.
- Run /login again — flow completes successfully, Keychain entry updated (confirmed via
security find-generic-password -s "Claude Code-credentials", cdat reflects current time). - Still: Not logged in on every command.
- Remove the env block from settings — authentication immediately works again, no re-login required.
- Set the same variables via shell (export CLAUDE_CODE_SIMPLE=1 etc. in ~/.zshrc, or inline CLAUDE_CODE_SIMPLE=1 claude) — auth works normally.
Claude Model
None
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
version: 2.1.97 (npm/Homebrew), also reproduced on 2.1.112 (native)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗