guardry/Guides/Limit to one environment
How to limit an AI agent to one environment and one set of keys
Create the agent credential with a scope of one environment and a name prefix such as STRIPE_, then choose its permissions and a short lifetime.
When you create the agent credential, set its scope to one environment and give it a name prefix such as STRIPE_. The agent can then reach only the entries in that environment whose names start with the prefix. Its permissions and its lifetime narrow it further.
1. Choose the scope
A credential's scope is either one environment or every current and future environment in the organization. Choose one environment, for example website / production.
The organization-wide scope includes environments that do not exist yet, so keep it for agents that really work across all of them. A credential with that scope must name the project and environment for each read, as in --project billing --environment production.
2. Add a name prefix
The name prefix is optional. With the prefix STRIPE_, the agent can reach STRIPE_KEY and cannot reach DATABASE_URL.
A prefix works best when your names are grouped by what they belong to. Entry names look like environment variables, so naming the keys for one provider with one shared prefix gives you a set you can hand to an agent as a unit.
3. Choose the permissions
Permissions are chosen separately. Give the agent only the ones its task needs.
- Read secret values.
- Read secret values only after a person approves each request.
- Use assigned services without ever receiving their credentials.
- Create new entries.
Whatever you choose, an agent can never edit, rotate or delete an existing entry. It cannot see members, manage credentials or approve anything.
4. Choose a lifetime
A credential lasts 1 hour, 4 hours, 7 days or 30 days. Pick the shortest one that covers the work. A credential can also be revoked at any moment.
5. Check the result
The credential is shown once. Sign the agent in and look at what it can discover. Listing does not read any value.
# Paste the credential at the hidden prompt guardry login --profile coding-agent guardry --profile coding-agent whoami # Discover without reading values guardry --profile coding-agent environments list guardry --profile coding-agent secrets list
Then check from the other side. The dashboard shows, for every entry, which agents can reach it and how.
Variables are different
Variables are visible to every agent credential that covers their environment, without approval. A narrow set of permissions does not hide them. Anything sensitive should be a secret.
What this does not do
- A limit on the credential is not a limit on the key. If the agent can read
STRIPE_KEY, it has whatever that key allows at the provider. - An agent that can read a secret can copy it. Guardry controls who gets a value and records every release; it cannot control what a program does with a value afterwards.
- A scope is one environment or the whole organization. There is no scope for a hand-picked list of environments.
Questions
Can one credential cover two environments but not the whole organization?
No. A scope is either one environment or every current and future environment in the organization. For two environments, create one credential for each and sign in under a separate profile for each.
What happens when the credential's lifetime ends?
The credential expires and the agent's requests stop being accepted. The agent cannot manage credentials, so a person creates a new one in the dashboard under Agent access.
Are variables limited in the same way as secrets?
No. Variables are visible to every agent credential that covers their environment, without approval. Store anything sensitive as a secret.
Can an agent widen its own access?
No. An agent cannot manage credentials, see members or approve anything. Only owners and administrators manage agent credentials.