# Where should an AI coding agent get its secrets from?

> An AI coding agent should get secrets from a store that releases only what a task needs, when a command runs, and records each read.

An AI coding agent should get its secrets from a store that releases only the values a task needs, at the moment a command needs them, and keeps a record of each release. It should not get them from the conversation, from the repository, or from a file it can read in full.

## The usual places

| Where the secret lives | What is true of it |
| --- | --- |
| The conversation | The value is part of the text the agent works from |
| The repository | Everyone and everything with access to the repository can read it |
| A `.env` file | Any process with file access can read every value in it |
| Your shell environment | Programs started from that shell inherit the variables you exported |
| A secrets manager, with a credential for the agent | The agent gets what that credential allows |

## What good looks like

- The agent finds secrets by name and description, not by reading values.
- Values go into the program that needs them when it starts.
- The agent has its own credential, limited to its task, and the credential expires.

## How Guardry does it

The agent searches names, descriptions and credential bundles without reading any value, then runs a program with the secrets injected into its environment:

```sh
guardry --profile coding-agent secrets list --search "billing sandbox" --json
guardry --profile coding-agent secrets run --secret API_KEY --secret DATABASE_URL -- python agent.py
```

Nothing is written to disk. The CLI does not cache secret values, and it removes `GUARDRY_*` variables from the environment of the program it runs.

Agents reach Guardry through the `guardry` CLI, its built-in MCP server and the `guardry-secrets` agent skill. A person creates each agent credential in the dashboard.

## Limits

An agent that can read a secret can copy it. Guardry is a hosted service and is not self-hosted.

## Questions

### Can I keep my .env file and also use Guardry?

You can import a `.env` file into Guardry, up to 100 entries per import. Guardry does not delete the source file, so the agent can still read the file until you remove it. See [Guardry vs .env files](https://guardry.ai/compare/env-files.md).

### Does the agent need to see the value at all?

Often it does not. `guardry secrets run` puts the value into the environment of the program it starts. For a GitHub token or a TOTP seed, an agent can use the credential through a service and never receive it. See [credential brokering](https://guardry.ai/answers/credential-brokering.md).

### What about CI jobs?

For CI and unattended runners, set `GUARDRY_URL=https://app.guardry.ai` and a protected `GUARDRY_TOKEN`, or `GUARDRY_TOKEN_FILE`.

---

Source: https://guardry.ai/answers/where-should-ai-agents-get-secrets/ · Updated 2026-11-27 · Guardry for language models: https://guardry.ai/llms.txt
