What this thread does
Do first: Create a .toml rule in a User or Admin policy location. Project-relative .gemini/policies is documented as disabled.
Short answer
The highest-priority matching active rule decides the call. Use decision = "deny" to exclude a tool; this replaces deprecated tools.exclude in settings.json. A rule without argsPattern can exclude the denied tool from the model's available tools.
What to do
Use the documented shell-approval example in a loaded policy file:
[[rule]]
toolName = "run_shell_command"
commandPrefix = "git"
decision = "ask_user"
priority = 100
| Field / location | Value / behavior |
|---|---|
| Files | Any .toml filename; files in the User policy directory are combined |
| Linux Admin directory | /etc/gemini-cli/policies |
| macOS Admin directory | /Library/Application Support/GeminiCli/policies |
| Admin directory permissions | Owner root (UID 0), no group/other writes; chmod 755 is the source example; failed checks cause policies to be ignored |
| Supplemental Admin locations | --admin-policy or adminPolicyPaths in system settings; ignored if the standard system location contains any .toml policies; supplemental paths skip those ownership checks |
toolName | Exact tool name or array of names; * any tool, mcp_server_* one server, mcp_*_toolName one operation across servers, mcp_* all MCP tools |
decision | allow: automatic execution; deny: block; ask_user: prompt, treated as deny in headless mode |
priority | 0–999 within a tier; larger wins |
commandPrefix | String or array; match the start of the shell command; source's deny example uses rm -rf, decision = "deny", priority = 100 |
commandRegex | Regular expression; example git (commit|push); cannot share a rule with commandPrefix |
argsPattern | Regex over stable JSON arguments; mismatch skips the rule |
| Regex caveat | commandRegex also sees JSON with a prepended "command":"; ^ and $ anchor the full JSON string, so usually avoid ^ |
modes | Array of default, autoEdit, plan, yolo; omitted or empty means all modes |
interactive | true interactive only; false headless only; omitted means both |
allowRedirection | true permits >, >>, <, <<, <<< for this rule; by default redirection asks for approval even if a command rule matches; each redirected command in a chain needs permission |
denyMessage | Optional denial explanation sent to user and model |
toolAnnotations | All supplied annotation pairs must match; example { readOnlyHint = true } |
mcpName | Server name; combine with a simple toolName such as search, not mcp_server_search; omit toolName for all tools on that server; mcpName = "*" spans all servers |
| MCP naming | Use my-server, not my_server; underscores can silently break server matching |
| Subagents | To block an invoked agent, use its name as toolName, e.g. codebase_investigator; invoke_agent uses agent_name as an alias. Use subagent to restrict rules by caller instead |
| Extra paths | policyPaths and adminPolicyPaths: arrays of policy files/directories, default [], restart required |
All rule conditions must match. Default policies generally allow read_file and glob, but write_file and run_shell_command default to ask_user. Delegation defaults to ask_user; local subagent actions are individually checked without that delegation prompt.
Approval modes: default prompts for most writes; autoEdit permits some writes; plan is read-only; yolo has a high-priority allow-all rule. Persistent approvals include the current and more permissive modes in order plan < default < autoEdit < yolo.
Limits and open questions
The policy page's tier table gives Default 1, Extension 2, disabled Workspace 3, User 4, Admin 5, with final_priority = tier_base + (toml_priority / 1000). Its worked examples and Admin prose still use older bases (Workspace 2, User 3, Admin 4). Treat the numeric cross-tier examples as inconsistent; the page states Admin overrides User and User overrides Default. No runtime version or tie-breaking rule is specified.
The schema calls the denial-message field denyMessage, while its subagent example uses deny_message; the page does not resolve that spelling difference.
Not for: Cline autoApprove or Antigravity CLI policies.
Sources
- Gemini CLI policy engine, google-gemini.
- Gemini CLI configuration: policy path settings, google-gemini.
Checked
2026-11-16; read Policy engine and the policyPaths/adminPolicyPaths sections of Configuration; no command was run.
Started from a post by @Gemini CLI documentation team, packaged by the editor. Original post