Note on Configuration Format, 9/17/25: The format of the
settings.jsonfile has been updated to a new, more organized structure.
- The new format will be supported in the stable release starting [09/10/25].
- Automatic migration from the old format to the new format will begin on [09/17/25].
For details on the previous format, please see the v1 Configuration documentation.
Gemini CLI offers several ways to configure its behavior, including environment variables, command-line arguments, and settings files. This document outlines the different configuration methods and available settings.
Configuration is applied in the following order of precedence (lower numbers are overridden by higher numbers):
.env files.Gemini CLI uses JSON settings files for persistent configuration. There are four locations for these files:
/etc/gemini-cli/system-defaults.json (Linux), C:\ProgramData\gemini-cli\system-defaults.json (Windows) or /Library/Application Support/GeminiCli/system-defaults.json (macOS). The path can be overridden using the GEMINI_CLI_SYSTEM_DEFAULTS_PATH environment variable.~/.gemini/settings.json (where ~ is your home directory)..gemini/settings.json within your project’s root directory./etc/gemini-cli/settings.json (Linux), C:\ProgramData\gemini-cli\settings.json (Windows) or /Library/Application Support/GeminiCli/settings.json (macOS). The path can be overridden using the GEMINI_CLI_SYSTEM_SETTINGS_PATH environment variable.Note on environment variables in settings: String values within your settings.json files can reference environment variables using either $VAR_NAME or ${VAR_NAME} syntax. These variables will be automatically resolved when the settings are loaded. For example, if you have an environment variable MY_API_TOKEN, you could use it in settings.json like this: "apiKey": "$MY_API_TOKEN".
Note for Enterprise Users: For guidance on deploying and managing Gemini CLI in a corporate environment, please see the Enterprise Configuration documentation.
.gemini directory in your projectIn addition to a project settings file, a project’s .gemini directory can contain other project-specific files related to Gemini CLI’s operation, such as:
.gemini/sandbox-macos-custom.sb, .gemini/sandbox.Dockerfile).settings.jsonSettings are organized into categories. All settings should be placed within their corresponding top-level category object in your settings.json file.
generalgeneral.preferredEditor (string):
undefinedgeneral.vimMode (boolean):
falsegeneral.disableAutoUpdate (boolean):
falsegeneral.disableUpdateNag (boolean):
falsegeneral.checkpointing.enabled (boolean):
falseoutputoutput.format (string):
"text""text", "json"uiui.theme (string):
undefinedui.customThemes (object):
{}ui.hideWindowTitle (boolean):
falseui.hideTips (boolean):
falseui.hideBanner (boolean):
falseui.hideFooter (boolean):
falseui.showMemoryUsage (boolean):
falseui.showLineNumbers (boolean):
falseui.showCitations (boolean):
trueui.accessibility.disableLoadingPhrases (boolean):
falseui.customWittyPhrases (array of strings):
[]ideide.enabled (boolean):
falseide.hasSeenNudge (boolean):
falseprivacyprivacy.usageStatisticsEnabled (boolean):
truemodelmodel.name (string):
undefinedmodel.maxSessionTurns (number):
-1model.summarizeToolOutput (object):
tokenBudget setting. Note: Currently only the run_shell_command tool is supported. For example {"run_shell_command": {"tokenBudget": 2000}}undefinedmodel.chatCompression.contextPercentageThreshold (number):
/compress command. For example, a value of 0.6 will trigger compression when the chat history exceeds 60% of the token limit.0.7model.skipNextSpeakerCheck (boolean):
falsecontextcontext.fileName (string or array of strings):
undefinedcontext.importFormat (string):
undefinedcontext.discoveryMaxDirs (number):
200context.includeDirectories (array):
[]context.loadFromIncludeDirectories (boolean):
/memory refresh command. If set to true, GEMINI.md files should be loaded from all directories that are added. If set to false, GEMINI.md should only be loaded from the current directory.falsecontext.fileFiltering.respectGitIgnore (boolean):
truecontext.fileFiltering.respectGeminiIgnore (boolean):
truecontext.fileFiltering.enableRecursiveFileSearch (boolean):
@ prefixes in the prompt.truetoolstools.sandbox (boolean or string):
undefinedtools.shell.enableInteractiveShell (boolean):
Use node-pty for an interactive shell experience. Fallback to child_process still applies. Defaults to false.
tools.core (array of strings):
tools.allowed.undefinedtools.exclude (array of strings):
undefinedtools.allowed (array of strings):
["run_shell_command(git)", "run_shell_command(npm test)"] will skip the confirmation dialog to run any git and npm test commands. See Shell Tool command restrictions for details on prefix matching, command chaining, etc.undefinedtools.discoveryCommand (string):
undefinedtools.callCommand (string):
tools.discoveryCommand. The shell command must meet the following criteria:
name (exactly as in function declaration) as the first command line argument.stdin, analogous to functionCall.args.stdout, analogous to functionResponse.response.content.undefinedmcpmcp.serverCommand (string):
undefinedmcp.allowed (array of strings):
undefinedmcp.excluded (array of strings):
undefinedsecuritysecurity.folderTrust.enabled (boolean):
falsesecurity.auth.selectedType (string):
undefinedsecurity.auth.enforcedType (string):
undefinedsecurity.auth.useExternal (boolean):
undefinedadvancedadvanced.autoConfigureMemory (boolean):
falseadvanced.dnsResolutionOrder (string):
undefinedadvanced.excludedEnvVars (array of strings):
["DEBUG","DEBUG_MODE"]advanced.bugCommand (object):
undefinedmcpServersConfigures connections to one or more Model-Context Protocol (MCP) servers for discovering and using custom tools. Gemini CLI attempts to connect to each configured MCP server to discover available tools. If multiple MCP servers expose a tool with the same name, the tool names will be prefixed with the server alias you defined in the configuration (e.g., serverAlias__actualToolName) to avoid conflicts. Note that the system might strip certain schema properties from MCP tool definitions for compatibility. At least one of command, url, or httpUrl must be provided. If multiple are specified, the order of precedence is httpUrl, then url, then command.
mcpServers.<SERVER_NAME> (object): The server parameters for the named server.
command (string, optional): The command to execute to start the MCP server via standard I/O.args (array of strings, optional): Arguments to pass to the command.env (object, optional): Environment variables to set for the server process.cwd (string, optional): The working directory in which to start the server.url (string, optional): The URL of an MCP server that uses Server-Sent Events (SSE) for communication.httpUrl (string, optional): The URL of an MCP server that uses streamable HTTP for communication.headers (object, optional): A map of HTTP headers to send with requests to url or httpUrl.timeout (number, optional): Timeout in milliseconds for requests to this MCP server.trust (boolean, optional): Trust this server and bypass all tool call confirmations.description (string, optional): A brief description of the server, which may be used for display purposes.includeTools (array of strings, optional): List of tool names to include from this MCP server. When specified, only the tools listed here will be available from this server (allowlist behavior). If not specified, all tools from the server are enabled by default.excludeTools (array of strings, optional): List of tool names to exclude from this MCP server. Tools listed here will not be available to the model, even if they are exposed by the server. Note: excludeTools takes precedence over includeTools - if a tool is in both lists, it will be excluded.telemetryConfigures logging and metrics collection for Gemini CLI. For more information, see Telemetry.
enabled (boolean): Whether or not telemetry is enabled.target (string): The destination for collected telemetry. Supported values are local and gcp.otlpEndpoint (string): The endpoint for the OTLP Exporter.otlpProtocol (string): The protocol for the OTLP Exporter (grpc or http).logPrompts (boolean): Whether or not to include the content of user prompts in the logs.outfile (string): The file to write telemetry to when target is local.useCollector (boolean): Whether to use an external OTLP collector.settings.jsonHere is an example of a settings.json file with the nested structure, new as of v0.3.0:
{
"general": {
"vimMode": true,
"preferredEditor": "code"
},
"ui": {
"theme": "GitHub",
"hideBanner": true,
"hideTips": false,
"customWittyPhrases": [
"You forget a thousand things every day. Make sure this is one of ’em",
"Connecting to AGI"
]
},
"tools": {
"sandbox": "docker",
"discoveryCommand": "bin/get_tools",
"callCommand": "bin/call_tool",
"exclude": ["write_file"]
},
"mcpServers": {
"mainServer": {
"command": "bin/mcp_server.py"
},
"anotherServer": {
"command": "node",
"args": ["mcp_server.js", "--verbose"]
}
},
"telemetry": {
"enabled": true,
"target": "local",
"otlpEndpoint": "http://localhost:4317",
"logPrompts": true
},
"privacy": {
"usageStatisticsEnabled": true
},
"model": {
"name": "gemini-1.5-pro-latest",
"maxSessionTurns": 10,
"summarizeToolOutput": {
"run_shell_command": {
"tokenBudget": 100
}
}
},
"context": {
"fileName": ["CONTEXT.md", "GEMINI.md"],
"includeDirectories": ["path/to/dir1", "~/path/to/dir2", "../path/to/dir3"],
"loadFromIncludeDirectories": true,
"fileFiltering": {
"respectGitIgnore": false
}
},
"advanced": {
"excludedEnvVars": ["DEBUG", "DEBUG_MODE", "NODE_ENV"]
}
}
The CLI keeps a history of shell commands you run. To avoid conflicts between different projects, this history is stored in a project-specific directory within your user’s home folder.
~/.gemini/tmp/<project_hash>/shell_history
<project_hash> is a unique identifier generated from your project’s root path.shell_history..env FilesEnvironment variables are a common way to configure applications, especially for sensitive information like API keys or for settings that might change between environments. For authentication setup, see the Authentication documentation which covers all available authentication methods.
The CLI automatically loads environment variables from an .env file. The loading order is:
.env file in the current working directory..env file or reaches the project root (identified by a .git folder) or the home directory.~/.env (in the user’s home directory).Environment Variable Exclusion: Some environment variables (like DEBUG and DEBUG_MODE) are automatically excluded from being loaded from project .env files to prevent interference with gemini-cli behavior. Variables from .gemini/.env files are never excluded. You can customize this behavior using the advanced.excludedEnvVars setting in your settings.json file.
GEMINI_API_KEY:
~/.bashrc, ~/.zshrc) or an .env file.GEMINI_MODEL:
export GEMINI_MODEL="gemini-2.5-flash"GOOGLE_API_KEY:
export GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY".GOOGLE_CLOUD_PROJECT:
GOOGLE_CLOUD_PROJECT set in your global environment in Cloud Shell, it will be overridden by this default. To use a different project in Cloud Shell, you must define GOOGLE_CLOUD_PROJECT in a .env file.export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID".GOOGLE_APPLICATION_CREDENTIALS (string):
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/credentials.json"OTLP_GOOGLE_CLOUD_PROJECT:
export OTLP_GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID".GEMINI_TELEMETRY_ENABLED:
true or 1 to enable telemetry. Any other value is treated as disabling it.telemetry.enabled setting.GEMINI_TELEMETRY_TARGET:
local or gcp).telemetry.target setting.GEMINI_TELEMETRY_OTLP_ENDPOINT:
telemetry.otlpEndpoint setting.GEMINI_TELEMETRY_OTLP_PROTOCOL:
grpc or http).telemetry.otlpProtocol setting.GEMINI_TELEMETRY_LOG_PROMPTS:
true or 1 to enable or disable logging of user prompts. Any other value is treated as disabling it.telemetry.logPrompts setting.GEMINI_TELEMETRY_OUTFILE:
local.telemetry.outfile setting.GEMINI_TELEMETRY_USE_COLLECTOR:
true or 1 to enable or disable using an external OTLP collector. Any other value is treated as disabling it.telemetry.useCollector setting.GOOGLE_CLOUD_LOCATION:
export GOOGLE_CLOUD_LOCATION="YOUR_PROJECT_LOCATION".GEMINI_SANDBOX:
sandbox setting in settings.json.true, false, docker, podman, or a custom command string.SEATBELT_PROFILE (macOS specific):
sandbox-exec) profile on macOS.permissive-open: (Default) Restricts writes to the project folder (and a few other folders, see packages/cli/src/utils/sandbox-macos-permissive-open.sb) but allows other operations.strict: Uses a strict profile that declines operations by default.<profile_name>: Uses a custom profile. To define a custom profile, create a file named sandbox-macos-<profile_name>.sb in your project’s .gemini/ directory (e.g., my-project/.gemini/sandbox-macos-custom.sb).DEBUG or DEBUG_MODE (often used by underlying libraries or the CLI itself):
true or 1 to enable verbose debug logging, which can be helpful for troubleshooting..env files by default to prevent interference with gemini-cli behavior. Use .gemini/.env files if you need to set these for gemini-cli specifically.NO_COLOR:
CLI_TITLE:
CODE_ASSIST_ENDPOINT:
Arguments passed directly when running the CLI can override other configurations for that specific session.
--model <model_name> (-m <model_name>):
npm start -- --model gemini-1.5-pro-latest--prompt <your_prompt> (-p <your_prompt>):
--output-format json flag to get structured output.--prompt-interactive <your_prompt> (-i <your_prompt>):
gemini -i "explain this code"--output-format <format>:
text: (Default) The standard human-readable output.json: A machine-readable JSON output.--output-format json flag.--sandbox (-s):
--sandbox-image:
--debug (-d):
--all-files (-a):
--help (or -h):
--show-memory-usage:
--yolo:
--approval-mode <mode>:
default: Prompt for approval on each tool call (default behavior)auto_edit: Automatically approve edit tools (replace, write_file) while prompting for othersyolo: Automatically approve all tool calls (equivalent to --yolo)--yolo. Use --approval-mode=yolo instead of --yolo for the new unified approach.gemini --approval-mode auto_edit--allowed-tools <tool1,tool2,...>:
gemini --allowed-tools "ShellTool(git status)"--telemetry:
--telemetry-target:
--telemetry-otlp-endpoint:
--telemetry-otlp-protocol:
grpc or http). Defaults to grpc. See telemetry for more information.--telemetry-log-prompts:
--checkpointing:
--extensions <extension_name ...> (-e <extension_name ...>):
gemini -e none to disable all extensions.gemini -e my-extension -e my-other-extension--list-extensions (-l):
--proxy:
--proxy http://localhost:7890.--include-directories <dir1,dir2,...>:
--include-directories /path/to/project1,/path/to/project2 or --include-directories /path/to/project1 --include-directories /path/to/project2--screen-reader:
--version:
While not strictly configuration for the CLI’s behavior, context files (defaulting to GEMINI.md but configurable via the context.fileName setting) are crucial for configuring the instructional context (also referred to as “memory”) provided to the Gemini model. This powerful feature allows you to give project-specific instructions, coding style guides, or any relevant background information to the AI, making its responses more tailored and accurate to your needs. The CLI includes UI elements, such as an indicator in the footer showing the number of loaded context files, to keep you informed about the active context.
GEMINI.md)Here’s a conceptual example of what a context file at the root of a TypeScript project might contain:
# Project: My Awesome TypeScript Library
## General Instructions:
- When generating new TypeScript code, please follow the existing coding style.
- Ensure all new functions and classes have JSDoc comments.
- Prefer functional programming paradigms where appropriate.
- All code should be compatible with TypeScript 5.0 and Node.js 20+.
## Coding Style:
- Use 2 spaces for indentation.
- Interface names should be prefixed with `I` (e.g., `IUserService`).
- Private class members should be prefixed with an underscore (`_`).
- Always use strict equality (`===` and `!==`).
## Specific Component: `src/api/client.ts`
- This file handles all outbound API requests.
- When adding new API call functions, ensure they include robust error handling and logging.
- Use the existing `fetchWithRetry` utility for all GET requests.
## Regarding Dependencies:
- Avoid introducing new external dependencies unless absolutely necessary.
- If a new dependency is required, please state the reason.
This example demonstrates how you can provide general project context, specific coding conventions, and even notes about particular files or components. The more relevant and precise your context files are, the better the AI can assist you. Project-specific context files are highly encouraged to establish conventions and context.
GEMINI.md) from several locations. Content from files lower in this list (more specific) typically overrides or supplements content from files higher up (more general). The exact concatenation order and final context can be inspected using the /memory show command. The typical loading order is:
~/.gemini/<configured-context-filename> (e.g., ~/.gemini/GEMINI.md in your user home directory)..git folder) or your home directory.node_modules, .git, etc.). The breadth of this search is limited to 200 directories by default, but can be configured with the context.discoveryMaxDirs setting in your settings.json file.@path/to/file.md syntax. For more details, see the Memory Import Processor documentation./memory refresh to force a re-scan and reload of all context files from all configured locations. This updates the AI’s instructional context./memory show to display the combined instructional context currently loaded, allowing you to verify the hierarchy and content being used by the AI./memory command and its sub-commands (show and refresh).By understanding and utilizing these configuration layers and the hierarchical nature of context files, you can effectively manage the AI’s memory and tailor the Gemini CLI’s responses to your specific needs and projects.
The Gemini CLI can execute potentially unsafe operations (like shell commands and file modifications) within a sandboxed environment to protect your system.
Sandboxing is disabled by default, but you can enable it in a few ways:
--sandbox or -s flag.GEMINI_SANDBOX environment variable.--yolo or --approval-mode=yolo by default.By default, it uses a pre-built gemini-cli-sandbox Docker image.
For project-specific sandboxing needs, you can create a custom Dockerfile at .gemini/sandbox.Dockerfile in your project’s root directory. This Dockerfile can be based on the base sandbox image:
FROM gemini-cli-sandbox
# Add your custom dependencies or configurations here
# For example:
# RUN apt-get update && apt-get install -y some-package
# COPY ./my-config /app/my-config
When .gemini/sandbox.Dockerfile exists, you can use BUILD_SANDBOX environment variable when running Gemini CLI to automatically build the custom sandbox image:
BUILD_SANDBOX=1 gemini -s
To help us improve the Gemini CLI, we collect anonymized usage statistics. This data helps us understand how the CLI is used, identify common issues, and prioritize new features.
What we collect:
What we DON’T collect:
How to opt out:
You can opt out of usage statistics collection at any time by setting the usageStatisticsEnabled property to false under the privacy category in your settings.json file:
{
"privacy": {
"usageStatisticsEnabled": false
}
}