RuleStack

Configs

Stacks

Compare

Diff

RuleStack

Configs

Stacks

Compare

Diff

Read API

RuleStack

Configs

Stacks

Compare

Diff

Read API

Diff/herringtondarkholme-megarepo-github-copilot-instructions ↔ herringtondarkholme-megarepo-gemini

Comparison

A · Copilot instructions · HerringtonDarkholme/megarepoB · GEMINI.md · HerringtonDarkholme/megarepo
What each file covers, counted
DimensionSharedOnly in AOnly in BOverlap
Sections042230%
Commands01120%
Section tags56433%

What each file covers

Sections

0 shared · 42 only in A · 23 only in B
  • − Megarepo - AI Setup Repository
  • − Repository Overview
  • − Current Repository State
  • − Working Effectively
  • − Initial Repository Exploration
  • − Always start by understanding the current repository state
  • − When Source Code is Added
  • − Check for package.json first
  • − If package.json exists, install dependencies
  • − NEVER CANCEL: npm install typically takes 2-5 minutes. Set timeout to 10+ minutes.
  • − Common build commands (verify these exist in package.json first)
  • − NEVER CANCEL: Build may take 5-45 minutes depending on project size. Set timeout to 60+ minutes.
  • − Common test commands
  • − NEVER CANCEL: Tests may take 5-15 minutes. Set timeout to 30+ minutes.
  • − Common development server
  • − Check for linting configuration
  • − Run linting if configured
  • − Run formatting if configured
  • − Run type checking if TypeScript
  • − Repository Structure Expectations
  • − Validation Requirements
  • − Before Making Changes
  • − After Making Changes
  • − Common Commands Reference
  • − Repository Information
  • − View current files
  • − Check git status
  • − View repository structure
  • − When Package.json Exists
  • − View available scripts
  • − Install dependencies
  • − TIMEOUT: 10+ minutes
  • − Common development commands (check package.json first)
  • − File Locations and Navigation
  • − Current Key Files
  • − Expected Important Locations (when populated)
  • − AI Development Guidelines
  • − Troubleshooting
  • − Repository Appears Empty
  • − Build Failures
  • − Development Server Issues
  • − Critical Reminders
  • + Gemini CLI Configuration
  • + Configuration layers
  • + Settings files
  • + The `.gemini` directory in your project
  • + Available settings in `settings.json`:
  • + Example `settings.json`:
  • + Shell History
  • + Environment Variables & `.env` Files
  • + Command-Line Arguments
  • + Context Files (Hierarchical Instructional Context)
  • + Example Context File Content (e.g., `GEMINI.md`)
  • + Project: My Awesome TypeScript Library
  • + General Instructions:
  • + Coding Style:
  • + Specific Component: `src/api/client.ts`
  • + Regarding Dependencies:
  • + Context File Management Commands
  • + Best Practices for Context Files
  • + Usage Statistics
  • + Sandboxing
  • + Types of Sandboxing
  • + Configuration
  • + Custom Sandbox Profiles

Commands

0 shared · 11 only in A · 2 only in B
  • − git status
  • − npm install
  • − npm run build
  • − npm test
  • − npm run dev
  • − npm run lint
  • − npm run format
  • − npm run type-check
  • − npm run start
  • − npm run test
  • − git branch -a
  • + docker
  • + npm start -- --model gemini-1.5-pro-latest

Section tags

5 shared · 6 only in A · 4 only in B
  • − build
  • − test
  • − lint-format
  • − git-pr
  • − security
  • − do-not
  • + code-style
  • + api
  • + ui
  • + docs
  •   setup
  •   architecture
  •   types
  •   dependencies
  •   agent-behaviour

Line diff

+520 added−175 removed50 unchanged8.8% identical
HerringtonDarkholme/megarepo · .github/copilot-instructions.md
@@ −1 @@
1# Megarepo - AI Setup Repository
2 
3**ALWAYS follow these instructions first and only fallback to additional search and context gathering if the information here is incomplete or found to be in error.**
4 
5## Repository Overview
6 
7Megarepo is currently a minimal repository template designed for AI-related projects. The repository contains basic setup files and is configured for Node.js/Next.js development based on the .gitignore patterns.
8 
9## Current Repository State
 
 
 
 
 
10 
11**IMPORTANT**: This repository is currently in a minimal state with only basic setup files:
12- README.md (basic project description)
13- LICENSE (MIT license)
14- .gitignore (configured for Node.js/Next.js projects)
15 
16**DO NOT attempt to build, test, or run code** - there is no source code or build system present yet.
17 
18## Working Effectively
 
 
 
 
 
 
 
 
19 
20### Initial Repository Exploration
21```bash
22# Always start by understanding the current repository state
23ls -la
24git status
25find . -type f -name "*.json" -o -name "*.js" -o -name "*.ts" -o -name "*.md"
26```
27 
28### When Source Code is Added
29 
30The repository is pre-configured for Node.js/Next.js development. When source code is added, follow these patterns:
31 
32#### Node.js/Next.js Project Setup
33```bash
34# Check for package.json first
35ls package.json
36 
37# If package.json exists, install dependencies
38npm install
39# NEVER CANCEL: npm install typically takes 2-5 minutes. Set timeout to 10+ minutes.
40 
41# Common build commands (verify these exist in package.json first)
42npm run build
43# NEVER CANCEL: Build may take 5-45 minutes depending on project size. Set timeout to 60+ minutes.
 
44 
45# Common test commands
46npm test
47# NEVER CANCEL: Tests may take 5-15 minutes. Set timeout to 30+ minutes.
 
 
 
 
 
 
 
 
48 
49# Common development server
50npm run dev
51```
 
 
 
 
 
 
 
 
 
 
52 
53#### Pre-commit Validation
54When source code exists, always run these before committing:
55```bash
56# Check for linting configuration
57ls .eslintrc* eslint.config.* .prettierrc*
58 
59# Run linting if configured
60npm run lint
 
 
 
 
 
61 
62# Run formatting if configured
63npm run format
 
 
 
64 
65# Run type checking if TypeScript
66npm run type-check
67```
 
 
68 
69## Repository Structure Expectations
 
 
 
70 
71Based on the .gitignore configuration, expect the following when the repository is populated:
 
 
 
72 
73```
74.
75├── README.md # Project documentation
76├── LICENSE # MIT license
77├── .gitignore # Node.js/Next.js ignore patterns
78├── package.json # Node.js dependencies and scripts
79├── package-lock.json # Dependency lockfile
80├── next.config.js # Next.js configuration (if Next.js)
81├── tsconfig.json # TypeScript configuration (if TypeScript)
82├── .eslintrc.* # ESLint configuration
83├── .prettierrc # Prettier configuration
84├── src/ # Source code directory
85│ ├── pages/ # Next.js pages (if Next.js)
86│ ├── components/ # React components
87│ └── utils/ # Utility functions
88├── public/ # Static assets
89├── .next/ # Next.js build output (ignored)
90├── build/ # Build output (ignored)
91└── node_modules/ # Dependencies (ignored)
92```
93 
94## Validation Requirements
 
 
 
95 
96### Before Making Changes
971. **Always check current repository state first**:
98 ```bash
99 git status
100 ls -la
101 cat package.json # Only if it exists
102 ```
103 
1042. **Verify build system exists before attempting builds**:
105 ```bash
106 # Check for package.json before running npm commands
107 test -f package.json && echo "Node.js project detected" || echo "No package.json found"
108 ```
 
 
109 
110### After Making Changes
1111. **When source code is present, always validate**:
112 ```bash
113 # Install dependencies if package.json exists
114 test -f package.json && npm install
115
116 # Build if build script exists
117 test -f package.json && npm run build
118
119 # Test if test script exists
120 test -f package.json && npm test
121
122 # Lint if lint script exists
123 test -f package.json && npm run lint
124 ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125 
1262. **Manual validation scenarios when application exists**:
127 - Start the development server and verify it loads
128 - Test basic functionality by navigating through the application
129 - Verify any API endpoints respond correctly
130 - Check console for errors
131 
132## Common Commands Reference
 
 
 
133 
134### Repository Information
135```bash
136# View current files
137ls -la
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138 
139# Check git status
140git status
 
 
141 
142# View repository structure
143tree . -a -I 'node_modules|.git' # If tree is available (use -a to show hidden files)
144find . -type f -not -path "./.git/*" -not -path "./node_modules/*" | sort
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145```
146 
147### When Package.json Exists
148```bash
149# View available scripts
150cat package.json | grep -A 20 '"scripts"'
151 
152# Install dependencies
153npm install
154# TIMEOUT: 10+ minutes
155 
156# Common development commands (check package.json first)
157npm run dev # Development server
158npm run build # Production build
159npm run start # Start production server
160npm run test # Run tests
161npm run lint # Run linter
162npm run format # Format code
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163```
164 
165## File Locations and Navigation
166 
167### Current Key Files
168- `/README.md` - Project overview and setup instructions
169- `/LICENSE` - MIT license terms
170- `/.gitignore` - Git ignore patterns (Node.js/Next.js focused)
 
 
 
 
 
 
171 
172### Expected Important Locations (when populated)
173- `/src/` - Main source code directory
174- `/src/pages/` - Next.js pages (if Next.js project)
175- `/src/components/` - React components
176- `/public/` - Static assets and files
177- `/package.json` - Project configuration and dependencies
178- `/next.config.js` - Next.js configuration
179- `/tsconfig.json` - TypeScript configuration
180 
181## AI Development Guidelines
182 
183Since this is an AI setup repository:
 
 
184 
1851. **Always verify AI-related dependencies** when they are added:
186 ```bash
187 # Common AI packages to look for
188 grep -E "(openai|langchain|tensorflow|pytorch|huggingface)" package.json
189 ```
190 
1912. **Environment variables for AI services**:
192 ```bash
193 # Check for environment configuration
194 ls .env* || echo "No environment files found"
195 ```
196 
1973. **API key management**:
198 - Never commit API keys
199 - Always use environment variables
200 - Check .env.example for required variables
201 
202## Troubleshooting
203 
204### Repository Appears Empty
205- This is expected in the current state
206- Check git branch: `git branch -a`
207- Look for other branches that might contain code
208 
209### Build Failures
210- First verify package.json exists: `ls package.json`
211- Clear dependencies and reinstall: `rm -rf node_modules package-lock.json && npm install`
212- Check Node.js version compatibility in package.json
213 
214### Development Server Issues
215- Verify port availability (typically 3000 for Next.js)
216- Check for environment variable requirements
217- Review console output for specific error messages
218 
219## Critical Reminders
220 
221- **NEVER CANCEL builds or long-running commands** - they may take 45+ minutes
222- **ALWAYS validate commands work** before assuming functionality exists
223- **CHECK for package.json** before running npm commands
224- **SET APPROPRIATE TIMEOUTS** - builds: 60+ minutes, tests: 30+ minutes
225- **VERIFY repository state** before attempting any operations
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
HerringtonDarkholme/megarepo · GEMINI.md
@@ +1 @@
1# Gemini CLI Configuration
2 
3Gemini 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.
4 
5## Configuration layers
6 
7Configuration is applied in the following order of precedence (lower numbers are overridden by higher numbers):
8 
91. **Default values:** Hardcoded defaults within the application.
102. **User settings file:** Global settings for the current user.
113. **Project settings file:** Project-specific settings.
124. **System settings file:** System-wide settings.
135. **Environment variables:** System-wide or session-specific variables, potentially loaded from `.env` files.
146. **Command-line arguments:** Values passed when launching the CLI.
15 
16## Settings files
 
 
 
17 
18Gemini CLI uses `settings.json` files for persistent configuration. There are three locations for these files:
19 
20- **User settings file:**
21 - **Location:** `~/.gemini/settings.json` (where `~` is your home directory).
22 - **Scope:** Applies to all Gemini CLI sessions for the current user.
23- **Project settings file:**
24 - **Location:** `.gemini/settings.json` within your project's root directory.
25 - **Scope:** Applies only when running Gemini CLI from that specific project. Project settings override user settings.
26- **System settings file:**
27 - **Location:** `/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.
28 - **Scope:** Applies to all Gemini CLI sessions on the system, for all users. System settings override user and project settings. May be useful for system administrators at enterprises to have controls over users' Gemini CLI setups.
29 
30**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"`.
 
 
 
 
 
 
31 
32### The `.gemini` directory in your project
33 
34In 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:
35 
36- [Custom sandbox profiles](#sandboxing) (e.g., `.gemini/sandbox-macos-custom.sb`, `.gemini/sandbox.Dockerfile`).
 
 
 
37 
38### Available settings in `settings.json`:
 
 
39 
40- **`contextFileName`** (string or array of strings):
41 - **Description:** Specifies the filename for context files (e.g., `GEMINI.md`, `AGENTS.md`). Can be a single filename or a list of accepted filenames.
42 - **Default:** `GEMINI.md`
43 - **Example:** `"contextFileName": "AGENTS.md"`
44 
45- **`bugCommand`** (object):
46 - **Description:** Overrides the default URL for the `/bug` command.
47 - **Default:** `"urlTemplate": "https://github.com/google-gemini/gemini-cli/issues/new?template=bug_report.yml&title={title}&info={info}"`
48 - **Properties:**
49 - **`urlTemplate`** (string): A URL that can contain `{title}` and `{info}` placeholders.
50 - **Example:**
51 ```json
52 "bugCommand": {
53 "urlTemplate": "https://bug.example.com/new?title={title}&info={info}"
54 }
55 ```
56 
57- **`fileFiltering`** (object):
58 - **Description:** Controls git-aware file filtering behavior for @ commands and file discovery tools.
59 - **Default:** `"respectGitIgnore": true, "enableRecursiveFileSearch": true`
60 - **Properties:**
61 - **`respectGitIgnore`** (boolean): Whether to respect .gitignore patterns when discovering files. When set to `true`, git-ignored files (like `node_modules/`, `dist/`, `.env`) are automatically excluded from @ commands and file listing operations.
62 - **`enableRecursiveFileSearch`** (boolean): Whether to enable searching recursively for filenames under the current tree when completing @ prefixes in the prompt.
63 - **Example:**
64 ```json
65 "fileFiltering": {
66 "respectGitIgnore": true,
67 "enableRecursiveFileSearch": false
68 }
69 ```
70 
71- **`coreTools`** (array of strings):
72 - **Description:** Allows you to specify a list of core tool names that should be made available to the model. This can be used to restrict the set of built-in tools. See [Built-in Tools](../core/tools-api.md#built-in-tools) for a list of core tools. You can also specify command-specific restrictions for tools that support it, like the `ShellTool`. For example, `"coreTools": ["ShellTool(ls -l)"]` will only allow the `ls -l` command to be executed.
73 - **Default:** All tools available for use by the Gemini model.
74 - **Example:** `"coreTools": ["ReadFileTool", "GlobTool", "ShellTool(ls)"]`.
 
75 
76- **`excludeTools`** (array of strings):
77 - **Description:** Allows you to specify a list of core tool names that should be excluded from the model. A tool listed in both `excludeTools` and `coreTools` is excluded. You can also specify command-specific restrictions for tools that support it, like the `ShellTool`. For example, `"excludeTools": ["ShellTool(rm -rf)"]` will block the `rm -rf` command.
78 - **Default**: No tools excluded.
79 - **Example:** `"excludeTools": ["run_shell_command", "findFiles"]`.
80 - **Security Note:** Command-specific restrictions in
81 `excludeTools` for `run_shell_command` are based on simple string matching and can be easily bypassed. This feature is **not a security mechanism** and should not be relied upon to safely execute untrusted code. It is recommended to use `coreTools` to explicitly select commands
82 that can be executed.
83 
84- **`allowMCPServers`** (array of strings):
85 - **Description:** Allows you to specify a list of MCP server names that should be made available to the model. This can be used to restrict the set of MCP servers to connect to. Note that this will be ignored if `--allowed-mcp-server-names` is set.
86 - **Default:** All MCP servers are available for use by the Gemini model.
87 - **Example:** `"allowMCPServers": ["myPythonServer"]`.
88 - **Security Note:** This uses simple string matching on MCP server names, which can be modified. If you're a system administrator looking to prevent users from bypassing this, consider configuring the `mcpServers` at the system settings level such that the user will not be able to configure any MCP servers of their own. This should not be used as an airtight security mechanism.
89 
90- **`excludeMCPServers`** (array of strings):
91 - **Description:** Allows you to specify a list of MCP server names that should be excluded from the model. A server listed in both `excludeMCPServers` and `allowMCPServers` is excluded. Note that this will be ignored if `--allowed-mcp-server-names` is set.
92 - **Default**: No MCP servers excluded.
93 - **Example:** `"excludeMCPServers": ["myNodeServer"]`.
94 - **Security Note:** This uses simple string matching on MCP server names, which can be modified. If you're a system administrator looking to prevent users from bypassing this, consider configuring the `mcpServers` at the system settings level such that the user will not be able to configure any MCP servers of their own. This should not be used as an airtight security mechanism.
95 
96- **`autoAccept`** (boolean):
97 - **Description:** Controls whether the CLI automatically accepts and executes tool calls that are considered safe (e.g., read-only operations) without explicit user confirmation. If set to `true`, the CLI will bypass the confirmation prompt for tools deemed safe.
98 - **Default:** `false`
99 - **Example:** `"autoAccept": true`
100 
101- **`theme`** (string):
102 - **Description:** Sets the visual [theme](./themes.md) for Gemini CLI.
103 - **Default:** `"Default"`
104 - **Example:** `"theme": "GitHub"`
105 
106- **`vimMode`** (boolean):
107 - **Description:** Enables or disables vim mode for input editing. When enabled, the input area supports vim-style navigation and editing commands with NORMAL and INSERT modes. The vim mode status is displayed in the footer and persists between sessions.
108 - **Default:** `false`
109 - **Example:** `"vimMode": true`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110 
111- **`sandbox`** (boolean or string):
112 - **Description:** Controls whether and how to use sandboxing for tool execution. If set to `true`, Gemini CLI uses a pre-built `gemini-cli-sandbox` Docker image. For more information, see [Sandboxing](#sandboxing).
113 - **Default:** `false`
114 - **Example:** `"sandbox": "docker"`
115 
116- **`toolDiscoveryCommand`** (string):
117 - **Description:** Defines a custom shell command for discovering tools from your project. The shell command must return on `stdout` a JSON array of [function declarations](https://ai.google.dev/gemini-api/docs/function-calling#function-declarations). Tool wrappers are optional.
118 - **Default:** Empty
119 - **Example:** `"toolDiscoveryCommand": "bin/get_tools"`
 
 
 
120 
121- **`toolCallCommand`** (string):
122 - **Description:** Defines a custom shell command for calling a specific tool that was discovered using `toolDiscoveryCommand`. The shell command must meet the following criteria:
123 - It must take function `name` (exactly as in [function declaration](https://ai.google.dev/gemini-api/docs/function-calling#function-declarations)) as first command line argument.
124 - It must read function arguments as JSON on `stdin`, analogous to [`functionCall.args`](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference#functioncall).
125 - It must return function output as JSON on `stdout`, analogous to [`functionResponse.response.content`](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference#functionresponse).
126 - **Default:** Empty
127 - **Example:** `"toolCallCommand": "bin/call_tool"`
128 
129- **`mcpServers`** (object):
130 - **Description:** Configures 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.
131 - **Default:** Empty
132 - **Properties:**
133 - **`<SERVER_NAME>`** (object): The server parameters for the named server.
134 - `command` (string, required): The command to execute to start the MCP server.
135 - `args` (array of strings, optional): Arguments to pass to the command.
136 - `env` (object, optional): Environment variables to set for the server process.
137 - `cwd` (string, optional): The working directory in which to start the server.
138 - `timeout` (number, optional): Timeout in milliseconds for requests to this MCP server.
139 - `trust` (boolean, optional): Trust this server and bypass all tool call confirmations.
140 - `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 (whitelist behavior). If not specified, all tools from the server are enabled by default.
141 - `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.
142 - **Example:**
143 ```json
144 "mcpServers": {
145 "myPythonServer": {
146 "command": "python",
147 "args": ["mcp_server.py", "--port", "8080"],
148 "cwd": "./mcp_tools/python",
149 "timeout": 5000,
150 "includeTools": ["safe_tool", "file_reader"],
151 },
152 "myNodeServer": {
153 "command": "node",
154 "args": ["mcp_server.js"],
155 "cwd": "./mcp_tools/node",
156 "excludeTools": ["dangerous_tool", "file_deleter"]
157 },
158 "myDockerServer": {
159 "command": "docker",
160 "args": ["run", "-i", "--rm", "-e", "API_KEY", "ghcr.io/foo/bar"],
161 "env": {
162 "API_KEY": "$MY_API_TOKEN"
163 }
164 }
165 }
166 ```
167 
168- **`checkpointing`** (object):
169 - **Description:** Configures the checkpointing feature, which allows you to save and restore conversation and file states. See the [Checkpointing documentation](../checkpointing.md) for more details.
170 - **Default:** `{"enabled": false}`
171 - **Properties:**
172 - **`enabled`** (boolean): When `true`, the `/restore` command is available.
173 
174- **`preferredEditor`** (string):
175 - **Description:** Specifies the preferred editor to use for viewing diffs.
176 - **Default:** `vscode`
177 - **Example:** `"preferredEditor": "vscode"`
178 
179- **`telemetry`** (object)
180 - **Description:** Configures logging and metrics collection for Gemini CLI. For more information, see [Telemetry](../telemetry.md).
181 - **Default:** `{"enabled": false, "target": "local", "otlpEndpoint": "http://localhost:4317", "logPrompts": true}`
182 - **Properties:**
183 - **`enabled`** (boolean): Whether or not telemetry is enabled.
184 - **`target`** (string): The destination for collected telemetry. Supported values are `local` and `gcp`.
185 - **`otlpEndpoint`** (string): The endpoint for the OTLP Exporter.
186 - **`logPrompts`** (boolean): Whether or not to include the content of user prompts in the logs.
187 - **Example:**
188 ```json
189 "telemetry": {
190 "enabled": true,
191 "target": "local",
192 "otlpEndpoint": "http://localhost:16686",
193 "logPrompts": false
194 }
195 ```
196- **`usageStatisticsEnabled`** (boolean):
197 - **Description:** Enables or disables the collection of usage statistics. See [Usage Statistics](#usage-statistics) for more information.
198 - **Default:** `true`
199 - **Example:**
200 ```json
201 "usageStatisticsEnabled": false
202 ```
203 
204- **`hideTips`** (boolean):
205 - **Description:** Enables or disables helpful tips in the CLI interface.
206 - **Default:** `false`
207 - **Example:**
208 
209 ```json
210 "hideTips": true
211 ```
212 
213- **`hideBanner`** (boolean):
214 - **Description:** Enables or disables the startup banner (ASCII art logo) in the CLI interface.
215 - **Default:** `false`
216 - **Example:**
217 
218 ```json
219 "hideBanner": true
220 ```
221 
222- **`maxSessionTurns`** (number):
223 - **Description:** Sets the maximum number of turns for a session. If the session exceeds this limit, the CLI will stop processing and start a new chat.
224 - **Default:** `-1` (unlimited)
225 - **Example:**
226 ```json
227 "maxSessionTurns": 10
228 ```
229 
230- **`summarizeToolOutput`** (object):
231 - **Description:** Enables or disables the summarization of tool output. You can specify the token budget for the summarization using the `tokenBudget` setting.
232 - Note: Currently only the `run_shell_command` tool is supported.
233 - **Default:** `{}` (Disabled by default)
234 - **Example:**
235 ```json
236 "summarizeToolOutput": {
237 "run_shell_command": {
238 "tokenBudget": 2000
239 }
240 }
241 ```
242 
243- **`excludedProjectEnvVars`** (array of strings):
244 - **Description:** Specifies environment variables that should be excluded from being loaded from project `.env` files. This prevents project-specific environment variables (like `DEBUG=true`) from interfering with gemini-cli behavior. Variables from `.gemini/.env` files are never excluded.
245 - **Default:** `["DEBUG", "DEBUG_MODE"]`
246 - **Example:**
247 ```json
248 "excludedProjectEnvVars": ["DEBUG", "DEBUG_MODE", "NODE_ENV"]
249 ```
250 
251- **`includeDirectories`** (array of strings):
252 - **Description:** Specifies an array of additional absolute or relative paths to include in the workspace context. This allows you to work with files across multiple directories as if they were one. Paths can use `~` to refer to the user's home directory. This setting can be combined with the `--include-directories` command-line flag.
253 - **Default:** `[]`
254 - **Example:**
255 ```json
256 "includeDirectories": [
257 "/path/to/another/project",
258 "../shared-library",
259 "~/common-utils"
260 ]
261 ```
262 
263- **`loadMemoryFromIncludeDirectories`** (boolean):
264 - **Description:** Controls the behavior of the `/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.
265 - **Default:** `false`
266 - **Example:**
267 ```json
268 "loadMemoryFromIncludeDirectories": true
269 ```
270 
271- **`chatCompression`** (object):
272 - **Description:** Controls the settings for chat history compression, both automatic and
273 when manually invoked through the /compress command.
274 - **Properties:**
275 - **`contextPercentageThreshold`** (number): A value between 0 and 1 that specifies the token threshold for compression as a percentage of the model's total token limit. For example, a value of `0.6` will trigger compression when the chat history exceeds 60% of the token limit.
276 - **Example:**
277 ```json
278 "chatCompression": {
279 "contextPercentageThreshold": 0.6
280 }
281 ```
282 
283- **`showLineNumbers`** (boolean):
284 - **Description:** Controls whether line numbers are displayed in code blocks in the CLI output.
285 - **Default:** `true`
286 - **Example:**
287 ```json
288 "showLineNumbers": false
289 ```
290 
291### Example `settings.json`:
292 
293```json
294{
295 "theme": "GitHub",
296 "sandbox": "docker",
297 "toolDiscoveryCommand": "bin/get_tools",
298 "toolCallCommand": "bin/call_tool",
299 "mcpServers": {
300 "mainServer": {
301 "command": "bin/mcp_server.py"
302 },
303 "anotherServer": {
304 "command": "node",
305 "args": ["mcp_server.js", "--verbose"]
306 }
307 },
308 "telemetry": {
309 "enabled": true,
310 "target": "local",
311 "otlpEndpoint": "http://localhost:4317",
312 "logPrompts": true
313 },
314 "usageStatisticsEnabled": true,
315 "hideTips": false,
316 "hideBanner": false,
317 "maxSessionTurns": 10,
318 "summarizeToolOutput": {
319 "run_shell_command": {
320 "tokenBudget": 100
321 }
322 },
323 "excludedProjectEnvVars": ["DEBUG", "DEBUG_MODE", "NODE_ENV"],
324 "includeDirectories": ["path/to/dir1", "~/path/to/dir2", "../path/to/dir3"],
325 "loadMemoryFromIncludeDirectories": true
326}
327```
328 
329## Shell History
 
 
 
330 
331The 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.
 
 
332 
333- **Location:** `~/.gemini/tmp/<project_hash>/shell_history`
334 - `<project_hash>` is a unique identifier generated from your project's root path.
335 - The history is stored in a file named `shell_history`.
336 
337## Environment Variables & `.env` Files
338 
339Environment variables are a common way to configure applications, especially for sensitive information like API keys or for settings that might change between environments.
340 
341The CLI automatically loads environment variables from an `.env` file. The loading order is:
342 
3431. `.env` file in the current working directory.
3442. If not found, it searches upwards in parent directories until it finds an `.env` file or reaches the project root (identified by a `.git` folder) or the home directory.
3453. If still not found, it looks for `~/.env` (in the user's home directory).
346 
347**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 `excludedProjectEnvVars` setting in your `settings.json` file.
348 
349- **`GEMINI_API_KEY`** (Required):
350 - Your API key for the Gemini API.
351 - **Crucial for operation.** The CLI will not function without it.
352 - Set this in your shell profile (e.g., `~/.bashrc`, `~/.zshrc`) or an `.env` file.
353- **`GEMINI_MODEL`**:
354 - Specifies the default Gemini model to use.
355 - Overrides the hardcoded default
356 - Example: `export GEMINI_MODEL="gemini-2.5-flash"`
357- **`GOOGLE_API_KEY`**:
358 - Your Google Cloud API key.
359 - Required for using Vertex AI in express mode.
360 - Ensure you have the necessary permissions.
361 - Example: `export GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY"`.
362- **`GOOGLE_CLOUD_PROJECT`**:
363 - Your Google Cloud Project ID.
364 - Required for using Code Assist or Vertex AI.
365 - If using Vertex AI, ensure you have the necessary permissions in this project.
366 - **Cloud Shell Note:** When running in a Cloud Shell environment, this variable defaults to a special project allocated for Cloud Shell users. If you have `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.
367 - Example: `export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"`.
368- **`GOOGLE_APPLICATION_CREDENTIALS`** (string):
369 - **Description:** The path to your Google Application Credentials JSON file.
370 - **Example:** `export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/credentials.json"`
371- **`OTLP_GOOGLE_CLOUD_PROJECT`**:
372 - Your Google Cloud Project ID for Telemetry in Google Cloud
373 - Example: `export OTLP_GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"`.
374- **`GOOGLE_CLOUD_LOCATION`**:
375 - Your Google Cloud Project Location (e.g., us-central1).
376 - Required for using Vertex AI in non express mode.
377 - Example: `export GOOGLE_CLOUD_LOCATION="YOUR_PROJECT_LOCATION"`.
378- **`GEMINI_SANDBOX`**:
379 - Alternative to the `sandbox` setting in `settings.json`.
380 - Accepts `true`, `false`, `docker`, `podman`, or a custom command string.
381- **`SEATBELT_PROFILE`** (macOS specific):
382 - Switches the Seatbelt (`sandbox-exec`) profile on macOS.
383 - `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.
384 - `strict`: Uses a strict profile that declines operations by default.
385 - `<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`).
386- **`DEBUG` or `DEBUG_MODE`** (often used by underlying libraries or the CLI itself):
387 - Set to `true` or `1` to enable verbose debug logging, which can be helpful for troubleshooting.
388 - **Note:** These variables are automatically excluded from project `.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.
389- **`NO_COLOR`**:
390 - Set to any value to disable all color output in the CLI.
391- **`CLI_TITLE`**:
392 - Set to a string to customize the title of the CLI.
393- **`CODE_ASSIST_ENDPOINT`**:
394 - Specifies the endpoint for the code assist server.
395 - This is useful for development and testing.
396 
397## Command-Line Arguments
398 
399Arguments passed directly when running the CLI can override other configurations for that specific session.
400 
401- **`--model <model_name>`** (**`-m <model_name>`**):
402 - Specifies the Gemini model to use for this session.
403 - Example: `npm start -- --model gemini-1.5-pro-latest`
404- **`--prompt <your_prompt>`** (**`-p <your_prompt>`**):
405 - Used to pass a prompt directly to the command. This invokes Gemini CLI in a non-interactive mode.
406- **`--prompt-interactive <your_prompt>`** (**`-i <your_prompt>`**):
407 - Starts an interactive session with the provided prompt as the initial input.
408 - The prompt is processed within the interactive session, not before it.
409 - Cannot be used when piping input from stdin.
410 - Example: `gemini -i "explain this code"`
411- **`--sandbox`** (**`-s`**):
412 - Enables sandbox mode for this session.
413- **`--sandbox-image`**:
414 - Sets the sandbox image URI.
415- **`--debug`** (**`-d`**):
416 - Enables debug mode for this session, providing more verbose output.
417- **`--all-files`** (**`-a`**):
418 - If set, recursively includes all files within the current directory as context for the prompt.
419- **`--help`** (or **`-h`**):
420 - Displays help information about command-line arguments.
421- **`--show-memory-usage`**:
422 - Displays the current memory usage.
423- **`--yolo`**:
424 - Enables YOLO mode, which automatically approves all tool calls.
425- **`--approval-mode <mode>`**:
426 - Sets the approval mode for tool calls. Available modes:
427 - `default`: Prompt for approval on each tool call (default behavior)
428 - `auto_edit`: Automatically approve edit tools (replace, write_file) while prompting for others
429 - `yolo`: Automatically approve all tool calls (equivalent to `--yolo`)
430 - Cannot be used together with `--yolo`. Use `--approval-mode=yolo` instead of `--yolo` for the new unified approach.
431 - Example: `gemini --approval-mode auto_edit`
432- **`--telemetry`**:
433 - Enables [telemetry](../telemetry.md).
434- **`--telemetry-target`**:
435 - Sets the telemetry target. See [telemetry](../telemetry.md) for more information.
436- **`--telemetry-otlp-endpoint`**:
437 - Sets the OTLP endpoint for telemetry. See [telemetry](../telemetry.md) for more information.
438- **`--telemetry-otlp-protocol`**:
439 - Sets the OTLP protocol for telemetry (`grpc` or `http`). Defaults to `grpc`. See [telemetry](../telemetry.md) for more information.
440- **`--telemetry-log-prompts`**:
441 - Enables logging of prompts for telemetry. See [telemetry](../telemetry.md) for more information.
442- **`--checkpointing`**:
443 - Enables [checkpointing](../checkpointing.md).
444- **`--extensions <extension_name ...>`** (**`-e <extension_name ...>`**):
445 - Specifies a list of extensions to use for the session. If not provided, all available extensions are used.
446 - Use the special term `gemini -e none` to disable all extensions.
447 - Example: `gemini -e my-extension -e my-other-extension`
448- **`--list-extensions`** (**`-l`**):
449 - Lists all available extensions and exits.
450- **`--proxy`**:
451 - Sets the proxy for the CLI.
452 - Example: `--proxy http://localhost:7890`.
453- **`--include-directories <dir1,dir2,...>`**:
454 - Includes additional directories in the workspace for multi-directory support.
455 - Can be specified multiple times or as comma-separated values.
456 - 5 directories can be added at maximum.
457 - Example: `--include-directories /path/to/project1,/path/to/project2` or `--include-directories /path/to/project1 --include-directories /path/to/project2`
458- **`--version`**:
459 - Displays the version of the CLI.
460 
461## Context Files (Hierarchical Instructional Context)
462 
463While not strictly configuration for the CLI's _behavior_, context files (defaulting to `GEMINI.md` but configurable via the `contextFileName` 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.
464 
465- **Purpose:** These Markdown files contain instructions, guidelines, or context that you want the Gemini model to be aware of during your interactions. The system is designed to manage this instructional context hierarchically.
466 
467### Example Context File Content (e.g., `GEMINI.md`)
468 
469Here's a conceptual example of what a context file at the root of a TypeScript project might contain:
470 
471```markdown
472# Project: My Awesome TypeScript Library
473 
474## General Instructions:
475 
476- When generating new TypeScript code, please follow the existing coding style.
477- Ensure all new functions and classes have JSDoc comments.
478- Prefer functional programming paradigms where appropriate.
479- All code should be compatible with TypeScript 5.0 and Node.js 20+.
480 
481## Coding Style:
482 
483- Use 2 spaces for indentation.
484- Interface names should be prefixed with `I` (e.g., `IUserService`).
485- Private class members should be prefixed with an underscore (`_`).
486- Always use strict equality (`===` and `!==`).
487 
488## Specific Component: `src/api/client.ts`
489 
490- This file handles all outbound API requests.
491- When adding new API call functions, ensure they include robust error handling and logging.
492- Use the existing `fetchWithRetry` utility for all GET requests.
493 
494## Regarding Dependencies:
495 
496- Avoid introducing new external dependencies unless absolutely necessary.
497- If a new dependency is required, please state the reason.
498```
499 
500This 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.
501 
502- **Hierarchical Loading and Precedence:** The CLI implements a sophisticated hierarchical memory system by loading context files (e.g., `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:
503 1. **Global Context File:**
504 - Location: `~/.gemini/<contextFileName>` (e.g., `~/.gemini/GEMINI.md` in your user home directory).
505 - Scope: Provides default instructions for all your projects.
506 2. **Project Root & Ancestors Context Files:**
507 - Location: The CLI searches for the configured context file in the current working directory and then in each parent directory up to either the git repository root or the user's home directory.
508 - Scope: Provides project-specific context, with files closer to your current directory taking higher precedence.
509 3. **Include Directories Context Files (if configured):**
510 - Location: Context files from directories specified in `includeDirectories` setting (controlled by `loadMemoryFromIncludeDirectories` setting).
511 - Scope: Additional project context from related directories.
512 
513### Context File Management Commands
 
 
 
 
 
 
 
514 
515The CLI provides several commands to help you manage and understand your context:
516 
517- **`/memory show`**: Displays the full context that will be provided to the model, including all loaded context files and their sources.
518- **`/memory refresh`**: Reloads all context files from disk, useful when you've made changes to context files during a session.
519- **`/memory clear`**: Temporarily clears the loaded context for the current session (context will be reloaded on next session).
520 
521### Best Practices for Context Files
 
 
 
 
522 
5231. **Keep it Relevant:** Include information that's directly useful for the tasks you'll be performing with the AI.
5242. **Be Specific:** Provide concrete examples and guidelines rather than vague descriptions.
5253. **Update Regularly:** Keep your context files current with your project's evolution.
5264. **Use Hierarchy:** Place general guidelines in higher-level context files and specific details in project-specific files.
5275. **Test and Iterate:** Use `/memory show` to verify your context is loading correctly and refine based on the AI's responses.
528 
529## Usage Statistics
 
 
 
530 
531Gemini CLI can collect anonymous usage statistics to help improve the tool. This data includes information about command usage, error rates, and performance metrics, but does not include sensitive information like your code, prompts, or personal data.
532 
533- **Control:** You can enable or disable usage statistics collection using the `usageStatisticsEnabled` setting in your `settings.json` file.
534- **Privacy:** All collected data is anonymized and aggregated. No personally identifiable information or code content is collected.
535- **Transparency:** The CLI will inform you when usage statistics are being collected and provide options to opt out.
 
536 
537## Sandboxing
 
 
 
538 
539Sandboxing provides an additional layer of security when using Gemini CLI by isolating tool execution from your main system. This is particularly useful when working with untrusted code or when you want to limit the potential impact of AI-generated commands.
 
 
 
540 
541### Types of Sandboxing
542 
5431. **Docker Sandboxing** (`"sandbox": "docker"`):
544 - Uses Docker containers to isolate tool execution
545 - Requires Docker to be installed and running
546 - Provides strong isolation from the host system
547 
5482. **Podman Sandboxing** (`"sandbox": "podman"`):
549 - Similar to Docker but uses Podman as the container runtime
550 - Useful in environments where Docker is not available
551 
5523. **Custom Sandboxing** (`"sandbox": "custom-command"`):
553 - Allows you to specify a custom sandboxing command
554 - Provides flexibility for specialized environments
555 
556### Configuration
557 
558You can enable sandboxing through:
559- Settings file: `"sandbox": true` or `"sandbox": "docker"`
560- Environment variable: `GEMINI_SANDBOX=true`
561- Command line: `--sandbox` flag
562 
563### Custom Sandbox Profiles
564 
565For advanced users, you can create custom sandbox profiles by placing configuration files in your project's `.gemini/` directory:
566 
567- **Docker:** `.gemini/sandbox.Dockerfile`
568- **macOS Seatbelt:** `.gemini/sandbox-macos-<profile_name>.sb`
569 
570These custom profiles allow you to define specific security policies and runtime environments for your project's needs.
@@ −1 +1 @@
1−# Megarepo - AI Setup Repository
1+# Gemini CLI Configuration
22  
3−**ALWAYS follow these instructions first and only fallback to additional search and context gathering if the information here is incomplete or found to be in error.**
3+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.
44  
5−## Repository Overview
5+## Configuration layers
66  
7−Megarepo is currently a minimal repository template designed for AI-related projects. The repository contains basic setup files and is configured for Node.js/Next.js development based on the .gitignore patterns.
7+Configuration is applied in the following order of precedence (lower numbers are overridden by higher numbers):
88  
9−## Current Repository State
9+1. **Default values:** Hardcoded defaults within the application.
10+2. **User settings file:** Global settings for the current user.
11+3. **Project settings file:** Project-specific settings.
12+4. **System settings file:** System-wide settings.
13+5. **Environment variables:** System-wide or session-specific variables, potentially loaded from `.env` files.
14+6. **Command-line arguments:** Values passed when launching the CLI.
1015  
11−**IMPORTANT**: This repository is currently in a minimal state with only basic setup files:
12−- README.md (basic project description)
13−- LICENSE (MIT license)
14−- .gitignore (configured for Node.js/Next.js projects)
16+## Settings files
1517  
16−**DO NOT attempt to build, test, or run code** - there is no source code or build system present yet.
18+Gemini CLI uses `settings.json` files for persistent configuration. There are three locations for these files:
1719  
18−## Working Effectively
20+- **User settings file:**
21+ - **Location:** `~/.gemini/settings.json` (where `~` is your home directory).
22+ - **Scope:** Applies to all Gemini CLI sessions for the current user.
23+- **Project settings file:**
24+ - **Location:** `.gemini/settings.json` within your project's root directory.
25+ - **Scope:** Applies only when running Gemini CLI from that specific project. Project settings override user settings.
26+- **System settings file:**
27+ - **Location:** `/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.
28+ - **Scope:** Applies to all Gemini CLI sessions on the system, for all users. System settings override user and project settings. May be useful for system administrators at enterprises to have controls over users' Gemini CLI setups.
1929  
20−### Initial Repository Exploration
21−```bash
22−# Always start by understanding the current repository state
23−ls -la
24−git status
25−find . -type f -name "*.json" -o -name "*.js" -o -name "*.ts" -o -name "*.md"
26−```
30+**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"`.
2731  
28−### When Source Code is Added
32+### The `.gemini` directory in your project
2933  
30−The repository is pre-configured for Node.js/Next.js development. When source code is added, follow these patterns:
34+In 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:
3135  
32−#### Node.js/Next.js Project Setup
33−```bash
34−# Check for package.json first
35−ls package.json
36+- [Custom sandbox profiles](#sandboxing) (e.g., `.gemini/sandbox-macos-custom.sb`, `.gemini/sandbox.Dockerfile`).
3637  
37−# If package.json exists, install dependencies
38−npm install
39−# NEVER CANCEL: npm install typically takes 2-5 minutes. Set timeout to 10+ minutes.
38+### Available settings in `settings.json`:
4039  
41−# Common build commands (verify these exist in package.json first)
42−npm run build
43−# NEVER CANCEL: Build may take 5-45 minutes depending on project size. Set timeout to 60+ minutes.
40+- **`contextFileName`** (string or array of strings):
41+ - **Description:** Specifies the filename for context files (e.g., `GEMINI.md`, `AGENTS.md`). Can be a single filename or a list of accepted filenames.
42+ - **Default:** `GEMINI.md`
43+ - **Example:** `"contextFileName": "AGENTS.md"`
4444  
45−# Common test commands
46−npm test
47−# NEVER CANCEL: Tests may take 5-15 minutes. Set timeout to 30+ minutes.
45+- **`bugCommand`** (object):
46+ - **Description:** Overrides the default URL for the `/bug` command.
47+ - **Default:** `"urlTemplate": "https://github.com/google-gemini/gemini-cli/issues/new?template=bug_report.yml&title={title}&info={info}"`
48+ - **Properties:**
49+ - **`urlTemplate`** (string): A URL that can contain `{title}` and `{info}` placeholders.
50+ - **Example:**
51+ ```json
52+ "bugCommand": {
53+ "urlTemplate": "https://bug.example.com/new?title={title}&info={info}"
54+ }
55+ ```
4856  
49−# Common development server
50−npm run dev
51−```
57+- **`fileFiltering`** (object):
58+ - **Description:** Controls git-aware file filtering behavior for @ commands and file discovery tools.
59+ - **Default:** `"respectGitIgnore": true, "enableRecursiveFileSearch": true`
60+ - **Properties:**
61+ - **`respectGitIgnore`** (boolean): Whether to respect .gitignore patterns when discovering files. When set to `true`, git-ignored files (like `node_modules/`, `dist/`, `.env`) are automatically excluded from @ commands and file listing operations.
62+ - **`enableRecursiveFileSearch`** (boolean): Whether to enable searching recursively for filenames under the current tree when completing @ prefixes in the prompt.
63+ - **Example:**
64+ ```json
65+ "fileFiltering": {
66+ "respectGitIgnore": true,
67+ "enableRecursiveFileSearch": false
68+ }
69+ ```
5270  
53−#### Pre-commit Validation
54−When source code exists, always run these before committing:
55−```bash
56−# Check for linting configuration
57−ls .eslintrc* eslint.config.* .prettierrc*
71+- **`coreTools`** (array of strings):
72+ - **Description:** Allows you to specify a list of core tool names that should be made available to the model. This can be used to restrict the set of built-in tools. See [Built-in Tools](../core/tools-api.md#built-in-tools) for a list of core tools. You can also specify command-specific restrictions for tools that support it, like the `ShellTool`. For example, `"coreTools": ["ShellTool(ls -l)"]` will only allow the `ls -l` command to be executed.
73+ - **Default:** All tools available for use by the Gemini model.
74+ - **Example:** `"coreTools": ["ReadFileTool", "GlobTool", "ShellTool(ls)"]`.
5875  
59−# Run linting if configured
60−npm run lint
76+- **`excludeTools`** (array of strings):
77+ - **Description:** Allows you to specify a list of core tool names that should be excluded from the model. A tool listed in both `excludeTools` and `coreTools` is excluded. You can also specify command-specific restrictions for tools that support it, like the `ShellTool`. For example, `"excludeTools": ["ShellTool(rm -rf)"]` will block the `rm -rf` command.
78+ - **Default**: No tools excluded.
79+ - **Example:** `"excludeTools": ["run_shell_command", "findFiles"]`.
80+ - **Security Note:** Command-specific restrictions in
81+ `excludeTools` for `run_shell_command` are based on simple string matching and can be easily bypassed. This feature is **not a security mechanism** and should not be relied upon to safely execute untrusted code. It is recommended to use `coreTools` to explicitly select commands
82+ that can be executed.
6183  
62−# Run formatting if configured
63−npm run format
84+- **`allowMCPServers`** (array of strings):
85+ - **Description:** Allows you to specify a list of MCP server names that should be made available to the model. This can be used to restrict the set of MCP servers to connect to. Note that this will be ignored if `--allowed-mcp-server-names` is set.
86+ - **Default:** All MCP servers are available for use by the Gemini model.
87+ - **Example:** `"allowMCPServers": ["myPythonServer"]`.
88+ - **Security Note:** This uses simple string matching on MCP server names, which can be modified. If you're a system administrator looking to prevent users from bypassing this, consider configuring the `mcpServers` at the system settings level such that the user will not be able to configure any MCP servers of their own. This should not be used as an airtight security mechanism.
6489  
65−# Run type checking if TypeScript
66−npm run type-check
67−```
90+- **`excludeMCPServers`** (array of strings):
91+ - **Description:** Allows you to specify a list of MCP server names that should be excluded from the model. A server listed in both `excludeMCPServers` and `allowMCPServers` is excluded. Note that this will be ignored if `--allowed-mcp-server-names` is set.
92+ - **Default**: No MCP servers excluded.
93+ - **Example:** `"excludeMCPServers": ["myNodeServer"]`.
94+ - **Security Note:** This uses simple string matching on MCP server names, which can be modified. If you're a system administrator looking to prevent users from bypassing this, consider configuring the `mcpServers` at the system settings level such that the user will not be able to configure any MCP servers of their own. This should not be used as an airtight security mechanism.
6895  
69−## Repository Structure Expectations
96+- **`autoAccept`** (boolean):
97+ - **Description:** Controls whether the CLI automatically accepts and executes tool calls that are considered safe (e.g., read-only operations) without explicit user confirmation. If set to `true`, the CLI will bypass the confirmation prompt for tools deemed safe.
98+ - **Default:** `false`
99+ - **Example:** `"autoAccept": true`
70100  
71−Based on the .gitignore configuration, expect the following when the repository is populated:
101+- **`theme`** (string):
102+ - **Description:** Sets the visual [theme](./themes.md) for Gemini CLI.
103+ - **Default:** `"Default"`
104+ - **Example:** `"theme": "GitHub"`
72105  
73−```
74−.
75−├── README.md # Project documentation
76−├── LICENSE # MIT license
77−├── .gitignore # Node.js/Next.js ignore patterns
78−├── package.json # Node.js dependencies and scripts
79−├── package-lock.json # Dependency lockfile
80−├── next.config.js # Next.js configuration (if Next.js)
81−├── tsconfig.json # TypeScript configuration (if TypeScript)
82−├── .eslintrc.* # ESLint configuration
83−├── .prettierrc # Prettier configuration
84−├── src/ # Source code directory
85−│ ├── pages/ # Next.js pages (if Next.js)
86−│ ├── components/ # React components
87−│ └── utils/ # Utility functions
88−├── public/ # Static assets
89−├── .next/ # Next.js build output (ignored)
90−├── build/ # Build output (ignored)
91−└── node_modules/ # Dependencies (ignored)
92−```
106+- **`vimMode`** (boolean):
107+ - **Description:** Enables or disables vim mode for input editing. When enabled, the input area supports vim-style navigation and editing commands with NORMAL and INSERT modes. The vim mode status is displayed in the footer and persists between sessions.
108+ - **Default:** `false`
109+ - **Example:** `"vimMode": true`
93110  
94−## Validation Requirements
111+- **`sandbox`** (boolean or string):
112+ - **Description:** Controls whether and how to use sandboxing for tool execution. If set to `true`, Gemini CLI uses a pre-built `gemini-cli-sandbox` Docker image. For more information, see [Sandboxing](#sandboxing).
113+ - **Default:** `false`
114+ - **Example:** `"sandbox": "docker"`
95115  
96−### Before Making Changes
97−1. **Always check current repository state first**:
98− ```bash
99− git status
100− ls -la
101− cat package.json # Only if it exists
102− ```
116+- **`toolDiscoveryCommand`** (string):
117+ - **Description:** Defines a custom shell command for discovering tools from your project. The shell command must return on `stdout` a JSON array of [function declarations](https://ai.google.dev/gemini-api/docs/function-calling#function-declarations). Tool wrappers are optional.
118+ - **Default:** Empty
119+ - **Example:** `"toolDiscoveryCommand": "bin/get_tools"`
103120  
104−2. **Verify build system exists before attempting builds**:
105− ```bash
106− # Check for package.json before running npm commands
107− test -f package.json && echo "Node.js project detected" || echo "No package.json found"
108− ```
121+- **`toolCallCommand`** (string):
122+ - **Description:** Defines a custom shell command for calling a specific tool that was discovered using `toolDiscoveryCommand`. The shell command must meet the following criteria:
123+ - It must take function `name` (exactly as in [function declaration](https://ai.google.dev/gemini-api/docs/function-calling#function-declarations)) as first command line argument.
124+ - It must read function arguments as JSON on `stdin`, analogous to [`functionCall.args`](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference#functioncall).
125+ - It must return function output as JSON on `stdout`, analogous to [`functionResponse.response.content`](https://cloud.google.com/vertex-ai/generative-ai/docs/model-reference/inference#functionresponse).
126+ - **Default:** Empty
127+ - **Example:** `"toolCallCommand": "bin/call_tool"`
109128  
110−### After Making Changes
111−1. **When source code is present, always validate**:
112− ```bash
113− # Install dependencies if package.json exists
114− test -f package.json && npm install
115−
116− # Build if build script exists
117− test -f package.json && npm run build
118−
119− # Test if test script exists
120− test -f package.json && npm test
121−
122− # Lint if lint script exists
123− test -f package.json && npm run lint
124− ```
129+- **`mcpServers`** (object):
130+ - **Description:** Configures 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.
131+ - **Default:** Empty
132+ - **Properties:**
133+ - **`<SERVER_NAME>`** (object): The server parameters for the named server.
134+ - `command` (string, required): The command to execute to start the MCP server.
135+ - `args` (array of strings, optional): Arguments to pass to the command.
136+ - `env` (object, optional): Environment variables to set for the server process.
137+ - `cwd` (string, optional): The working directory in which to start the server.
138+ - `timeout` (number, optional): Timeout in milliseconds for requests to this MCP server.
139+ - `trust` (boolean, optional): Trust this server and bypass all tool call confirmations.
140+ - `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 (whitelist behavior). If not specified, all tools from the server are enabled by default.
141+ - `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.
142+ - **Example:**
143+ ```json
144+ "mcpServers": {
145+ "myPythonServer": {
146+ "command": "python",
147+ "args": ["mcp_server.py", "--port", "8080"],
148+ "cwd": "./mcp_tools/python",
149+ "timeout": 5000,
150+ "includeTools": ["safe_tool", "file_reader"],
151+ },
152+ "myNodeServer": {
153+ "command": "node",
154+ "args": ["mcp_server.js"],
155+ "cwd": "./mcp_tools/node",
156+ "excludeTools": ["dangerous_tool", "file_deleter"]
157+ },
158+ "myDockerServer": {
159+ "command": "docker",
160+ "args": ["run", "-i", "--rm", "-e", "API_KEY", "ghcr.io/foo/bar"],
161+ "env": {
162+ "API_KEY": "$MY_API_TOKEN"
163+ }
164+ }
165+ }
166+ ```
125167  
126−2. **Manual validation scenarios when application exists**:
127− - Start the development server and verify it loads
128− - Test basic functionality by navigating through the application
129− - Verify any API endpoints respond correctly
130− - Check console for errors
168+- **`checkpointing`** (object):
169+ - **Description:** Configures the checkpointing feature, which allows you to save and restore conversation and file states. See the [Checkpointing documentation](../checkpointing.md) for more details.
170+ - **Default:** `{"enabled": false}`
171+ - **Properties:**
172+ - **`enabled`** (boolean): When `true`, the `/restore` command is available.
131173  
132−## Common Commands Reference
174+- **`preferredEditor`** (string):
175+ - **Description:** Specifies the preferred editor to use for viewing diffs.
176+ - **Default:** `vscode`
177+ - **Example:** `"preferredEditor": "vscode"`
133178  
134−### Repository Information
135−```bash
136−# View current files
137−ls -la
179+- **`telemetry`** (object)
180+ - **Description:** Configures logging and metrics collection for Gemini CLI. For more information, see [Telemetry](../telemetry.md).
181+ - **Default:** `{"enabled": false, "target": "local", "otlpEndpoint": "http://localhost:4317", "logPrompts": true}`
182+ - **Properties:**
183+ - **`enabled`** (boolean): Whether or not telemetry is enabled.
184+ - **`target`** (string): The destination for collected telemetry. Supported values are `local` and `gcp`.
185+ - **`otlpEndpoint`** (string): The endpoint for the OTLP Exporter.
186+ - **`logPrompts`** (boolean): Whether or not to include the content of user prompts in the logs.
187+ - **Example:**
188+ ```json
189+ "telemetry": {
190+ "enabled": true,
191+ "target": "local",
192+ "otlpEndpoint": "http://localhost:16686",
193+ "logPrompts": false
194+ }
195+ ```
196+- **`usageStatisticsEnabled`** (boolean):
197+ - **Description:** Enables or disables the collection of usage statistics. See [Usage Statistics](#usage-statistics) for more information.
198+ - **Default:** `true`
199+ - **Example:**
200+ ```json
201+ "usageStatisticsEnabled": false
202+ ```
138203  
139−# Check git status
140−git status
204+- **`hideTips`** (boolean):
205+ - **Description:** Enables or disables helpful tips in the CLI interface.
206+ - **Default:** `false`
207+ - **Example:**
141208  
142−# View repository structure
143−tree . -a -I 'node_modules|.git' # If tree is available (use -a to show hidden files)
144−find . -type f -not -path "./.git/*" -not -path "./node_modules/*" | sort
209+ ```json
210+ "hideTips": true
211+ ```
212+ 
213+- **`hideBanner`** (boolean):
214+ - **Description:** Enables or disables the startup banner (ASCII art logo) in the CLI interface.
215+ - **Default:** `false`
216+ - **Example:**
217+ 
218+ ```json
219+ "hideBanner": true
220+ ```
221+ 
222+- **`maxSessionTurns`** (number):
223+ - **Description:** Sets the maximum number of turns for a session. If the session exceeds this limit, the CLI will stop processing and start a new chat.
224+ - **Default:** `-1` (unlimited)
225+ - **Example:**
226+ ```json
227+ "maxSessionTurns": 10
228+ ```
229+ 
230+- **`summarizeToolOutput`** (object):
231+ - **Description:** Enables or disables the summarization of tool output. You can specify the token budget for the summarization using the `tokenBudget` setting.
232+ - Note: Currently only the `run_shell_command` tool is supported.
233+ - **Default:** `{}` (Disabled by default)
234+ - **Example:**
235+ ```json
236+ "summarizeToolOutput": {
237+ "run_shell_command": {
238+ "tokenBudget": 2000
239+ }
240+ }
241+ ```
242+ 
243+- **`excludedProjectEnvVars`** (array of strings):
244+ - **Description:** Specifies environment variables that should be excluded from being loaded from project `.env` files. This prevents project-specific environment variables (like `DEBUG=true`) from interfering with gemini-cli behavior. Variables from `.gemini/.env` files are never excluded.
245+ - **Default:** `["DEBUG", "DEBUG_MODE"]`
246+ - **Example:**
247+ ```json
248+ "excludedProjectEnvVars": ["DEBUG", "DEBUG_MODE", "NODE_ENV"]
249+ ```
250+ 
251+- **`includeDirectories`** (array of strings):
252+ - **Description:** Specifies an array of additional absolute or relative paths to include in the workspace context. This allows you to work with files across multiple directories as if they were one. Paths can use `~` to refer to the user's home directory. This setting can be combined with the `--include-directories` command-line flag.
253+ - **Default:** `[]`
254+ - **Example:**
255+ ```json
256+ "includeDirectories": [
257+ "/path/to/another/project",
258+ "../shared-library",
259+ "~/common-utils"
260+ ]
261+ ```
262+ 
263+- **`loadMemoryFromIncludeDirectories`** (boolean):
264+ - **Description:** Controls the behavior of the `/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.
265+ - **Default:** `false`
266+ - **Example:**
267+ ```json
268+ "loadMemoryFromIncludeDirectories": true
269+ ```
270+ 
271+- **`chatCompression`** (object):
272+ - **Description:** Controls the settings for chat history compression, both automatic and
273+ when manually invoked through the /compress command.
274+ - **Properties:**
275+ - **`contextPercentageThreshold`** (number): A value between 0 and 1 that specifies the token threshold for compression as a percentage of the model's total token limit. For example, a value of `0.6` will trigger compression when the chat history exceeds 60% of the token limit.
276+ - **Example:**
277+ ```json
278+ "chatCompression": {
279+ "contextPercentageThreshold": 0.6
280+ }
281+ ```
282+ 
283+- **`showLineNumbers`** (boolean):
284+ - **Description:** Controls whether line numbers are displayed in code blocks in the CLI output.
285+ - **Default:** `true`
286+ - **Example:**
287+ ```json
288+ "showLineNumbers": false
289+ ```
290+ 
291+### Example `settings.json`:
292+ 
293+```json
294+{
295+ "theme": "GitHub",
296+ "sandbox": "docker",
297+ "toolDiscoveryCommand": "bin/get_tools",
298+ "toolCallCommand": "bin/call_tool",
299+ "mcpServers": {
300+ "mainServer": {
301+ "command": "bin/mcp_server.py"
302+ },
303+ "anotherServer": {
304+ "command": "node",
305+ "args": ["mcp_server.js", "--verbose"]
306+ }
307+ },
308+ "telemetry": {
309+ "enabled": true,
310+ "target": "local",
311+ "otlpEndpoint": "http://localhost:4317",
312+ "logPrompts": true
313+ },
314+ "usageStatisticsEnabled": true,
315+ "hideTips": false,
316+ "hideBanner": false,
317+ "maxSessionTurns": 10,
318+ "summarizeToolOutput": {
319+ "run_shell_command": {
320+ "tokenBudget": 100
321+ }
322+ },
323+ "excludedProjectEnvVars": ["DEBUG", "DEBUG_MODE", "NODE_ENV"],
324+ "includeDirectories": ["path/to/dir1", "~/path/to/dir2", "../path/to/dir3"],
325+ "loadMemoryFromIncludeDirectories": true
326+}
145327 ```
146328  
147−### When Package.json Exists
148−```bash
149−# View available scripts
150−cat package.json | grep -A 20 '"scripts"'
329+## Shell History
151330  
152−# Install dependencies
153−npm install
154−# TIMEOUT: 10+ minutes
331+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.
155332  
156−# Common development commands (check package.json first)
157−npm run dev # Development server
158−npm run build # Production build
159−npm run start # Start production server
160−npm run test # Run tests
161−npm run lint # Run linter
162−npm run format # Format code
333+- **Location:** `~/.gemini/tmp/<project_hash>/shell_history`
334+ - `<project_hash>` is a unique identifier generated from your project's root path.
335+ - The history is stored in a file named `shell_history`.
336+ 
337+## Environment Variables & `.env` Files
338+ 
339+Environment variables are a common way to configure applications, especially for sensitive information like API keys or for settings that might change between environments.
340+ 
341+The CLI automatically loads environment variables from an `.env` file. The loading order is:
342+ 
343+1. `.env` file in the current working directory.
344+2. If not found, it searches upwards in parent directories until it finds an `.env` file or reaches the project root (identified by a `.git` folder) or the home directory.
345+3. If still not found, it looks for `~/.env` (in the user's home directory).
346+ 
347+**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 `excludedProjectEnvVars` setting in your `settings.json` file.
348+ 
349+- **`GEMINI_API_KEY`** (Required):
350+ - Your API key for the Gemini API.
351+ - **Crucial for operation.** The CLI will not function without it.
352+ - Set this in your shell profile (e.g., `~/.bashrc`, `~/.zshrc`) or an `.env` file.
353+- **`GEMINI_MODEL`**:
354+ - Specifies the default Gemini model to use.
355+ - Overrides the hardcoded default
356+ - Example: `export GEMINI_MODEL="gemini-2.5-flash"`
357+- **`GOOGLE_API_KEY`**:
358+ - Your Google Cloud API key.
359+ - Required for using Vertex AI in express mode.
360+ - Ensure you have the necessary permissions.
361+ - Example: `export GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY"`.
362+- **`GOOGLE_CLOUD_PROJECT`**:
363+ - Your Google Cloud Project ID.
364+ - Required for using Code Assist or Vertex AI.
365+ - If using Vertex AI, ensure you have the necessary permissions in this project.
366+ - **Cloud Shell Note:** When running in a Cloud Shell environment, this variable defaults to a special project allocated for Cloud Shell users. If you have `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.
367+ - Example: `export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"`.
368+- **`GOOGLE_APPLICATION_CREDENTIALS`** (string):
369+ - **Description:** The path to your Google Application Credentials JSON file.
370+ - **Example:** `export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/credentials.json"`
371+- **`OTLP_GOOGLE_CLOUD_PROJECT`**:
372+ - Your Google Cloud Project ID for Telemetry in Google Cloud
373+ - Example: `export OTLP_GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_ID"`.
374+- **`GOOGLE_CLOUD_LOCATION`**:
375+ - Your Google Cloud Project Location (e.g., us-central1).
376+ - Required for using Vertex AI in non express mode.
377+ - Example: `export GOOGLE_CLOUD_LOCATION="YOUR_PROJECT_LOCATION"`.
378+- **`GEMINI_SANDBOX`**:
379+ - Alternative to the `sandbox` setting in `settings.json`.
380+ - Accepts `true`, `false`, `docker`, `podman`, or a custom command string.
381+- **`SEATBELT_PROFILE`** (macOS specific):
382+ - Switches the Seatbelt (`sandbox-exec`) profile on macOS.
383+ - `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.
384+ - `strict`: Uses a strict profile that declines operations by default.
385+ - `<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`).
386+- **`DEBUG` or `DEBUG_MODE`** (often used by underlying libraries or the CLI itself):
387+ - Set to `true` or `1` to enable verbose debug logging, which can be helpful for troubleshooting.
388+ - **Note:** These variables are automatically excluded from project `.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.
389+- **`NO_COLOR`**:
390+ - Set to any value to disable all color output in the CLI.
391+- **`CLI_TITLE`**:
392+ - Set to a string to customize the title of the CLI.
393+- **`CODE_ASSIST_ENDPOINT`**:
394+ - Specifies the endpoint for the code assist server.
395+ - This is useful for development and testing.
396+ 
397+## Command-Line Arguments
398+ 
399+Arguments passed directly when running the CLI can override other configurations for that specific session.
400+ 
401+- **`--model <model_name>`** (**`-m <model_name>`**):
402+ - Specifies the Gemini model to use for this session.
403+ - Example: `npm start -- --model gemini-1.5-pro-latest`
404+- **`--prompt <your_prompt>`** (**`-p <your_prompt>`**):
405+ - Used to pass a prompt directly to the command. This invokes Gemini CLI in a non-interactive mode.
406+- **`--prompt-interactive <your_prompt>`** (**`-i <your_prompt>`**):
407+ - Starts an interactive session with the provided prompt as the initial input.
408+ - The prompt is processed within the interactive session, not before it.
409+ - Cannot be used when piping input from stdin.
410+ - Example: `gemini -i "explain this code"`
411+- **`--sandbox`** (**`-s`**):
412+ - Enables sandbox mode for this session.
413+- **`--sandbox-image`**:
414+ - Sets the sandbox image URI.
415+- **`--debug`** (**`-d`**):
416+ - Enables debug mode for this session, providing more verbose output.
417+- **`--all-files`** (**`-a`**):
418+ - If set, recursively includes all files within the current directory as context for the prompt.
419+- **`--help`** (or **`-h`**):
420+ - Displays help information about command-line arguments.
421+- **`--show-memory-usage`**:
422+ - Displays the current memory usage.
423+- **`--yolo`**:
424+ - Enables YOLO mode, which automatically approves all tool calls.
425+- **`--approval-mode <mode>`**:
426+ - Sets the approval mode for tool calls. Available modes:
427+ - `default`: Prompt for approval on each tool call (default behavior)
428+ - `auto_edit`: Automatically approve edit tools (replace, write_file) while prompting for others
429+ - `yolo`: Automatically approve all tool calls (equivalent to `--yolo`)
430+ - Cannot be used together with `--yolo`. Use `--approval-mode=yolo` instead of `--yolo` for the new unified approach.
431+ - Example: `gemini --approval-mode auto_edit`
432+- **`--telemetry`**:
433+ - Enables [telemetry](../telemetry.md).
434+- **`--telemetry-target`**:
435+ - Sets the telemetry target. See [telemetry](../telemetry.md) for more information.
436+- **`--telemetry-otlp-endpoint`**:
437+ - Sets the OTLP endpoint for telemetry. See [telemetry](../telemetry.md) for more information.
438+- **`--telemetry-otlp-protocol`**:
439+ - Sets the OTLP protocol for telemetry (`grpc` or `http`). Defaults to `grpc`. See [telemetry](../telemetry.md) for more information.
440+- **`--telemetry-log-prompts`**:
441+ - Enables logging of prompts for telemetry. See [telemetry](../telemetry.md) for more information.
442+- **`--checkpointing`**:
443+ - Enables [checkpointing](../checkpointing.md).
444+- **`--extensions <extension_name ...>`** (**`-e <extension_name ...>`**):
445+ - Specifies a list of extensions to use for the session. If not provided, all available extensions are used.
446+ - Use the special term `gemini -e none` to disable all extensions.
447+ - Example: `gemini -e my-extension -e my-other-extension`
448+- **`--list-extensions`** (**`-l`**):
449+ - Lists all available extensions and exits.
450+- **`--proxy`**:
451+ - Sets the proxy for the CLI.
452+ - Example: `--proxy http://localhost:7890`.
453+- **`--include-directories <dir1,dir2,...>`**:
454+ - Includes additional directories in the workspace for multi-directory support.
455+ - Can be specified multiple times or as comma-separated values.
456+ - 5 directories can be added at maximum.
457+ - Example: `--include-directories /path/to/project1,/path/to/project2` or `--include-directories /path/to/project1 --include-directories /path/to/project2`
458+- **`--version`**:
459+ - Displays the version of the CLI.
460+ 
461+## Context Files (Hierarchical Instructional Context)
462+ 
463+While not strictly configuration for the CLI's _behavior_, context files (defaulting to `GEMINI.md` but configurable via the `contextFileName` 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.
464+ 
465+- **Purpose:** These Markdown files contain instructions, guidelines, or context that you want the Gemini model to be aware of during your interactions. The system is designed to manage this instructional context hierarchically.
466+ 
467+### Example Context File Content (e.g., `GEMINI.md`)
468+ 
469+Here's a conceptual example of what a context file at the root of a TypeScript project might contain:
470+ 
471+```markdown
472+# Project: My Awesome TypeScript Library
473+ 
474+## General Instructions:
475+ 
476+- When generating new TypeScript code, please follow the existing coding style.
477+- Ensure all new functions and classes have JSDoc comments.
478+- Prefer functional programming paradigms where appropriate.
479+- All code should be compatible with TypeScript 5.0 and Node.js 20+.
480+ 
481+## Coding Style:
482+ 
483+- Use 2 spaces for indentation.
484+- Interface names should be prefixed with `I` (e.g., `IUserService`).
485+- Private class members should be prefixed with an underscore (`_`).
486+- Always use strict equality (`===` and `!==`).
487+ 
488+## Specific Component: `src/api/client.ts`
489+ 
490+- This file handles all outbound API requests.
491+- When adding new API call functions, ensure they include robust error handling and logging.
492+- Use the existing `fetchWithRetry` utility for all GET requests.
493+ 
494+## Regarding Dependencies:
495+ 
496+- Avoid introducing new external dependencies unless absolutely necessary.
497+- If a new dependency is required, please state the reason.
163498 ```
164499  
165−## File Locations and Navigation
500+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.
166501  
167−### Current Key Files
168−- `/README.md` - Project overview and setup instructions
169−- `/LICENSE` - MIT license terms
170−- `/.gitignore` - Git ignore patterns (Node.js/Next.js focused)
502+- **Hierarchical Loading and Precedence:** The CLI implements a sophisticated hierarchical memory system by loading context files (e.g., `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:
503+ 1. **Global Context File:**
504+ - Location: `~/.gemini/<contextFileName>` (e.g., `~/.gemini/GEMINI.md` in your user home directory).
505+ - Scope: Provides default instructions for all your projects.
506+ 2. **Project Root & Ancestors Context Files:**
507+ - Location: The CLI searches for the configured context file in the current working directory and then in each parent directory up to either the git repository root or the user's home directory.
508+ - Scope: Provides project-specific context, with files closer to your current directory taking higher precedence.
509+ 3. **Include Directories Context Files (if configured):**
510+ - Location: Context files from directories specified in `includeDirectories` setting (controlled by `loadMemoryFromIncludeDirectories` setting).
511+ - Scope: Additional project context from related directories.
171512  
172−### Expected Important Locations (when populated)
173−- `/src/` - Main source code directory
174−- `/src/pages/` - Next.js pages (if Next.js project)
175−- `/src/components/` - React components
176−- `/public/` - Static assets and files
177−- `/package.json` - Project configuration and dependencies
178−- `/next.config.js` - Next.js configuration
179−- `/tsconfig.json` - TypeScript configuration
513+### Context File Management Commands
180514  
181−## AI Development Guidelines
515+The CLI provides several commands to help you manage and understand your context:
182516  
183−Since this is an AI setup repository:
517+- **`/memory show`**: Displays the full context that will be provided to the model, including all loaded context files and their sources.
518+- **`/memory refresh`**: Reloads all context files from disk, useful when you've made changes to context files during a session.
519+- **`/memory clear`**: Temporarily clears the loaded context for the current session (context will be reloaded on next session).
184520  
185−1. **Always verify AI-related dependencies** when they are added:
186− ```bash
187− # Common AI packages to look for
188− grep -E "(openai|langchain|tensorflow|pytorch|huggingface)" package.json
189− ```
521+### Best Practices for Context Files
190522  
191−2. **Environment variables for AI services**:
192− ```bash
193− # Check for environment configuration
194− ls .env* || echo "No environment files found"
195− ```
523+1. **Keep it Relevant:** Include information that's directly useful for the tasks you'll be performing with the AI.
524+2. **Be Specific:** Provide concrete examples and guidelines rather than vague descriptions.
525+3. **Update Regularly:** Keep your context files current with your project's evolution.
526+4. **Use Hierarchy:** Place general guidelines in higher-level context files and specific details in project-specific files.
527+5. **Test and Iterate:** Use `/memory show` to verify your context is loading correctly and refine based on the AI's responses.
196528  
197−3. **API key management**:
198− - Never commit API keys
199− - Always use environment variables
200− - Check .env.example for required variables
529+## Usage Statistics
201530  
202−## Troubleshooting
531+Gemini CLI can collect anonymous usage statistics to help improve the tool. This data includes information about command usage, error rates, and performance metrics, but does not include sensitive information like your code, prompts, or personal data.
203532  
204−### Repository Appears Empty
205−- This is expected in the current state
206−- Check git branch: `git branch -a`
207−- Look for other branches that might contain code
533+- **Control:** You can enable or disable usage statistics collection using the `usageStatisticsEnabled` setting in your `settings.json` file.
534+- **Privacy:** All collected data is anonymized and aggregated. No personally identifiable information or code content is collected.
535+- **Transparency:** The CLI will inform you when usage statistics are being collected and provide options to opt out.
208536  
209−### Build Failures
210−- First verify package.json exists: `ls package.json`
211−- Clear dependencies and reinstall: `rm -rf node_modules package-lock.json && npm install`
212−- Check Node.js version compatibility in package.json
537+## Sandboxing
213538  
214−### Development Server Issues
215−- Verify port availability (typically 3000 for Next.js)
216−- Check for environment variable requirements
217−- Review console output for specific error messages
539+Sandboxing provides an additional layer of security when using Gemini CLI by isolating tool execution from your main system. This is particularly useful when working with untrusted code or when you want to limit the potential impact of AI-generated commands.
218540  
219−## Critical Reminders
541+### Types of Sandboxing
220542  
221−- **NEVER CANCEL builds or long-running commands** - they may take 45+ minutes
222−- **ALWAYS validate commands work** before assuming functionality exists
223−- **CHECK for package.json** before running npm commands
224−- **SET APPROPRIATE TIMEOUTS** - builds: 60+ minutes, tests: 30+ minutes
225−- **VERIFY repository state** before attempting any operations
543+1. **Docker Sandboxing** (`"sandbox": "docker"`):
544+ - Uses Docker containers to isolate tool execution
545+ - Requires Docker to be installed and running
546+ - Provides strong isolation from the host system
547+ 
548+2. **Podman Sandboxing** (`"sandbox": "podman"`):
549+ - Similar to Docker but uses Podman as the container runtime
550+ - Useful in environments where Docker is not available
551+ 
552+3. **Custom Sandboxing** (`"sandbox": "custom-command"`):
553+ - Allows you to specify a custom sandboxing command
554+ - Provides flexibility for specialized environments
555+ 
556+### Configuration
557+ 
558+You can enable sandboxing through:
559+- Settings file: `"sandbox": true` or `"sandbox": "docker"`
560+- Environment variable: `GEMINI_SANDBOX=true`
561+- Command line: `--sandbox` flag
562+ 
563+### Custom Sandbox Profiles
564+ 
565+For advanced users, you can create custom sandbox profiles by placing configuration files in your project's `.gemini/` directory:
566+ 
567+- **Docker:** `.gemini/sandbox.Dockerfile`
568+- **macOS Seatbelt:** `.gemini/sandbox-macos-<profile_name>.sb`
569+ 
570+These custom profiles allow you to define specific security policies and runtime environments for your project's needs.
RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack

RuleStack

Built by

Kynth Studio

Directory

Configs
Stacks
Compare formats
Diff two configs
Best AGENTS.md examples

Formats

AGENTS.md
CLAUDE.md
Cursor rules
Copilot instructions

Reference

Read API
Corpus health
Privacy Policy
Terms

RuleStack