Skip to content
VacuumPrompts
HomeHow it worksFeaturesPrivacyInteractive examplesFAQ Help Center Download

GUIDE

How to stop .env files and passwords leaking to AI coding tools

Last updated 2026-11-25

Coding agents explore your project by reading files and running commands. If a real key sits in a .env file, a config or a log, it can end up in a model request without you noticing. Here is how to close those gaps.

How secrets reach the AI

  • The agent reads a .env or config file to understand how the app is set up.
  • A command prints environment variables or a connection string, and the output is sent back to the model.
  • You attach or paste a log that contains a token.
  • An open editor tab with credentials is included as context.

Fixes that work

  • Keep only placeholder values in .env.example, and keep real values in a secret manager or your OS credential store.
  • Use short-lived, low-permission keys for local development, so a leaked key does less damage.
  • On Copilot Business or Enterprise, add sensitive paths to content exclusion.
  • Close credential files before starting an agent task, and avoid commands that print secrets.
  • Rotate any key you suspect was sent to an AI tool.
  • Add a local redaction layer. VacuumPrompts runs on your Windows PC and replaces recognised secrets in supported Copilot, Claude Code, Codex and ChatGPT requests with placeholders such as [CREDENTIAL_1] before they are sent.

Why .gitignore is not enough

.gitignore keeps a file out of your repository. It does not stop an AI tool on your machine from opening that file or seeing it in command output. Treat AI tools like any other program that can read your working folder.

Frequently asked questions

Does .gitignore stop Copilot from reading my .env file?

Not reliably. .gitignore controls what git tracks, not what tools on your PC can read. Use content exclusion where available and keep real secrets out of the project folder.

How do I stop Copilot from sending my passwords?

Keep passwords out of files and logs the agent can read, use content exclusion on business plans, and add local redaction such as VacuumPrompts for anything that slips through.

What should I do if a key was sent to an AI?

Rotate it. Revoking and replacing the key is the only way to be sure it cannot be used.

Download VacuumPrompts free for Windows

More guides

  • How to reduce GitHub Copilot token usage
  • Codex usage limit reached too fast? Here’s how to save tokens
  • How to save tokens in ChatGPT and reduce LLM costs
  • How to stop API keys and passwords leaking into ChatGPT and Copilot

All guides

About & contact · Privacy Policy · Terms of Use · Changelog

VacuumPrompts

The vacuum cleaner for AI prompts: no dust, no dirt, just the prompt. Free for Windows 10 & 11, runs entirely on your PC.

SOLUTIONS

  • Prompt optimizer
  • Token optimization
  • Prompt security
  • Prompt spelling corrector
  • Guides

PRODUCT

  • How it works
  • Features
  • Privacy
  • Interactive examples
  • Download
  • Benchmark
  • Changelog

HELP

  • FAQ
  • Help Center
  • Uninstall guide
  • Contact support privately
  • Report a bug publicly ↗

COMPANY

  • About & contact
  • Releases on GitHub ↗
  • Privacy Policy
  • Terms of Use

v0.1.50 Preview · Windows · © 2026 The VacuumPrompts team