Working safely with agents
Agents run commands on your machine. A few habits keep that boring.
Before you start
- Work inside a Git repository and commit before a big request. A bad result is then one
git checkout .away. - Leave the sandbox and approvals on. Claude Code asks before running commands unless you allow them; Codex follows its
sandbox_modeandapproval_policy. - Don't run agents with full access on your everyday machine.
Secrets
- Never paste API keys, passwords or tokens into a prompt or a rules file. Rules files are usually committed and shared.
- Keep secrets in
.envfiles listed in.gitignore, and tell the agent in your rules not to read or print them. - If a secret ends up in a commit, change the secret. Deleting the commit doesn't make it private again.
Prompt injection
Text the agent reads can contain instructions: a web page, an issue comment, a file in a dependency. A well-built agent treats that text as data, but stay alert. If an agent suddenly wants to send data somewhere or install something you didn't ask for, stop it and look at what it read.
Review
Read the diff before you keep it, especially in tests (an agent can "fix" a failing test by weakening it), configuration and anything security-related.