Gemini CLI trusted folders: keep a cloned repo from configuring your agent

A repository can ship settings, MCP servers and an .env that change how your coding agent behaves. Gemini CLI's trusted folders feature ignores all of that until you say the folder is yours. It's off by default.

The short answer

Turn on folder trust in your user settings ("security": { "folderTrust": { "enabled": true } }); it’s disabled by default.1 After that, opening Gemini CLI in a folder you haven’t trusted runs it in a restricted mode: the project’s .gemini/settings.json is ignored, its .env isn’t loaded, its MCP servers don’t connect, its custom commands don’t load, tool auto-acceptance is off, and extensions can’t be installed or changed.1 You decide per folder, and can revisit with /permissions.1

One context note: Gemini CLI’s docs say it was replaced by Antigravity CLI on 18 June 2026 for unpaid-tier and Google One users.1

Every MCP tool call goes through your rules first. Here a delete that doesn’t say which rows is stopped before it reaches the database. These are the rules deedglass init starts with; the call is made up.

Why a repository can be an attack

When you clone a project and start a coding agent in it, the agent reads files that the project’s authors wrote. Some of those files aren’t code; they’re agent configuration:

File in the repo What it could do without folder trust
.gemini/settings.json Change approval behaviour, tools, hooks
MCP server entries Start a local process of the author’s choosing on your machine
.env Set environment variables for the session
Custom command .toml files Add commands that do more than their name says

A pull request that adds an MCP server or loosens auto-approval is a change to your machine’s behaviour the moment you open the branch. That’s the risk folder trust addresses: the agent shouldn’t take configuration from a folder you haven’t vouched for.

What an untrusted folder loses

From the docs:1

Capability Untrusted folder
Workspace settings (.gemini/settings.json) Ignored
Project .env Not loaded
MCP servers Don’t connect
Custom commands from .toml Not loaded
Tool auto-acceptance Disabled: you’re always prompted
Extensions Can’t be installed, updated or uninstalled

The auto-acceptance row means a trusted user setting like auto-approval doesn’t carry into an untrusted folder either. In practice, a repository you’re only reviewing gets a careful agent, not your everyday one.

Turning it on

In ~/.gemini/settings.json:1

Code Data in JSON, the format software uses to pass records and settings.

{
  "security": {
    "folderTrust": {
      "enabled": true
    }
  }
}

Trust decisions are stored in ~/.gemini/trustedFolders.json; GEMINI_CLI_TRUSTED_FOLDERS_PATH moves the file.1 For a team, put the setting in the system overrides file (/etc/gemini-cli/settings.json on Linux, /Library/Application Support/GeminiCli/settings.json on macOS), which has the final say over user and workspace settings.2

The trusted folders file is worth backing up and reviewing occasionally. Every entry is a folder whose configuration your agent will obey.

The three choices, and which to pick

When you open an untrusted folder, the dialog offers:1

  • Trust folder: fully trusts this folder.
  • Trust parent folder: trusts the parent directory and everything under it.
  • Don’t trust: restricted safe mode.

Our rule of thumb:

Situation Choice
Your own project Trust folder
A repository you’re reviewing, or a pull request branch from someone else Don’t trust
A folder of throwaway experiments you created Trust folder, per experiment
~/code or another parent holding many clones Avoid “trust parent”: every future clone inside it inherits trust

“Trust parent folder” is the convenient option that quietly widens over time. A repository you clone next month into a trusted parent gets full trust without a dialog.

Reviewing a repository safely

Opening a stranger’s repository with an agent is a normal part of code review now. A short routine keeps it boring:

  1. Open it untrusted. Choose “Don’t trust” in the dialog.
  2. Read the agent files first. Look at .gemini/, .mcp.json, .claude/, .cursor/, .codex/ and .github/hooks/ before anything else. They tell you what the project wants your agent to do.
  3. Ask the agent questions, not for changes. In restricted mode every tool call prompts anyway; keep it to reading.
  4. Trust only when it’s yours. If you fork it and start working, trust your fork, not the original clone.

CI and headless runs

In headless environments such as CI, there’s no one to answer the dialog. Without a decision, an untrusted folder makes the CLI exit with a FatalUntrustedWorkspaceError. --skip-trust, or GEMINI_CLI_TRUST_WORKSPACE=true, trusts the workspace for that session only.1

That flag is safe when the workspace is your own code at a commit you chose. It’s not safe when CI runs on pull requests from forks: the fork’s .gemini/settings.json and MCP servers become trusted for the run. In that case, run the agent on a checkout that excludes agent configuration, or don’t run it on untrusted branches at all. The same reasoning applies to any CI job that runs untrusted code with credentials, as our Amazon Q extension post shows from AWS’s own bulletins.

The same idea in other agents

Folder trust isn’t unique to Gemini CLI. Codex loads a project’s .codex/ hooks only when the project is trusted3, and in Claude Code a committed .claude/settings.json applies its permissions.allow rules only after each person trusts the folder, while its deny and ask rules apply right away.4 Our hooks across agents post covers where each agent reads project files from. The common lesson: agent configuration in a repository is code, and should be reviewed and trusted like code.

A checklist

  • security.folderTrust.enabled: true in user or system settings.
  • Repositories under review opened with “Don’t trust.”
  • No “trust parent” on folders that collect clones.
  • ~/.gemini/trustedFolders.json reviewed now and then.
  • --skip-trust used only in CI on code you control.
  • Pull requests that add or change agent configuration reviewed like CI changes.
  • A sandbox and deny rules for the folders you do trust; see Gemini CLI yolo mode.

To check a repository’s agent configuration before you trust it, paste its MCP config into the check page or run npx deedglass scan in the folder (how the grade works); the scan Action does the same on pull requests. To try tool-call rules in your browser, open the playground.

Written with AI assistance and checked against our claims register.

The takeaway

Gemini CLI's folder trust is off by default; once on, an untrusted repo's settings, .env, MCP servers and auto-approval are all ignored until you trust it.

Read nextGemini CLI yolo mode: what it auto-approves, and how to make it less dangerous Try it: install in 7 s

Related on this site

More posts

Sources

  1. 1Gemini CLI docs: Trusted folders · geminicli.com · checked 26 October 2026
  2. 2Gemini CLI docs: Enterprise configuration · geminicli.com · checked 26 October 2026
  3. 3Codex docs: Hooks · learn.chatgpt.com · checked 25 October 2026
  4. 4Claude Code docs: Settings files and precedence · code.claude.com · checked 26 October 2026

Published 26 October 2026, sources last checked 26 October 2026. If something here is out of date, write to hello@deedglass.com.

Try it on your own setup

npx deedglass scan

Grades only your own setup. Nothing is uploaded.

Pricing