r/ChatGPTCoding • u/radim11 • 24d ago
Discussion How do you organize secrets and credentials when building with agents?
I am quite curious how people handle this. Are you using .env files, 1Password, a secrets manager, or something else like internal tooling?
How do you group things: by project, dev/staging/prod, service? Does your coding agents use the same credentials as your apps, or do you give it separate ones?
Could you share and example of your structure with fake names, and hear what’s annoying about your current setup and which setup should I ideally use. I'm not really sure what is the best approach.
14
Upvotes
4
u/FulcraDynamics 24d ago
I'd give agents separate credentials with only the permissions they actually need. Sharing production credentials with a coding agent seems like an unnecessary risk, especially if it can execute commands.
3
u/Humaux 23d ago
I stopped sharing one .env file across agents after about 2 weeks of debugging a leak.
Your idea of giving each agent its own OS user and letting it read only from /run/secrets is the part I wish I had copied earlier. I once let a test agent share the same vault as a prod agent, and it picked up a production key during a routine run. I spent about 3 hours rotating that key and checking what it had touched, and most of that time was panic, not work.
My rule now is simple:
The rough edge is real: that one rotation cost about 3 hours, and a shared .env file is not convenient, it is reckless when one agent mistake can expose everything.
Do you think a proxy that never shows the real key to the agent is worth the extra setup, or does it just move the same risk somewhere else?
2
u/Difficult_Duty2198 23d ago
what helped me was keeping a .env.example with fake values committed and the real .env in gitignore, then only letting the agent see the example. super low effort and i haven't mixed anything up since
1
u/Tritonwolf 24d ago
AWS secrets manager.
1
u/holyknight00 21d ago
i started using 1Password, as I already use it for everything, but it has been surprisingly frustrating. i get 200 million 1pasword unlock prompts even if allow everything which is not good. Hopefully they get a better "agent ready" solution fast.
3
u/Both_Kaleidoscope711 23d ago
Here is how I handle my setup as it relates to secrets.
I have Azure Key Vaults broken out by application and environment. All secret keys are the same across environments.
app-dev-kv, app-test-kv, app-stage-kv, app-prod-kv
Then I manage the secrets using KickCatch Secrets Manager.
Then may applications are hooked directly into the key vaults so none of the secrets are exposed in configuration or local files. My coding agents never need to know the secrets because they just execute the application which has hooks into the key vault. You should never be providing secrets to coding agents.
2
u/ASIREXLABS 23d ago
Separate credentials for the agent is the right base. The next step that helped us most was keeping secrets out of the agent's context entirely.
.envat all. In Claude Code you can add deny rules likeRead(./.env)andRead(./.env.*). The agent only needs to know the variable names, not the values.op://dev/app/DATABASE_URL, andop run --env-file=.env -- npm startinjects the real values only into that process. The file is safe to commit and harmless if an agent prints it.Structure-wise, environment first, then consumer, as others said:
staging/agent/...separate fromstaging/app/....1
u/jek39 23d ago
no different than every other CLI tool - typically envars
1
u/Odd_Antelope9098 23d ago
I've been meaning to start using Infisical for a while now, anyone have thoughts?