Use case · Protect

My agent can read my .env file. Protect refuses the read.

Your agent asks to cat .env. Protect refuses the call before it runs, so the model gets a refusal, not your keys. The secrets pack covers .env, your credential files and the environment, in the shell and in the agent's own file tools. Limits →

Your agent tries

The agent wants to check your token.

Blocked · never reaches your shellRead environment files

.env and .env.*. Examples and templates are allowed.

⛔ context-mode Protect blocked this command, so it was NOT executed:
Blocked by your team’s policy: Read environment files. .env files hold secrets.
… Tell the user it was blocked and continue with other work.

The model reads this refusal, not your keys.

Not a shell command: the agent's own Read tool.

Blocked · never runsRead environment files

File rules cover the agent's own Read, Edit, Grep and Glob tools too, not only the shell.

A Read call is rewritten into the same refusal.

The same read, inside a substitution.

Blocked · never reaches your shellRead environment files

Protect works out the substitution and reads it as cat .env.

cat $(echo .env)
cat `echo .env`
cat $(echo .e)nv
all read as: cat .env

No file at all: the agent dumps the environment.

Blocked · never reaches your shellDump the environment

env, printenv, export -p, a bare set, /proc/<pid>/environ, and commands that read stored secrets.

Keys outside the repo.

Blocked · never reaches your shellRead credential files

~/.ssh, ~/.aws, ~/.kube, ~/.npmrc, ~/.git-credentials, *.pem, *.key and more.

The template the agent needs to set up the app.

RunsNo rule matches

.env.example, .env.sample and .env.template hold no secrets, so they run.

The problem

One read sends your keys. You do not see it happen.

The agent runs commands without asking

That is why it is fast. A cat .env to "check the token" looks like normal work.

What it reads goes to the model

The file's text becomes a tool result, and the agent sends it to the model with the rest of the conversation.

There is more than one way in

The shell, the agent's own Read tool, a read inside a substitution, or printenv. A check on one tool name misses the rest.

How it works

Checked on the gateway. Refused before it runs.

  1. 01Turn on the secrets pack

    Open Protect in the console and pick Balanced or Locked down. Both include Protect secrets and also turn on Core protections.

  2. 02Protect reads each call

    It reads what the call does, through wrappers such as sudo and sh -c, in the shell and in the agent's file tools.

  3. 03The client runs a refusal instead

    The gateway turns a blocked call into an echo of the refusal. The model reads the rule and why, and the agent carries on with other work.

Your agentAsks to run cat .env to check a token.
→
Context Mode · ProtectChecks the call before the client runs it.
  • Matches "Read environment files"
  • Turns the call into an echo of the refusal
  • Writes the block to the decision log, with no file contents
→
The modelReads the refusal and why. It never reads your keys.
Your agent asks for the read. Protect, in blue, refuses it on the gateway. The file never opens, so nothing from it reaches the model.
Proof

Tested on production. Tried in real sessions.

42of the test cases try to get past the rules, such as cat $(echo .env)
Every runblocked the .env read and never showed the token, on Claude Opus 5.5 and Claude Haiku 4.5

What the secrets pack blocks

RuleBlocksStill runs
Read environment files.env and .env.*.env.example, .env.sample, .env.template
Read credential files~/.ssh, ~/.aws, ~/.kube, ~/.npmrc, ~/.git-credentials, *.pem, *.key and moreOther files in your home folder
Dump the environmentenv, printenv, export -p, a bare set, and commands that read stored secretsenv FOO=1 npm test
Upload filescurl -F, -T, -d @file; wget --post-file; gh gist create and morecurl -d '{}' to an API
Known paste and drop sites19 hosts, such as pastebin.com and webhook.siteOther sites, unless you block them

The live runs are prompt 2 of the Protect docs' 5-minute trial, run on 2026-10-02 and 2026-10-04 in real sessions through the gateway. Limits: without "block other sites", the pack slows a leak and does not stop it. A program that picks its destination at run time, or a script file Protect cannot read, can get past it. Method and sources →

Products used

What this uses.

Protect

Rules for every tool call, checked before your client runs it. In every plan; off until you turn it on.

Protect docs

Every rule in the secrets pack, the refusal text, and the limits.

The test report

How we tried to get past the rules, and the 126 checks.

Plans

Start free. On Team, one policy covers every member, and an agent cannot loosen it.

Related: Secure coding agents · For security teams

Keep your keys out of the model.

npx @context-mode/cli connects your agents. 1,000 requests free, no card.

Get started free

Your coding agent costs less and remembers your project.

Start free: 1,000 requests, every feature, no card. After you sign in, the console gives you one command to connect Claude Code or Codex.

Read the docs