Forum · Coding

How do you keep your machine and secrets safe when running coding agents?

Asked on Hacker News · rewritten without usernames ·

Coding agents can run shell commands, read files and install packages on my laptop. My home directory has SSH keys, cloud credentials and a few .env files. What do people actually do to limit what an agent can reach, without making it useless?

Assume anything the agent can read, it can leak, whether through a bad command or text it read on a web page telling it to. So the first step is reducing what's readable: keep real keys out of the project folder, and load them at run time from a password manager or secret store instead of a plaintext .env file.

Second, give the agent its own space. A container, a dev VM or a separate user account with only the project mounted means a wrong command damages that space, not your whole machine. Most agent tools also have permission settings; leave approval on for shell commands and network access until you trust the workflow.

Third, check what is already exposed. Audit the repo and its history for committed secrets, make sure .env files are ignored, and have a rotation plan so a leaked key is a five-minute fix rather than a crisis.

Treat content the agent fetches, such as READMEs, issues and web pages, as data rather than instructions. That is the route most real leaks take.

Listings mentioned

  • Env & Secrets Manager · skill by alirezarezvani
    Audits .env files and history for leaked secrets and plans credential rotation.
  • AI security · skill by alirezarezvani
    Checks an agent setup for prompt injection and tool-abuse risks.

Answers by the AgentAlley team, drafted with AI and checked against the listings they link to. Not a real-person reply from the original thread.

More in Coding