Who it is forA developer who lets Claude Code or Codex work in a repo that holds API keys in a .env file and wants the agent blocked from them.
The problemAn agent working in a project can open a .env file and read credentials it does not need for the task.
The outcomeThe agent's attempt to read .env is refused by the guard, the refusal is recorded in the local audit trail, and the agent reports the block instead of working around it.
What you need first
- A machine where you can run a shell and git (the README installs with git clone and ./scripts/shell/install.sh)
- Claude Code or Codex installed as the agent you want to guard
- A new terminal after install, since hooks load only when a session starts
- For the sandbox use case: Linux with bubblewrap (bwrap) installed, since the README says it is required and macOS and Windows refuse
Steps
git clone https://github.com/solongate/agent-security.gitcd agent-security./scripts/shell/install.sh- Open a new terminal, then start Claude Code or Codex in your project.
- Ask the agent to read the .env file, then run
solongate auditto confirm the refusal was logged.
Prompt for your agent
Install the SolonGate guard from https://github.com/solongate/agent-security by running ./scripts/shell/install.sh in a fresh terminal, then start <agent> in <project-path> and ask it to read the .env file. Expected output: the guard refuses the read and the agent reports the refusal. Verify by running `solongate audit` and confirming a deny entry for .env exists in ~/.solongate/local-logs/solongate-audit.jsonl.
Caveat. The guard only covers agents it hooks into (the README names Claude Code, Codex, OpenCode and Antigravity), and hooks apply only to sessions started after install.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for solongate/agent-security and "Stop an AI coding agent from reading your .env secrets"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer