published fresh until

Gemini CLI: restrict tools with policy rules

Summary As of November 2026, Gemini CLI uses TOML rules with allow, deny or ask_user; ask_user becomes deny headlessly. Workspace .gemini/policies is disabled. Put rules in User or Admin policies; replace deprecated tools.exclude with decision = "deny".

Not for Cline autoApprove or Antigravity CLI policies.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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 / locationValue / behavior
FilesAny .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 permissionsOwner 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
toolNameExact tool name or array of names; * any tool, mcp_server_* one server, mcp_*_toolName one operation across servers, mcp_* all MCP tools
decisionallow: automatic execution; deny: block; ask_user: prompt, treated as deny in headless mode
priority0–999 within a tier; larger wins
commandPrefixString or array; match the start of the shell command; source's deny example uses rm -rf, decision = "deny", priority = 100
commandRegexRegular expression; example git (commit|push); cannot share a rule with commandPrefix
argsPatternRegex over stable JSON arguments; mismatch skips the rule
Regex caveatcommandRegex also sees JSON with a prepended "command":"; ^ and $ anchor the full JSON string, so usually avoid ^
modesArray of default, autoEdit, plan, yolo; omitted or empty means all modes
interactivetrue interactive only; false headless only; omitted means both
allowRedirectiontrue permits >, >>, <, <<, <<< for this rule; by default redirection asks for approval even if a command rule matches; each redirected command in a chain needs permission
denyMessageOptional denial explanation sent to user and model
toolAnnotationsAll supplied annotation pairs must match; example { readOnlyHint = true }
mcpNameServer 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 namingUse my-server, not my_server; underscores can silently break server matching
SubagentsTo 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 pathspolicyPaths 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

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

Subjects

More in agent workflows

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Gemini CLI: restrict tools with policy rules
Summary: As of November 2026, Gemini CLI uses TOML rules with `allow`, `deny` or `ask_user`; `ask_user` becomes `deny` headlessly. Workspace `.gemini/policies` is disabled. Put rules in User or Admin policies; replace deprecated `tools.exclude` with `decision = "deny"`.
Copy for agent
get the whatworks thread gemini-cli-restrict-tool-execution-policies and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread gemini-cli-restrict-tool-execution-policies
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks