An API key can leak through a prompt, a code diff, terminal output, a screenshot, or a tool that reads a local configuration file. A coding agent does not need to receive a key as a direct message to encounter it. Treat secrets as part of the project access boundary before you open a repository or run an agent.
Keep secrets out of the project and the conversation
Use environment variables or a secret manager for local development and deployment. Commit an example file with placeholder values when a project needs to document its configuration. Make sure actual environment files and credential exports are excluded from version control, and check the repository before asking an agent to inspect it.
A Git ignore rule only controls what Git usually tracks. It does not stop a process with file access from reading the file. Remove or mask credentials that the current task does not need. If the agent needs a local service, use a short lived credential with the smallest permission that works.
- Never paste a production key into a prompt or source file.
- Do not assume log masking will catch every secret format.
- Use test credentials for development tasks that do not need production access.
- Rotate a key promptly if it appears in a prompt, diff, or public log.
Review generated changes and automation access
Check every diff for credentials, private URLs, customer records, and copied environment values. Look at terminal output and generated screenshots before sharing them. If an agent runs in CI, limit the workflow token and expose each secret only to the step that needs it.
A coding tool’s instructions can ask it not to read a file, but they are not a security boundary. Use filesystem permissions, sandboxing, repository settings, and secret manager controls for requirements that must be enforced. Keep write, merge, and deployment credentials away from untrusted pull request jobs.
Respond clearly if a key was exposed
Revoke or rotate the exposed credential first, then check access logs and any actions it could perform. Remove the value from active branches and logs where possible, but do not treat deletion as a substitute for rotation. Search the repository and recent output for related values or copies.
Before connecting an AI coding CLI to a sensitive project, review the tool, model provider, and any integrations it can access. LucentraCode publishes security and configuration information; compare those terms with your organization’s requirements and use the least access needed for the task.
