Check your Gemini CLI policy file
Paste a policy file and your settings.json, and see which rules Gemini CLI really follows: refusals an old “allow for all future sessions” answer outranks, files it skips over one bad rule, patterns it won’t load and settings that let a whole server through. Then copy the files back with the fixes you pick. Nothing leaves this page.
1Paste your Gemini CLI files
Everything runs in this page and nothing you paste is sent anywhere. There is no share link on purpose: settings.json can hold keys, and the checker only ever shows where a key is, never the key.
2What they let through
- 7 risks
- 7 checks
- 2 tips
RiskGemini CLI skips rule 5 (deny (?:curl|wget)+ )
(?:curl|wget)+Gemini CLI compiles patterns as RE2 and skips a rule whose pattern has a group followed by *, +, ? or {n} with one of those inside it, which Gemini CLI refuses as a nested quantifier (the ? of (?: counts). It reports the error once at start-up and carries on, so the rule refuses nothing.
Riskrule 2 (allow git) lets git through
gitThis rule allows git, which covers every subcommand, including the ones that run scripts, publish or delete. Allow the narrow forms you trust and let the rest ask.
RiskA saved "allow for all future sessions" outranks rule 3 (ask_user git push)
priority = 500When you pick "Allow for all future sessions", Gemini CLI saves an allow rule in ~/.gemini/policies/auto-saved.toml at priority 950 of this same tier. The higher priority wins (a tie went to the saved answer when we tried), so one old click runs the command anyway. Put refusals and questions above 950.
RiskA saved "allow for all future sessions" outranks rule 4 (deny rm)
priority = 900When you pick "Allow for all future sessions", Gemini CLI saves an allow rule in ~/.gemini/policies/auto-saved.toml at priority 950 of this same tier. The higher priority wins (a tie went to the saved answer when we tried), so one old click runs the command anyway. Put refusals and questions above 950.
Riskrule 2 (allow git) outranks rule 3 (ask_user git push)
600 ≥ 500Gemini CLI uses the highest-priority rule that matches, and rule 2 matches everything rule 3 does. So it runs unasked what you meant to stop. The most careful rule should rank highest.
RiskEvery tool on github runs unasked
mcpServers.github.trusttrust: true becomes an allow rule for every tool on github, including ones it adds later. Leave it off and allow the tools you trust by name in a policy file.
RiskA key is written into settings.json
mcpServers.github.headers.AuthorizationAnyone who can read settings.json, or a project you share it with, gets this key. Write $NAME instead and keep the value in your shell's environment; the checker never shows the value.
Checkrule 4 (deny rm) misses rm written another way
rmcommandPrefix only matches a command that starts with the word. /bin/rm, FOO=1 rm, "rm" and \rm all run rm and none of them starts with it, so they reach Gemini CLI's defaults (and run with --yolo).
Checkrule 6 (deny sudo) doesn't apply with --yolo
modes = ["default","autoEdit"]A rule with modes only applies in those modes. With --yolo, Gemini CLI runs everything no rule refuses, so this one is gone exactly when it matters most.
Checkrule 6 (deny sudo) misses sudo written another way
sudocommandPrefix only matches a command that starts with the word. /bin/sudo, FOO=1 sudo, "sudo" and \sudo all run sudo and none of them starts with it, so they reach Gemini CLI's defaults (and run with --yolo).
Checkrule 1 (allow git status, git diff, npm test) lets npm test through
npm testThis rule allows npm test, which runs code from the project, which Gemini CLI can change first: it writes the command into a test, script or hook, then this rule runs it unasked. Allow the narrow forms you trust and let the rest ask.
Checkrule 7 (allow mcpName github) lets too much through
This rule lets every tool on github run unasked, including tools it adds later. Allow the narrow forms you trust and let the rest ask.
Checktools.allowed lets run_shell_command(npm run) run unasked
tools.allowed: run_shell_command(npm run)Gemini CLI turns tools.allowed into allow rules at priority 300 of the user tier, so run_shell_command(npm run) runs unasked unless a policy rule above 300 refuses it.
Checktools.allowed refuses every other shell command
tools.allowedA narrowed entry such as run_shell_command(npm run) also adds a rule that refuses every other shell command, at priority 290 of the user tier. So rule 1 in your policy file never gets to allow anything, and any shell allow or ask_user rule below 290 is refused instead.
TipOld one-click answers stay in force
security.disableAlwaysAllowEvery "Allow for all future sessions" click is saved as an allow rule at priority 950. security.disableAlwaysAllow stops Gemini CLI offering it and skips the ones already saved. It skips every other rule at exactly 950 too, refusals included, so move any of yours off 950 first.
Tip--yolo is still available
security.disableYoloModeWith --yolo, Gemini CLI runs every call no rule refuses. security.disableYoloMode makes it refuse to start in that mode.
The files, fixed
policy.toml
Save it over the file you pasted. Gemini CLI reads every .toml file in the folder, so a fixed copy beside the old one keeps the old rules too.
settings.json
Comments in your settings.json are not kept in this copy.
What the checker looks for
It reads the files the way Gemini CLI does, following its policy engine reference and its source, and every finding was run through Gemini CLI 0.70’s own policy engine on 21 November 2026. It sees the files you paste: Gemini CLI also reads every other .toml file in the folder, the admin folder, extensions and the flags you start it with. A clean result is not proof, so check the calls that matter to you with /policies list.
| Option | For example | Why it matters |
|---|---|---|
| Refusals that lose | For exampledecision = "deny", priority = 900 in ~/.gemini/policies | Why it mattersA saved "Allow for all future sessions" answer sits at 950 of the same tier and wins, so one old click runs the command anyway. |
| Rules in the wrong order | For exampleAn allow for git at 600 above an ask_user for git push at 500 | Why it mattersThe highest-priority rule that matches decides, so the allow answers first and git push never asks. |
| A file that never loads | For exampledecision = "block", priority = 1200, an mcpName rule with no toolName | Why it mattersOne rule Gemini CLI can't read makes it skip the whole file, every refusal in it included. |
| Rules that say less than they seem | For examplecommand_prefix = "git status", commandRegex = "(?:rm|unlink)+ " | Why it mattersA misspelt key is dropped without a word, so the rule matches every command; a pattern RE2 refuses is skipped. |
| Gaps | For examplemodes = ["default"] on a deny, commandPrefix = "rm" | Why it mattersGone with --yolo, and /bin/rm, FOO=1 rm or "rm" don't start with rm. |
| settings.json | For exampletools.allowed = ["run_shell_command"], mcpServers.github.trust = true | Why it mattersSettings become allow rules too: every shell command, or every tool on a server, runs unasked. Keys written into the file are named, never shown. |
Keep the questions, lose the waiting
Careful policies ask more often. With the VariantGate hook, each shell command and file change Gemini CLI wants to make waits in your inbox, and you answer from email, Slack, Teams, Discord or your phone, even in a headless run. Free for one person and 100 requests a month, with no card.
Questions
Why does Gemini CLI run a command my deny rule refuses?
Gemini CLI saves each "Allow for all future sessions" answer as an allow rule in ~/.gemini/policies/auto-saved.toml at priority 950, in the same user tier as your own policy files. The highest priority that matches wins, so a deny rule you wrote at 900 loses to an answer you clicked weeks ago, and at exactly 950 the saved answer won when we tried. Put deny and ask_user rules above 950, or turn on security.disableAlwaysAllow.
What makes Gemini CLI skip a whole policy file?
It checks every [[rule]] in a file before loading any of them. One rule with a decision other than allow, deny or ask_user, a priority outside 0 to 999 or not a whole number, a missing priority, or no toolName makes it skip the whole file, refusals included, with one error at start-up. The documentation shows an mcpName rule without toolName; written that way, the file is skipped.
Do policy files in a project's .gemini/policies folder work?
No. Gemini CLI 0.70 switches the workspace tier off in its code, and its documentation says so too: rules in a project's .gemini/policies don't apply. Use ~/.gemini/policies, or the admin folder (owned by root, writable only by root) for everyone on a machine.
Why is my commandRegex rule ignored?
Patterns are compiled as RE2, and Gemini CLI skips a rule whose commandRegex or argsPattern uses a lookahead, a backreference or a \u escape, holds a group followed by *, +, ? or {n} with one of those inside (so (?:rm|unlink)+ is refused because of the ? in (?:), or repeats more than 1,000 times. A skipped deny rule refuses nothing.
Does settings.json change what my policy file does?
Yes. tools.allowed becomes allow rules at priority 300 of the user tier, so a deny below 300 loses to them, and a narrowed entry such as run_shell_command(npm test) also adds a rule at 290 that refuses every other shell command. mcpServers.<name>.trust allows every tool on that server at 200, and mcp.allowed at 100. The checker reads settings.json for these.