Gemini CLI policies: allow, ask and deny rules in one place
Say what Google’s Gemini CLI may run on its own, what it should ask about and what it must never do. The builder writes a policy file of [[rule]] entries for your toolchain, git, web fetches and MCP servers, and tells you where a rule does less than it seems. No sign-up, and nothing leaves this page.
1Say what Gemini CLI may do
Default: no rule, so Gemini CLI’s own defaults decide. Allow: runs without asking. Ask: asks at the terminal. Never: refused, with a message the model sees.
Run the tests
The test commands of the toolchains picked above. Tests run any code in the project.
Lint, build and type check
Lint, build, type check and format.
Install packages
Needs the network, and a new package runs its own install scripts.
Look at git changes and history
git status, diff, log and show. They only look, but by default Gemini CLI asks.
Commit and switch branches
git add, commit and switch.
Push to the remote
Anything pushed is seen by others and can start a deploy.
Throw away work or history
Force pushes, hard resets and git clean. Spelled another way they slip past; see below.
Delete files with rm
rm and rmdir. With no rule they would run in --yolo mode, so they always get one.
Use curl and wget
curl and wget can send your files anywhere on the network.
Containers, clusters and cloud
docker, kubectl, helm, terraform and the AWS, Google Cloud and Azure command lines.
Database command lines
psql, mysql, sqlite3, mongosh and redis-cli: any query, including DROP.
Run as root with sudo
Anything run with sudo.
Gemini CLI’s own tools
Write and edit files
write_file and replace. By default Gemini CLI asks, and refuses them in a headless run.
Fetch web pages
web_fetch reads any address the model writes, which can carry your data out in the URL.
Search the web
google_web_search. Allowed by default.
Tools from MCP servers
Every tool from every MCP server in settings.json, including ones added later.
2Save the policy file
~/.gemini/policies/variantgate.toml
Download it, then put it in place:
# Where the browser saved it; change the path if yours differs mkdir -p ~/.gemini/policies mv ~/Downloads/variantgate.toml ~/.gemini/policies/variantgate.toml
Runs without asking
- Run the tests
- Lint, build and type check
- Look at git changes and history
- VariantGate's approval tools
Asks at the terminal (refused headless)
- Install packages
- Push to the remote
- Delete files with rm
- Use curl and wget
- Containers, clusters and cloud
- Database command lines
Refused
- Throw away work or history
- Run as root with sudo
No rule: Gemini CLI's defaults
- Commit and switch branches
- Write and edit files
- Fetch web pages
- Search the web
- Tools from MCP servers
- An allowed command that writes to a file (npm test > out.txt) or runs $(…) asks anyway, and in a headless run it is refused. Each part of a chained command is checked on its own: npm test && git push asks if git push asks, and is refused if any part is refused.
- The "written another way" rules also catch sudo wherever it stands as a word, so a command that only mentions it (echo sudo) gets the same answer, even one you allowed, such as a test run or a commit message with sudo in it. That errs on the careful side. Quoting inside the word (r''m), a variable ($X) or another tool (find -delete) still gets past, so treat these rules as a seatbelt, not a lock.
- Rules for commands of more than one word match only how a command starts: git push origin main --force doesn't start with git push --force, and git -C . reset --hard doesn't start with git reset --hard. Protect the main branch on the server, and keep work you can't lose pushed.
- The file lets four tools from an MCP server named variantgate run unasked (request_approval, check_approval, withdraw_request, report_outcome): they only ask a person, and without them a headless run can't ask at all. Give no other server that name.
- Refusals and questions here rank above answers saved with "allow for all future sessions", so Gemini CLI keeps asking about these until you change this file. An old saved answer can't get a refused command through either.
- Asking only works at the terminal. In a headless run (gemini -p, CI) Gemini CLI refuses whatever would ask, including its own defaults for shell commands, edits and web fetches.
- In --yolo mode everything without a rule runs, but these rules still hold: a user policy file ranks above yolo's allow-all. They also rank above tools.allowed and trust: true in settings.json.
- Gemini CLI 0.70 ignores a .gemini/policies folder inside a project, so this file goes in your home folder and covers every project. A person on the machine can change it; for rules they can't, pick the admin folder.
Gemini CLI reads every .toml file in the folder, so this one sits beside your own. Run /policies list inside Gemini CLI to see the rules it loaded.
How Gemini CLI decides what runs
Every tool call goes through the policy engine before it runs. The engine looks at every rule that matches the call and takes the one with the highest priority: the folder a rule comes from sets its tier, and the priority in the file orders rules inside it. The details are in Gemini CLI’s policy engine reference. We loaded every rule this builder writes into the engine of Gemini CLI 0.70 and checked its answers at the desk, in YOLO mode and headless (21 November 2026).
| Option | Tier | Folder | What to know |
|---|---|---|---|
| Admin | Tier5 | Folder/etc/gemini-cli/policies, or /Library/Application Support/GeminiCli/policies on macOS | What to knowRanks above everything. Ignored unless root owns the folder and nobody else can write to it. |
| User | Tier4 | Folder~/.gemini/policies | What to knowYours, for every project. Also where tools.allowed and trust: true land (300 and below), and answers saved with "allow for all future sessions" (950). |
| Workspace | Tier3 | Folder.gemini/policies | What to knowInside a project. Disabled in Gemini CLI 0.70, so a file here does nothing. |
| Default | Tier1 | FolderBuilt in | What to knowReading allowed; shell, edits and web fetches ask, and are refused headless. YOLO's allow-all lives here. |
What a policy file can’t do
It matches how a command starts
commandPrefix = "rm"refusesrm -rf buildbut not/bin/rm -rf buildorFOO=1 rm, which in YOLO mode run. The builder adds a second rule for those, and still nothing stopsfind . -delete.Allow is narrower than it looks
An allowed
npm teststill asks when it writes to a file or runs$(…), and build files still ask with edits allowed. That is Gemini CLI being careful, but in a headless run it means refused.Asking only works while you watch
ask_userwaits at the terminal. Withgemini -pnobody is there, and Gemini CLI refuses it. Sending the call to your phone keeps an unattended run moving without allowing more.
Answer from anywhere
Tick the phone box above and each shell command and file change your policy lets through waits in your VariantGate inbox, at the desk or in a headless run: yes or no from email, Slack, Teams, Discord or a phone notification, with every answer kept on the record. Free for one person and 100 requests a month, with no card.
Questions
Which rule wins when several match?
The matching rule with the highest priority. Gemini CLI turns a rule's priority (0 to 999) into tier + priority / 1000, and the tiers are default 1, extension 2, workspace 3, user 4 and admin 5. So any rule in ~/.gemini/policies beats every built-in rule, and an admin rule beats every user rule. This builder gives refusals 990, questions 970 and allows 500, so the most careful rule decides where two match. Two allows sit above them on purpose: VariantGate's own approval tools at 995, which only ask a person, and an optional allow at 980 for MCP tools that say they only read.
Can I keep the policy in my project's .gemini folder?
Not in Gemini CLI 0.70. Its documentation says the workspace tier is disabled (issue 18186), so a policies folder inside the repository does nothing. Put the file in ~/.gemini/policies for yourself, or in the admin folder for every user on the machine.
Do my rules still hold in --yolo mode?
Yes. YOLO mode adds a built-in rule that allows every tool, but it sits in the default tier, so a user rule that asks or refuses still ranks above it. What YOLO changes is everything without a rule of yours: that runs. It also stops Gemini CLI's own checks from asking about commands it thinks are dangerous.
What happens to ask_user in a headless run?
In a headless run (gemini -p, or CI) nobody can answer, so Gemini CLI treats ask_user as deny, and its own defaults refuse shell commands, file edits and web fetches. Allow what the run needs, refuse the rest, or keep the VariantGate hook on so a person answers from their phone.
Why does an allowed command still ask?
Gemini CLI asks anyway when an allowed command writes to a file (>, >>), runs a command substitution such as $(…), or runs outside the project folder. Each part of a chained command (&&, ;, |) is checked on its own, and one refused part refuses the whole command. Edits to build files such as package.json, lock files, Makefile or Dockerfile also ask, above every policy file.
Is there a priority I should not use?
Avoid 950, and put anything that must hold above it. Gemini CLI saves your "allow for all future sessions" answers in ~/.gemini/policies/auto-saved.toml at priority 950, so a deny at 900 loses to an old "always allow" for the same command. And when disableAlwaysAllow is on, Gemini CLI skips every rule at 950, even a deny rule you wrote. We saw both in the engine.