[BUG] unexpected loading of project's .env file when executing shell commands

Resolved 💬 5 comments Opened Jul 12, 2025 by ericbuehl Closed Jan 6, 2026

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: v1.0.48
  • Operating System: macOS 15.5
  • Terminal: Terminal App

Bug Description

My project has a .env file which my project loads and manages in-process. However, claude-code is taking it upon itself to load the variables into it's own environment before executing any commands. This is unexpected. If intentional a way to disable would be appreciated.

The bug described in https://github.com/anthropics/claude-code/issues/401 was closed without resolution. It is still an issue as of claude code v1.0.48

Steps to Reproduce

  1. create .env file in project
  2. launch claude
  3. tell claude to run any command
  4. observe that commands run with environment with variables defined in .env

Expected Behavior

claude should ignore my project's .env file

Actual Behavior

claude is sourcing my project's .env with no way to disable

Additional Context

<!-- Add any other context about the problem here, such as screenshots, logs, etc. -->

View original on GitHub ↗

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