Keeping credentials out of your coding agent’s model context A developer built ContextVeil, an open-source, local tool that strips selected secret values from coding agent tool output before it reaches the model's context. It uses deterministic, exact matching on .env and configuration files, storing references rather than credential copies, and supports Claude Code in production plus experimental Codex CLI, GitHub Copilot CLI and OpenCode integrations. The tool does not sandbox the agent and cannot catch transformed values such as Base64-encoded secrets. I always had a slightly bad feeling about the credentials my coding agent could access. Did I secure things enough? Probably not. But I also didn't want to cripple it by blocking access to files it needed to understand my project. That left me doing nothing about it. When I learned about hooks in coding agent harnesses, I wondered: could I let the agent read the files, but remove the secret values from the output before it reaches the model? This became ContextVeil https://github.com/daniel-sc/contextveil , a small, local, open-source tool. When debugging an application, reading .env.local can be quite useful. The model might need to know which database you connect to or whether a feature flag is enabled. But the API token next to these settings usually isn't needed. Of course, credentials should generally live in a credential store. In practice, projects also have .env files, configuration files and environment variables containing secrets. And these are not necessarily limited to disposable development credentials. I see this as sensible hygiene: if the model doesn't need the credential, why put it into its context? A value that never reaches the model cannot accidentally be repeated by it in a generated example or a response. For example, Claude Code might run cat .env.local and receive: DATABASE URL=postgres://localhost/my app API TOKEN=cv example canary not a real token LOG LEVEL=debug If you have selected API TOKEN for protection, ContextVeil changes the supported tool result before it reaches the model: DATABASE URL=postgres://localhost/my app API TOKEN=