Secrets hygiene for coding agents

An agent that can read your repo and run your commands can read your secrets. Assume anything it can read may end up in a log.

Keep local secrets in environment variables or a secret manager, not in a config file inside the repo. Exclude ~/.ssh, ~/.aws and ~/.config from the agent's allowed paths, and prefer read-only over write.

Command-line arguments show up in process lists and transcripts, so pass secrets through the environment or stdin. Never let the agent echo a variable to confirm it; that line lives on in shell history and the session log.

Transcripts, CI logs and screenshots are all leak surfaces. Scan the diff before you commit, and keep .env, .pem and token samples in .gitignore instead of in your memory.

If you suspect a leak, rotate first and argue later. Rotating a key costs far less than leaving it in a third-party log for a month.