When you wire an AI coding agent (Claude Code, Cursor, VS Code Copilot, or Claude Desktop) into a real backend repository, secret leakage rarely happens because someone deliberately uploads .env.production .
It happens silently during normal debugging loops:
A failing integration test prints a connection error containing postgresql://svc_billing:[email protected]:5432/ledger .
A curl trace or Kubernetes ConfigMap dump includes an active Authorization: Bearer eyJ... JWT, an sk-proj-... OpenAI key, or an internal corporate hostname.
If you manually scrub values into ***REDACTED*** before prompting the model, two things break immediately :
Lost referential equality : When service-a/.env and docker-compose.yml hold different API keys (a classic config-drift bug), replacing both with ***REDACTED*** blinds the LLM to the mismatch.
Broken code round-trips : Every refactored snippet the LLM hands back now has literal ***REDACTED*** strings baked in, forcing error-prone manual copy-paste restoration.
Here…