docs/cli/trusted-folders.md
The Trusted Folders feature is a security setting that gives you control over which projects can use the full capabilities of Gemini CLI. It prevents potentially malicious code from running by asking you to approve a folder before the CLI loads any project-specific configurations from it.
The Trusted Folders feature is disabled by default. To use it, you must first enable it in your settings.
Add the following to your user settings.json file:
{
"security": {
"folderTrust": {
"enabled": true
}
}
}
Once the feature is enabled, the first time you run Gemini CLI from a folder, a dialog will automatically appear, prompting you to make a choice:
my-project).safe-projects), which automatically trusts all of its subdirectories as
well. This is useful if you keep all your safe projects in one place.Your choice is saved in a central file (~/.gemini/trustedFolders.json), so you
will only be asked once per folder.
Before you make a choice, Gemini CLI performs a discovery phase to scan the folder for potential configurations. This information is displayed in the trust dialog to help you make an informed decision.
The discovery UI lists the following categories of items found in the project:
.toml command definitions that add new functionality.The trust dialog also highlights critical information that requires your attention:
settings.json file), these errors will be
displayed prominently.By reviewing these details, you can ensure that you only grant trust to projects that you know are safe.
When a folder is untrusted, Gemini CLI runs in a restricted "safe mode" to protect you. In this mode, the following features are disabled:
Workspace settings are ignored: The CLI will not load the
.gemini/settings.json file from the project. This prevents the loading of
custom tools and other potentially dangerous configurations.
Environment variables are ignored: The CLI will not load any .env
files from the project.
Extension management is restricted: You cannot install, update, or uninstall extensions.
Tool auto-acceptance is disabled: You will always be prompted before any tool is run, even if you have auto-acceptance enabled globally.
Automatic memory loading is disabled: The CLI will not automatically load files into context from directories specified in local settings.
MCP servers do not connect: The CLI will not attempt to connect to any Model Context Protocol (MCP) servers.
Custom commands are not loaded: The CLI will not load any custom commands from .toml files, including both project-specific and global user commands.
Granting trust to a folder unlocks the full functionality of Gemini CLI for that workspace.
When running Gemini CLI in a headless environment (for example, a CI/CD
pipeline) where interactive prompts are not possible, the trust dialog cannot be
displayed. If the folder is untrusted and the Folder Trust feature is enabled,
the CLI will throw a FatalUntrustedWorkspaceError and exit.
To proceed in these environments, you can bypass the trust check using one of the following methods:
--skip-trust flag.GEMINI_CLI_TRUST_WORKSPACE=true
environment variable.These methods will trust the current workspace for the duration of the session without prompting.
For detailed instructions on managing folder trust within CI/CD workflows, review the Gemini CLI trust guidance for GitHub Actions.
By default, trust settings are saved to ~/.gemini/trustedFolders.json. If you
need to store this file in a different location, you can set the
GEMINI_CLI_TRUSTED_FOLDERS_PATH environment variable to the desired absolute
file path.
If you need to change a decision or see all your settings, you have a couple of options:
Change the current folder's trust: Run the /permissions command from
within the CLI. This will bring up the same interactive dialog, allowing you
to change the trust level for the current folder.
View all trust rules: To see a complete list of all your trusted and
untrusted folder rules, you can inspect the contents of the
~/.gemini/trustedFolders.json file in your home directory.
For advanced users, it's helpful to know the exact order of operations for how trust is determined:
IDE trust signal: If you are using the IDE Integration, the CLI first asks the IDE if the workspace is trusted. The IDE's response takes highest priority.
Local trust file: If the IDE is not connected, the CLI checks the
central ~/.gemini/trustedFolders.json file.