[BUG] Claude Code sources .env

Resolved 💬 3 comments Opened Dec 9, 2025 by in-op Closed Dec 9, 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?

Claude code sources .env files located in your project's root directory. I noticed this when my project had a .env with export DEBUG=1 and it set "Debug mode enabled" when opening Claude Code.

This is presumably the cause of the following other issues:

This behavior is completely undocumented. It also should not happen. .env files are extremely common in development and users are going to be tinkering with Claude Code unexpectedly when there are name conflicts for environment variables that Claude Code is looking for, when you want to be configuring your app.

What Should Happen?

Do not source .env by default. If you want to keep the feature, at least make it opt-in and document it.

Error Messages/Logs

Steps to Reproduce

Create a .env file at the root of your project, include export DEBUG=1, and open Claude Code in that same directory.

Claude Model

None

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.0.56

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

I've tried in iterm, the PyCharm terminal, and the PyCharm plugin, doesn't seem to matter

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗