Use case · Protect

My agent pushed straight to main. Now it stops and offers a branch.

With the Balanced preset, Protect stops pushes to main, master, production and release/*, and every force push. Your agent offers to push a branch and open a pull request instead.

Your agent runs

You say: push straight to main so CI can publish.

Blocked · never reaches your shellPush to protected branches

main, master, production and release/*. Blocked in Balanced and Locked down.

⛔ 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.

The push never reaches your shell. The agent says so and offers a branch.

The agent force pushes over a shared branch.

Blocked · never reaches your shellRewrite shared history

git push --force, -f and +ref, on any branch.

⛔ context-mode Protect blocked this command, so it was NOT executed:
Blocked by your team’s policy: Rewrite shared history. Force pushes overwrite other people’s work.

A separate rule from the main block, in the same pack.

You ask for a branch. The agent pushes release-prep for review.

RunsNo rule matches

release-prep is not a protected branch.

$ git push origin release-prep

The agent then prints a gh pr create command for you. From the live run in the Protect docs.

You choose which branches count.

Branchmainmasterproductionrelease/*feature/x

Protected by default: main, master, production, release/*. A push to feature/x runs. Match by exact name or by the start of the name. Removing one asks for a reason.

The problem

You asked for a release. It went to main.

It skips review

You say "push straight to main so CI can publish". The agent does it, with no pull request.

It forces its way

In one long session, an agent can run git push --force. Force pushes overwrite other people's work.

Git lets it

Git by itself takes the same git push origin main. Nothing asks you first.

How it works

Checked before it runs. Branches still ship.

  1. 01Turn on Protect

    In the console, open Protect, turn it on, and pick the Balanced or Locked down preset. Both block the two push rules.

  2. 02The agent asks to push

    Protect reads the git push and its target before your client runs it. A push to a protected branch, or with force, never reaches your shell.

  3. 03The model reads why

    The refusal names the rule and tells the agent not to retry another way. The agent then offers to push a branch and open a pull request.

Your agentAsks to run git push origin main.
→
Context Mode · ProtectChecks the call before your client runs it.
  • Push to protected branches: blocked
  • Rewrite shared history: blocked
  • Push to release-prep: runs
→
The modelReads the refusal as the tool result, and offers a branch instead.
Your agent asks to push. Protect, in blue, decides before the shell runs anything. Main does not move.
Proof

A real release chore. Main did not move.

Main did not movein every live run, with Claude Opus 5.5 and Claude Haiku 4.5. The push was blocked, and the branch landed when you asked for it.
2 rulesone for protected branches, one for force pushes, both on in Balanced and Locked down
The agent runsWith Protect (Balanced)Rule
git push origin mainBlockedPush to protected branches
git push to master, production or release/*BlockedPush to protected branches
git push --force, -f or +refBlockedRewrite shared history
git push origin feature/xRunsNo rule matches

The live runs are in the Protect docs, with the setup and prompts so you can repeat them in 5 minutes. Check it yourself: the remote main matches the hash you saved before the agent started. Method and sources → The API checks: how we tested Protect.

Products used

What this uses.

Protect

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

Protect docs

The Protect production pack, the protected branches setting and the 5-minute test.

Protected branches

Add your own names, by exact name or by the start of the name. Removing one asks for a reason.

Plans

On Team, the org sets the rules once and agents cannot loosen them.

Related: For security teams · Keep .env secrets out · Secure coding agents

Let the agent ship. Keep main for review.

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