[BUG] .env value overriding model setting
Resolved 💬 3 comments Opened Dec 3, 2025 by jcoleman24 Closed Dec 3, 2025
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?
In a nutshell, I use an .env value for anthropic model in the project I am working on with the name of "ANTHROPIC_MODEL". This seems to be the same value that Claude Code uses. As such, every time I load this project in Claude Code it defaults to the model setting in the .env of the project rather than the model I want to use with Claude Code (set though the /model command). Thus, I have to reset this setting every time I launch Claude Code.
What Should Happen?
Claude Code should honor the /model setting and should persist across sessions.
Error Messages/Logs
Steps to Reproduce
- Have an .env file for project with a value set for "ANTHROPIC_MODEL" (e.g. "claude-sonnet-4-5-20250929")
- Open project in Claude Code.
- See that the model selected is the same as the .env value (claude-sonnet-4-5-20250929)
- Have to manually override this with the /model setting (e.g. Default/Opus 4.5)
- Close Claude Code
- Reopen Claude Code, see that the model setting has reverted back to the .env value ("claude-sonnet-4-5-20250929")
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.0.55
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗