Skip to content

[BUG] Claude Code reads .env files and hardcodes secrets into inline scripts #24185

@SDpower

Description

@SDpower

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Claude Code does not respect .gitignore when reading files. It reads .env containing sensitive credentials (tokens, passwords), then hardcodes
them directly into inline Python scripts shown in conversation history.

Expected behavior: Files listed in .gitignore (especially .env) should be treated as sensitive. Claude Code should never read credentials and
paste them into scripts or conversation output.

Actual behavior: Claude Code freely reads .env, extracts secrets, and embeds them in plaintext commands.

What Should Happen?

ask me how to do

Error Messages/Logs

Steps to Reproduce

Afetr 3 time plam , jsut tell any thing you needd totdo read some data. hi willl directy ren .env

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.34

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions