You open an unfamiliar cloned repository in Gemini CLI 0.62.0 and choose Don't trust - what does safe mode switch off, and what still works?
answer
- the dialog lists what the repo brings
- decision saved per folder
- workspace settings and .env skipped
- no MCP servers, no custom commands
- approval mode forced back to default
basics
~20 sSafe mode ignores the repository's .gemini/settings.json and .env, connects no MCP servers, loads no custom commands, blocks extension installs and forces the default approval mode, so edits and commands ask. The agent can still read code.
solid answer
~40 sFolder trust is on by default at 0.62.0 (`security.folderTrust.enabled`), so the first run in a new folder shows a dialog listing what the repository would bring: custom commands, MCP servers, hooks, skills and setting overrides, with warnings for things like auto-approved tools. Choosing **Don't trust** records the folder in `~/.gemini/trustedFolders.json` and runs it in safe mode: the project's `.gemini/settings.json` and `.env` are ignored, MCP servers do not connect, custom `.toml` commands are not loaded, extensions cannot be installed, updated or uninstalled, and tool auto-acceptance is off - the approval mode is forced back to `default` even if you passed `--approval-mode=yolo`. Your user settings still apply and the agent can still read files and answer questions. `/permissions trust` changes the decision later.
go deeper
Know that Gemini CLI asks whether to trust a new folder and that Don't trust stops the repository's settings, MCP servers and commands loading.
List what safe mode disables, where decisions are stored, and how /permissions trust changes one.
Explain why --approval-mode=yolo still prompts in an untrusted clone, why trust is not isolation, and how headless runs need --skip-trust deliberately.
Set a team habit for unfamiliar repositories: never trust parent folders broadly, read the discovery list, pair trust with a sandbox for code you did not write.
## Why Gemini CLI asks about folders A repository can carry more than code for Gemini CLI. A project `.gemini/` directory can hold a `settings.json` that adds MCP servers, pre-approves tools or switches the sandbox off, a `.env` with environment variables, custom slash commands as `.toml` files, hooks and skills. Loading those from a stranger's repository would let the repository configure your agent: a committed settings file could, for example, register an MCP server whose `command` runs a script from the repository, or pre-approve `run_shell_command` through `tools.allowed` so commands stop asking. **Trusted folders** is the gate in front of that configuration. At 0.62.0 the setting `security.folderTrust.enabled` defaults to `true` in the settings schema and the source, so the gate is active out of the box. The trusted-folders page still says the feature is disabled by default and shows how to enable it; the release's own schema is the one that runs. ## The trust dialog and the discovery phase The first time you start the CLI in a folder it has no decision for, it runs a **discovery phase** and shows what it found: - **Commands** - custom `.toml` command definitions. - **MCP Servers** - servers the CLI would try to connect to. - **Hooks** - hooks that can intercept CLI behaviour. - **Skills** - local agent skills. - **Setting overrides** - project settings that would override yours. It also raises **security warnings** for dangerous settings, such as auto-approving tools or disabling the sandbox, and **discovery errors** such as a malformed `settings.json`. You then pick **Trust folder**, **Trust parent folder** (which trusts every sub-directory too) or **Don't trust**. The list is the useful part: an MCP server, a hook or a setting that disables the sandbox in a repository you did not write is the reason the dialog exists, and it is cheaper to read it now than to audit what ran later. The choice is stored in `~/.gemini/trustedFolders.json` (relocatable with `GEMINI_CLI_TRUSTED_FOLDERS_PATH`), so you are asked once per folder. When the CLI is connected to an IDE, the IDE's trust signal is consulted first. ## What safe mode switches off | Area | In an untrusted folder | |---|---| | Project `.gemini/settings.json` | Not loaded | | Project `.env` files | Not loaded | | MCP servers | Not connected | | Custom `.toml` commands | Not loaded, project and user ones alike | | Extensions | Cannot be installed, updated or uninstalled | | Tool auto-acceptance | Off: the approval mode is forced to `default`, so edits and commands ask | | Memory loading from directories named in local settings | Off | The tool auto-acceptance row has a concrete form in the source: if the folder is not trusted and the requested approval mode is anything other than `default`, the CLI logs "Approval mode overridden to \"default\" because the current folder is not trusted" and runs in `default`. Launching with `--approval-mode=yolo` or `auto_edit` in a folder you refused therefore still prompts for every edit and command. ## What still works - The agent itself: it can read and search the code with the read-only tools and answer questions about it. - Your **user** settings in `~/.gemini/settings.json` and any system settings; safe mode targets the workspace's configuration, not yours. - Edits and shell commands, one confirmation at a time. - `/permissions trust` to change the decision for this or another directory once you have read the repository. Trust is **not isolation**. A shell command you approve in an untrusted folder runs with your user's permissions; containing it is the job of `-s` / `--sandbox`. Folder trust decides what the repository may configure; the sandbox decides what an approved command can touch. ## Headless runs and CI A run with `-p` cannot show the dialog, so it is not trusted unless you say so with `--skip-trust` or `GEMINI_CLI_TRUST_WORKSPACE=true`, each of which trusts the current workspace for that session only. The trusted-folders page documents such a run exiting with `FatalUntrustedWorkspaceError`; either way, an unattended run against a pull request from outside the team should not be given `--skip-trust`. ## Habits worth having 1. Read the discovery list before choosing: an MCP server or a setting that disables the sandbox in a repository you did not write is the warning sign. 2. Prefer **Trust folder** over **Trust parent folder** unless every project under that parent is yours. 3. Review `~/.gemini/trustedFolders.json` from time to time; it is the complete list of what you have vouched for.
- You trusted a parent folder last month and now clone a stranger's repository under it. What happens?Trust parent folder trusts every sub-directory, so the new clone is trusted without a dialog: its `.gemini/settings.json`, `.env`, MCP servers and commands load. Mark that clone untrusted with `/permissions trust`, or check `~/.gemini/trustedFolders.json` and narrow the rule to specific folders.
- Does Don't trust stop the agent running a destructive command?Not by itself. Safe mode keeps the approval mode at `default`, so no edit or command runs without your confirmation, but a command you approve runs with your permissions. Containing what an approved command can reach is the sandbox's job, started with `-s` or `GEMINI_SANDBOX`.
Safe mode is a hotel desk holding a new guest's bags until someone vouches for them: you can talk to the guest, but nothing they brought - keys, appliances, notes to staff - is used, and nobody waves their requests through unchecked, whatever they ask for.
- Folder trust is off unless you enable it, so a fresh install loads everything.
- An untrusted folder blocks the agent from reading any files.
- Passing --approval-mode=yolo overrides an untrusted folder's restrictions.
- Safe mode also ignores your own ~/.gemini/settings.json.
- Trusting a folder sandboxes the commands the agent runs there.
- Trust decisions are stored in the project's .gemini directory.
Assumes Gemini CLI 0.62.0, where security.folderTrust.enabled defaults to true in the schema and an untrusted folder forces the approval mode back to default; the trusted-folders page still describes the feature as off by default.