Solution

What stops an agent with your terminal? Rules checked before each call runs.

Protect checks each tool call before your terminal runs it. With the rules you pick, a .env read, a push to main or rm -rf ~ never runs, and the model is told why.

Today it enforces Claude Code and Codex. Other agents are recorded, not enforced.

Pick a call

cat .env: your agent wants to read your keys.

Blocked · never reaches your shellRead environment files

.env and .env.*. Examples and templates are allowed. A hidden read such as cat $(echo .env) is read the same way.

context-mode Protect blocked this command, so it was NOT executed:
Blocked by your team's policy: Read environment files. .env files hold secrets.

Your agent tells you it was blocked and carries on with other work.

git push origin main: your agent wants to ship with no review.

Blocked · never reaches your shellPush to protected branches

main, master, production and names that start with release/.

context-mode Protect blocked this command, so it was NOT executed:
Blocked by your team's policy: Push to protected branches. Protected branches change through reviewed pull requests.

Your agent tells you it was blocked and carries on with other work.

sudo sh -c 'rm -rf ~': a bad guess about a path, inside two wrappers.

Blocked · never reaches your shellCore protection: delete the root or home folder

Read through wrappers such as sudo and sh -c.

context-mode Protect blocked this command, so it was NOT executed:
Blocked by your team's policy: Delete the root or home folder.

Your agent tells you it was blocked and carries on with other work.

npm test: ordinary work.

RunsNo rule matches

Nothing is blocked until you choose rules. Then only calls that match your rules are blocked.

The problem

An agent with a shell works fast. One bad call is enough.

Your secrets

It reads a .env file and sends your keys to the model.

Your main branch

It force-pushes to main, with no review.

Your home folder

It runs rm -rf ~ after a bad guess about a path.

A check on one tool name misses calls. The same rm -rf ~ can come wrapped in sudo or sh -c, or through a tool with another name.

How it works

Checked on the way back from the model. Before your shell sees it.

Your agent sends each request through Context Mode to the model. When the model asks for a tool call, Protect checks it in Context Mode. An allowed call goes back to your agent and runs. A blocked call goes back as a refusal. Your agent and your terminal Context Mode gateway Model API your own account request Protect reads what it does asks for a call runs, or a refusal
Protect sits in the gateway. It checks the call the model asks for before your agent runs it. A blocked call comes back as a short refusal.
  1. 01The model asks for a call

    A shell command, a file read or write, a web fetch or a tool-server call.

  2. 02Protect reads what it does

    Through wrappers such as sudo and sh -c, across 22 capabilities.

  3. 03It runs, or it never reaches your shell

    A blocked call becomes a refusal. The model reads why and carries on.

Rules decide on the gateway, outside the model. The model cannot change them; it only reads the refusal. A rule is a list of conditions you can read and test, with no wildcards. Protect is off until you turn it on, and nothing is blocked until you pick a preset or add rules.

Proof

Tested on production. 42 of 103 cases try to get past it.

126 of 126Protect API checks pass on production
42 of 103test cases try to sneak past the rules
32 to 556 µsto decide one call, inside the gateway
TestResult
API checks, production126 pass, 0 fail
Claude Code (Haiku 4.5), live25 pass, 0 fail, 1 skip
Codex, live22 pass, 0 fail, 1 skip
Refused calls with a side effectNone

Five throwaway accounts in production, no customer traffic. What it does not catch: a script file, a compiled program or a path built at run time. Keep your agent's sandbox on too. Method and results →

For a team

One policy for every agent. Set once by the org.

On Team, the org sets the rules and agents cannot loosen them. For audit, the decision log and policy changes, see Protect for security teams.

Products used

What this uses.

Protect

Checks every tool call before it runs. In every plan, off until you turn it on.

Protect docs

Every rule type, the presets, the packs and the limits.

Related: Block .env reads, Protect your main branch, Block commands you cannot undo, For security teams.

Let the agent work. Keep the keys.

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

For a team: sales@context-mode.com

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