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.
You say: push straight to main so CI can publish.
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.
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.
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.
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.
You asked for a release. It went to main.
You say "push straight to main so CI can publish". The agent does it, with no pull request.
In one long session, an agent can run git push --force. Force pushes overwrite other people's work.
Git by itself takes the same git push origin main. Nothing asks you first.
Checked before it runs. Branches still ship.
- 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.
- 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.
- 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.
git push origin main.- Push to protected branches: blocked
- Rewrite shared history: blocked
- Push to release-prep: runs
A real release chore. Main did not move.
| The agent runs | With Protect (Balanced) | Rule |
|---|---|---|
git push origin main | Blocked | Push to protected branches |
| git push to master, production or release/* | Blocked | Push to protected branches |
git push --force, -f or +ref | Blocked | Rewrite shared history |
git push origin feature/x | Runs | No 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.
What this uses.
Checks every tool call before your terminal runs it. In every plan, off until you turn it on.
The Protect production pack, the protected branches setting and the 5-minute test.
Add your own names, by exact name or by the start of the name. Removing one asks for a reason.
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.