← All posts

Gemini CLI Permissions and Tool Approval Setup

Learn how to optimize your Gemini CLI workflow by configuring granular tool approvals and safety policies while protecting against dangerous commands.

To configure Gemini CLI to bypass confirmations for safe commands while remaining protected against dangerous ones, you should use the Policy Engine and adjust your Approval Settings.

This guide walks you through setting up a frictionless yet secure development environment.

1. Enable Global Automatic Approvals

First, set the CLI to automatically approve non-destructive actions by default. Run the following command in the CLI:

bash
/settings set general.defaultApprovalMode auto_edit
  • auto_edit: Automatically approves file reads/writes but still prompts for shell commands.
  • yolo: If you want to skip all prompts (not recommended), you can start the CLI with the --yolo or -y flag.

2. Create a “Safe” Policy for Common Commands

To allow specific shell commands (like git or ls) to run without prompts, create a policy file.

  1. Navigate to (or create) ~/.gemini/policies/.
  2. Create a file named safe-commands.toml:
toml
# Allow all git commands automatically
[[rule]]
toolName = "run_shell_command"
commandPrefix = "git "
decision = "allow"
priority = 100

# Allow listing files
[[rule]]
toolName = "run_shell_command"
commandPrefix = "ls"
decision = "allow"
priority = 100

3. Explicitly Block Dangerous Commands

In the same policy file, you can ensure dangerous commands always prompt you by setting their priority higher than your “allow” rules:

toml
# Always ask before deleting anything
[[rule]]
toolName = "run_shell_command"
commandPrefix = "rm "
decision = "ask_user"
priority = 999

# Always ask before force-pushing
[[rule]]
toolName = "run_shell_command"
commandPrefix = "git push --force"
decision = "ask_user"
priority = 999

4. Enable Permanent Approvals

To “whitelist” tools as you use them, enable permanent approvals in /settings:

bash
/settings set security.enablePermanentToolApproval true

Once enabled, whenever a tool prompts you, you can select “Allow for all future sessions” to automatically generate a rule for that specific tool or command.

5. Trust Your Workspace

If the CLI keeps prompting you despite these settings, the folder may not be “Trusted.” Run this command in your project root:

bash
/permissions trust

This moves the folder out of “Safe Mode” (where everything is prompted) into your custom global configuration.

Written by Mac Poncardas, a freelance web designer and developer helping small businesses get more clients from their websites.

More writing

Does your site pass the test?

Send me the link. I'll tell you what I'd change first, free.