SaylorTwift HF Staff commited on
Commit
7a1ad33
·
verified ·
1 Parent(s): 52efc7b

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gemini/commands/github/cleanup-back-to-main.toml +13 -0
  2. .gemini/commands/oncall/pr-review.toml +47 -0
  3. .gemini/skills/async-pr-review/scripts/async-review.sh +245 -0
  4. .gemini/skills/async-pr-review/scripts/check-async-review.sh +65 -0
  5. docs/admin/enterprise-controls.md +176 -0
  6. docs/assets/gemini-screenshot.png +0 -0
  7. docs/assets/monitoring-dashboard-metrics.png +0 -0
  8. docs/assets/monitoring-dashboard-overview.png +0 -0
  9. docs/assets/theme-tokyonight-dark.png +0 -0
  10. docs/changelogs/index.md +1214 -0
  11. docs/changelogs/latest.md +72 -0
  12. docs/changelogs/preview.md +49 -0
  13. docs/cli/acp-mode.md +126 -0
  14. docs/cli/auto-memory.md +164 -0
  15. docs/cli/checkpointing.md +95 -0
  16. docs/cli/cli-reference.md +134 -0
  17. docs/cli/creating-skills.md +207 -0
  18. docs/cli/custom-commands.md +331 -0
  19. docs/cli/enterprise.md +613 -0
  20. docs/cli/gemini-ignore.md +71 -0
  21. docs/cli/gemini-md.md +116 -0
  22. docs/cli/generation-settings.md +212 -0
  23. docs/cli/git-worktrees.md +107 -0
  24. docs/cli/headless.md +51 -0
  25. docs/cli/model-routing.md +59 -0
  26. docs/cli/model-steering.md +80 -0
  27. docs/cli/model.md +55 -0
  28. docs/cli/notifications.md +59 -0
  29. docs/cli/plan-mode.md +509 -0
  30. docs/cli/rewind.md +51 -0
  31. docs/cli/sandbox.md +473 -0
  32. docs/cli/session-management.md +215 -0
  33. docs/cli/settings.md +198 -0
  34. docs/cli/skills-best-practices.md +78 -0
  35. docs/cli/skills.md +141 -0
  36. docs/cli/system-prompt.md +129 -0
  37. docs/cli/telemetry.md +1277 -0
  38. docs/cli/themes.md +288 -0
  39. docs/cli/token-caching.md +20 -0
  40. docs/cli/trusted-folders.md +154 -0
  41. docs/cli/using-agent-skills.md +89 -0
  42. docs/core/gemma-setup.md +83 -0
  43. docs/core/index.md +109 -0
  44. docs/core/local-model-routing.md +200 -0
  45. docs/core/remote-agents.md +457 -0
  46. docs/core/subagents.md +598 -0
  47. docs/examples/proxy-script.md +83 -0
  48. docs/extensions/best-practices.md +189 -0
  49. docs/extensions/index.md +61 -0
  50. docs/extensions/reference.md +361 -0
.gemini/commands/github/cleanup-back-to-main.toml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ description = "Go back to main and clean up the branch."
2
+
3
+ prompt = """
4
+ I'm done with the work on this branch, and I'm ready to go back to main and clean up.
5
+
6
+ Here is the workflow I'd like you to follow:
7
+
8
+ 1. **Get Current Branch:** First, I need you to get the name of the current branch and save it.
9
+ 2. **Branch Check:** Check if the current branch is `main`. If it is, I need you to stop and let me know.
10
+ 3. **Go to Main:** Next, I need you to checkout the main branch.
11
+ 4. **Pull Latest:** Once you are on the main branch, I need you to pull down the latest changes to make sure I'm up to date.
12
+ 5. **Branch Cleanup:** Finally, I need you to delete the branch that you noted in the first step.
13
+ """
.gemini/commands/oncall/pr-review.toml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ description = "Review a specific pull request"
2
+
3
+ prompt = """
4
+ ## Mission: Comprehensive Pull Request Review
5
+
6
+ Today, our mission is to meticulously review community pull requests (PRs) for this project. We will proceed systematically, evaluating each candidate PR for its quality, adherence to standards, and readiness for merging.
7
+
8
+ ### Workflow:
9
+
10
+ 1. **PR Preparation & Initial Assessment**:
11
+ * **You will check out the designated PR {{args}}** into a temporary branch.
12
+ * **Execute the preflight checks (`npm run preflight`)**. This includes building, linting, and running all unit tests.
13
+ * Analyze the output of these preflight checks, noting any failures, warnings, or linting issues.
14
+
15
+ 2. **In-Depth Code Review**:
16
+ * **Your primary role is to conduct a thorough and in-depth code review** of the changes introduced in the PR. Focus your analysis on the following criteria:
17
+ * **Correctness**: Does the code achieve its stated purpose without bugs or logical errors?
18
+ * **Maintainability**: Is the code clean, well-structured, and easy to understand and modify in the future? Consider factors like code clarity, modularity, and adherence to established design patterns.
19
+ * **Readability**: Is the code well-commented (where necessary) and consistently formatted according to our project's coding style guidelines?
20
+ * **Efficiency**: Are there any obvious performance bottlenecks or resource inefficiencies introduced by the changes?
21
+ * **Security**: Are there any potential security vulnerabilities or insecure coding practices?
22
+ * **Edge Cases and Error Handling**: Does the code appropriately handle edge cases and potential errors?
23
+ * **Testability**: Is the new or modified code adequately covered by tests (even if preflight checks pass)? Suggest additional test cases that would improve coverage or robustness.
24
+ * Based on your analysis, you will determine if the PR is **safe to merge**.
25
+
26
+ 3. **Reviewing Previous Feedback**:
27
+ * **Access and examine the PR's history** to identify any **outstanding requests or unresolved comments from previous reviews**. Incorporate these into your current review and explicitly highlight if they have been adequately addressed in the current state of the PR.
28
+
29
+ 4. **Decision and Output Generation**:
30
+ * **If the PR is deemed safe to merge** (after your comprehensive review and considering previous feedback):
31
+ * Draft a **friendly, concise, and professional approval message**.
32
+ * **The approval message should:**
33
+ * Clearly state that the PR is approved.
34
+ * Briefly acknowledge the quality or value of the contribution (e.g., "Great work on X feature!" or "Appreciate the fix for Y issue!").
35
+ * **Do NOT mention the preflight checks or unit testing**, as these are internal processes.
36
+ * Be suitable for public display on GitHub.
37
+ * **If the PR is NOT safe to merge**:
38
+ * Provide a **clear, constructive, and detailed summary of the issues found**.
39
+ * Suggest **specific actionable changes** required for the PR to become merge-ready.
40
+ * Ensure the feedback is professional and encourages the contributor.
41
+
42
+ ### Post-PR Action:
43
+
44
+ * After providing your review and decision for the current PR, I will wait for you to perform any manual testing you wish to do. Please let me know when you are finished.
45
+ * Once you have confirmed that you are done, I will switch to the `main` branch, clean up the local branch, and perform a pull to ensure we are synchronized with the latest upstream changes for the next review.
46
+
47
+ """
.gemini/skills/async-pr-review/scripts/async-review.sh ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ notify() {
4
+ local title="${1}"
5
+ local message="${2}"
6
+ local pr="${3}"
7
+ # Terminal escape sequence
8
+ printf "\e]9;%s | PR #%s | %s\a" "${title}" "${pr}" "${message}"
9
+ # Native macOS notification
10
+ os_type="$(uname || true)"
11
+ if [[ "${os_type}" == "Darwin" ]]; then
12
+ osascript -e "display notification \"${message}\" with title \"${title}\" subtitle \"PR #${pr}\""
13
+ fi
14
+ }
15
+
16
+ pr_number="${1}"
17
+ if [[ -z "${pr_number}" ]]; then
18
+ echo "Usage: async-review <pr_number>"
19
+ exit 1
20
+ fi
21
+
22
+ base_dir="$(git rev-parse --show-toplevel 2>/dev/null || true)"
23
+ if [[ -z "${base_dir}" ]]; then
24
+ echo "❌ Must be run from within a git repository."
25
+ exit 1
26
+ fi
27
+
28
+ # Use the repository's local .gemini/tmp directory for ephemeral worktrees and logs
29
+ pr_dir="${base_dir}/.gemini/tmp/async-reviews/pr-${pr_number}"
30
+ target_dir="${pr_dir}/worktree"
31
+ log_dir="${pr_dir}/logs"
32
+
33
+ cd "${base_dir}" || exit 1
34
+
35
+ mkdir -p "${log_dir}"
36
+ rm -f "${log_dir}/setup.exit" "${log_dir}/final-assessment.exit" "${log_dir}/final-assessment.md"
37
+
38
+ echo "🧹 Cleaning up previous worktree if it exists..." | tee -a "${log_dir}/setup.log"
39
+ git worktree remove -f "${target_dir}" >> "${log_dir}/setup.log" 2>&1 || true
40
+ git branch -D "gemini-async-pr-${pr_number}" >> "${log_dir}/setup.log" 2>&1 || true
41
+ git worktree prune >> "${log_dir}/setup.log" 2>&1 || true
42
+
43
+ echo "📡 Fetching PR #${pr_number}..." | tee -a "${log_dir}/setup.log"
44
+ if ! git fetch origin -f "pull/${pr_number}/head:gemini-async-pr-${pr_number}" >> "${log_dir}/setup.log" 2>&1; then
45
+ echo 1 > "${log_dir}/setup.exit"
46
+ echo "❌ Fetch failed. Check ${log_dir}/setup.log"
47
+ notify "Async Review Failed" "Fetch failed." "${pr_number}"
48
+ exit 1
49
+ fi
50
+
51
+ if [[ ! -d "${target_dir}" ]]; then
52
+ echo "🧹 Pruning missing worktrees..." | tee -a "${log_dir}/setup.log"
53
+ git worktree prune >> "${log_dir}/setup.log" 2>&1
54
+ echo "🌿 Creating worktree in ${target_dir}..." | tee -a "${log_dir}/setup.log"
55
+ if ! git worktree add "${target_dir}" "gemini-async-pr-${pr_number}" >> "${log_dir}/setup.log" 2>&1; then
56
+ echo 1 > "${log_dir}/setup.exit"
57
+ echo "❌ Worktree creation failed. Check ${log_dir}/setup.log"
58
+ notify "Async Review Failed" "Worktree creation failed." "${pr_number}"
59
+ exit 1
60
+ fi
61
+ else
62
+ echo "🌿 Worktree already exists." | tee -a "${log_dir}/setup.log"
63
+ fi
64
+ echo 0 > "${log_dir}/setup.exit"
65
+
66
+ cd "${target_dir}" || exit 1
67
+
68
+ echo "🚀 Launching background tasks. Logs saving to: ${log_dir}"
69
+
70
+ echo " ↳ [1/5] Grabbing PR diff..."
71
+ rm -f "${log_dir}/pr-diff.exit"
72
+ { gh pr diff "${pr_number}" > "${log_dir}/pr-diff.diff" 2>&1; echo $? > "${log_dir}/pr-diff.exit"; } &
73
+
74
+ echo " ↳ [2/5] Starting build and lint..."
75
+ rm -f "${log_dir}/build-and-lint.exit"
76
+ { { npm run clean && npm ci && npm run format && npm run build && npm run lint:ci && npm run typecheck; } > "${log_dir}/build-and-lint.log" 2>&1; echo $? > "${log_dir}/build-and-lint.exit"; } &
77
+
78
+ # Dynamically resolve gemini binary (fallback to your nightly path)
79
+ GEMINI_CMD="$(command -v gemini || echo "${HOME}/.gcli/nightly/node_modules/.bin/gemini")"
80
+ # shellcheck disable=SC2312
81
+ POLICY_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)/policy.toml"
82
+
83
+ echo " ↳ [3/5] Starting Gemini code review..."
84
+ rm -f "${log_dir}/review.exit"
85
+ { "${GEMINI_CMD}" --policy "${POLICY_PATH}" -p "/review-frontend ${pr_number}" > "${log_dir}/review.md" 2>&1; echo $? > "${log_dir}/review.exit"; } &
86
+
87
+ echo " ↳ [4/5] Starting automated tests (waiting for build and lint)..."
88
+ rm -f "${log_dir}/npm-test.exit"
89
+ {
90
+ while [[ ! -f "${log_dir}/build-and-lint.exit" ]]; do sleep 1; done
91
+ read -r build_exit < "${log_dir}/build-and-lint.exit" || build_exit=""
92
+ if [[ "${build_exit}" == "0" ]]; then
93
+ gh pr checks "${pr_number}" > "${log_dir}/ci-checks.log" 2>&1
94
+ ci_status=$?
95
+
96
+ if [[ "${ci_status}" -eq 0 ]]; then
97
+ echo "CI checks passed. Skipping local npm tests." > "${log_dir}/npm-test.log"
98
+ echo 0 > "${log_dir}/npm-test.exit"
99
+ elif [[ "${ci_status}" -eq 8 ]]; then
100
+ echo "CI checks are still pending. Skipping local npm tests to avoid duplicate work. Please check GitHub for final results." > "${log_dir}/npm-test.log"
101
+ echo 0 > "${log_dir}/npm-test.exit"
102
+ else
103
+ echo "CI checks failed. Failing checks:" > "${log_dir}/npm-test.log"
104
+ gh pr checks "${pr_number}" --json name,bucket -q '.[] | select(.bucket=="fail") | .name' >> "${log_dir}/npm-test.log" 2>&1
105
+
106
+ echo "Attempting to extract failing test files from CI logs..." >> "${log_dir}/npm-test.log"
107
+ pr_branch="$(gh pr view "${pr_number}" --json headRefName -q '.headRefName' 2>/dev/null || true)"
108
+ run_id="$(gh run list --branch "${pr_branch}" --workflow ci.yml --json databaseId -q '.[0].databaseId' 2>/dev/null || true)"
109
+
110
+ failed_files=""
111
+ if [[ -n "${run_id}" ]]; then
112
+ failed_files="$(gh run view "${run_id}" --log-failed 2>/dev/null | grep -o -E '(packages/[a-zA-Z0-9_-]+|integration-tests|evals)/[a-zA-Z0-9_/-]+\.test\.ts(x)?' | sort | uniq || true)"
113
+ fi
114
+
115
+ if [[ -n "${failed_files}" ]]; then
116
+ echo "Found failing test files from CI:" >> "${log_dir}/npm-test.log"
117
+ for f in ${failed_files}; do echo " - ${f}" >> "${log_dir}/npm-test.log"; done
118
+ echo "Running ONLY failing tests locally..." >> "${log_dir}/npm-test.log"
119
+
120
+ exit_code=0
121
+ for file in ${failed_files}; do
122
+ if [[ "${file}" == packages/* ]]; then
123
+ ws_dir="$(echo "${file}" | cut -d'/' -f1,2)"
124
+ else
125
+ ws_dir="$(echo "${file}" | cut -d'/' -f1)"
126
+ fi
127
+ rel_file="${file#"${ws_dir}"/}"
128
+
129
+ echo "--- Running ${rel_file} in workspace ${ws_dir} ---" >> "${log_dir}/npm-test.log"
130
+ if ! npm run test:ci -w "${ws_dir}" -- "${rel_file}" >> "${log_dir}/npm-test.log" 2>&1; then
131
+ exit_code=1
132
+ fi
133
+ done
134
+ echo "${exit_code}" > "${log_dir}/npm-test.exit"
135
+ else
136
+ echo "Could not extract specific failing files. Skipping full local test suite as it takes too long. Please check CI logs manually." >> "${log_dir}/npm-test.log"
137
+ echo 1 > "${log_dir}/npm-test.exit"
138
+ fi
139
+ fi
140
+ else
141
+ echo "Skipped due to build-and-lint failure" > "${log_dir}/npm-test.log"
142
+ echo 1 > "${log_dir}/npm-test.exit"
143
+ fi
144
+ } &
145
+
146
+ echo " ↳ [5/5] Starting Gemini test execution (waiting for build and lint)..."
147
+ rm -f "${log_dir}/test-execution.exit"
148
+ {
149
+ while [[ ! -f "${log_dir}/build-and-lint.exit" ]]; do sleep 1; done
150
+ read -r build_exit < "${log_dir}/build-and-lint.exit" || build_exit=""
151
+ if [[ "${build_exit}" == "0" ]]; then
152
+ "${GEMINI_CMD}" --policy "${POLICY_PATH}" -p "Analyze the diff for PR ${pr_number} using 'gh pr diff ${pr_number}'. Instead of running the project's automated test suite (like 'npm test'), physically exercise the newly changed code in the terminal (e.g., by writing a temporary script to call the new functions, or testing the CLI command directly). Verify the feature's behavior works as expected. IMPORTANT: Do NOT modify any source code to fix errors. Just exercise the code and log the results, reporting any failures clearly. Do not ask for user confirmation." > "${log_dir}/test-execution.log" 2>&1; echo $? > "${log_dir}/test-execution.exit"
153
+ else
154
+ echo "Skipped due to build-and-lint failure" > "${log_dir}/test-execution.log"
155
+ echo 1 > "${log_dir}/test-execution.exit"
156
+ fi
157
+ } &
158
+
159
+ echo "✅ All tasks dispatched!"
160
+ echo "You can monitor progress with: tail -f ${log_dir}/*.log"
161
+ echo "Read your review later at: ${log_dir}/review.md"
162
+
163
+ # Polling loop to wait for all background tasks to finish
164
+ tasks=("pr-diff" "build-and-lint" "review" "npm-test" "test-execution")
165
+ log_files=("pr-diff.diff" "build-and-lint.log" "review.md" "npm-test.log" "test-execution.log")
166
+
167
+ declare -A task_done
168
+ for t in "${tasks[@]}"; do task_done[${t}]=0; done
169
+
170
+ all_done=0
171
+ while [[ "${all_done}" -eq 0 ]]; do
172
+ clear
173
+ echo "=================================================="
174
+ echo "🚀 Async PR Review Status for PR #${pr_number}"
175
+ echo "=================================================="
176
+ echo ""
177
+
178
+ all_done=1
179
+ for i in "${!tasks[@]}"; do
180
+ t="${tasks[${i}]}"
181
+
182
+ if [[ -f "${log_dir}/${t}.exit" ]]; then
183
+ read -r task_exit < "${log_dir}/${t}.exit" || task_exit=""
184
+ if [[ "${task_exit}" == "0" ]]; then
185
+ echo " ✅ ${t}: SUCCESS"
186
+ else
187
+ echo " ❌ ${t}: FAILED (exit code ${task_exit})"
188
+ fi
189
+ task_done[${t}]=1
190
+ else
191
+ echo " ⏳ ${t}: RUNNING"
192
+ all_done=0
193
+ fi
194
+ done
195
+
196
+ echo ""
197
+ echo "=================================================="
198
+ echo "📝 Live Logs (Last 5 lines of running tasks)"
199
+ echo "=================================================="
200
+
201
+ for i in "${!tasks[@]}"; do
202
+ t="${tasks[${i}]}"
203
+ log_file="${log_files[${i}]}"
204
+
205
+ if [[ "${task_done[${t}]}" -eq 0 ]]; then
206
+ if [[ -f "${log_dir}/${log_file}" ]]; then
207
+ echo ""
208
+ echo "--- ${t} ---"
209
+ tail -n 5 "${log_dir}/${log_file}"
210
+ fi
211
+ fi
212
+ done
213
+
214
+ if [[ "${all_done}" -eq 0 ]]; then
215
+ sleep 3
216
+ fi
217
+ done
218
+
219
+ clear
220
+ echo "=================================================="
221
+ echo "🚀 Async PR Review Status for PR #${pr_number}"
222
+ echo "=================================================="
223
+ echo ""
224
+ for t in "${tasks[@]}"; do
225
+ read -r task_exit < "${log_dir}/${t}.exit" || task_exit=""
226
+ if [[ "${task_exit}" == "0" ]]; then
227
+ echo " ✅ ${t}: SUCCESS"
228
+ else
229
+ echo " ❌ ${t}: FAILED (exit code ${task_exit})"
230
+ fi
231
+ done
232
+ echo ""
233
+
234
+ echo "⏳ Tasks complete! Synthesizing final assessment..."
235
+ if ! "${GEMINI_CMD}" --policy "${POLICY_PATH}" -p "Read the review at ${log_dir}/review.md, the automated test logs at ${log_dir}/npm-test.log, and the manual test execution logs at ${log_dir}/test-execution.log. Summarize the results, state whether the build and tests passed based on ${log_dir}/build-and-lint.exit and ${log_dir}/npm-test.exit, and give a final recommendation for PR ${pr_number}." > "${log_dir}/final-assessment.md" 2>&1; then
236
+ echo $? > "${log_dir}/final-assessment.exit"
237
+ echo "❌ Final assessment synthesis failed!"
238
+ echo "Check ${log_dir}/final-assessment.md for details."
239
+ notify "Async Review Failed" "Final assessment synthesis failed." "${pr_number}"
240
+ exit 1
241
+ fi
242
+
243
+ echo 0 > "${log_dir}/final-assessment.exit"
244
+ echo "✅ Final assessment complete! Check ${log_dir}/final-assessment.md"
245
+ notify "Async Review Complete" "Review and test execution finished successfully." "${pr_number}"
.gemini/skills/async-pr-review/scripts/check-async-review.sh ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ pr_number="${1}"
3
+
4
+ if [[ -z "${pr_number}" ]]; then
5
+ echo "Usage: check-async-review <pr_number>"
6
+ exit 1
7
+ fi
8
+
9
+ base_dir="$(git rev-parse --show-toplevel 2>/dev/null || true)"
10
+ if [[ -z "${base_dir}" ]]; then
11
+ echo "❌ Must be run from within a git repository."
12
+ exit 1
13
+ fi
14
+
15
+ log_dir="${base_dir}/.gemini/tmp/async-reviews/pr-${pr_number}/logs"
16
+
17
+ if [[ ! -d "${log_dir}" ]]; then
18
+ echo "STATUS: NOT_FOUND"
19
+ echo "❌ No logs found for PR #${pr_number} in ${log_dir}"
20
+ exit 0
21
+ fi
22
+
23
+ tasks=(
24
+ "setup|setup.log"
25
+ "pr-diff|pr-diff.diff"
26
+ "build-and-lint|build-and-lint.log"
27
+ "review|review.md"
28
+ "npm-test|npm-test.log"
29
+ "test-execution|test-execution.log"
30
+ "final-assessment|final-assessment.md"
31
+ )
32
+
33
+ all_done=true
34
+ echo "STATUS: CHECKING"
35
+
36
+ for task_info in "${tasks[@]}"; do
37
+ IFS="|" read -r task_name log_file <<< "${task_info}"
38
+
39
+ file_path="${log_dir}/${log_file}"
40
+ exit_file="${log_dir}/${task_name}.exit"
41
+
42
+ if [[ -f "${exit_file}" ]]; then
43
+ read -r exit_code < "${exit_file}" || exit_code=""
44
+ if [[ "${exit_code}" == "0" ]]; then
45
+ echo "✅ ${task_name}: SUCCESS"
46
+ else
47
+ echo "❌ ${task_name}: FAILED (exit code ${exit_code})"
48
+ echo " Last lines of ${file_path}:"
49
+ tail -n 3 "${file_path}" | sed 's/^/ /' || true
50
+ fi
51
+ elif [[ -f "${file_path}" ]]; then
52
+ echo "⏳ ${task_name}: RUNNING"
53
+ all_done=false
54
+ else
55
+ echo "➖ ${task_name}: NOT STARTED"
56
+ all_done=false
57
+ fi
58
+ done
59
+
60
+ if [[ "${all_done}" == "true" ]]; then
61
+ echo "STATUS: COMPLETE"
62
+ echo "LOG_DIR: ${log_dir}"
63
+ else
64
+ echo "STATUS: IN_PROGRESS"
65
+ fi
docs/admin/enterprise-controls.md ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Enterprise Admin Controls
2
+
3
+ Gemini CLI empowers enterprise administrators to manage and enforce security
4
+ policies and configuration settings across their entire organization. Secure
5
+ defaults are enabled automatically for all enterprise users, but can be
6
+ customized via the [Management Console](https://goo.gle/manage-gemini-cli).
7
+
8
+ **Enterprise Admin Controls are enforced globally and cannot be overridden by
9
+ users locally**, ensuring a consistent security posture.
10
+
11
+ ## Admin Controls vs. System Settings
12
+
13
+ While [System-wide settings](../cli/settings.md) act as convenient configuration
14
+ overrides, they can still be modified by users with sufficient privileges. In
15
+ contrast, admin controls are immutable at the local level, making them the
16
+ preferred method for enforcing policy.
17
+
18
+ ## Available Controls
19
+
20
+ ### Strict Mode
21
+
22
+ **Enabled/Disabled** | Default: enabled
23
+
24
+ If enabled, users will not be able to enter yolo mode.
25
+
26
+ ### Extensions
27
+
28
+ **Enabled/Disabled** | Default: disabled
29
+
30
+ If disabled, users will not be able to use or install extensions. See
31
+ [Extensions](../extensions/index.md) for more details.
32
+
33
+ ### MCP
34
+
35
+ #### Enabled/Disabled
36
+
37
+ **Enabled/Disabled** | Default: disabled
38
+
39
+ If disabled, users will not be able to use MCP servers. See
40
+ [MCP Server Integration](../tools/mcp-server.md) for more details.
41
+
42
+ #### MCP Servers (preview)
43
+
44
+ **Default**: empty
45
+
46
+ Allows administrators to define an explicit allowlist of MCP servers. This
47
+ guarantees that users can only connect to trusted MCP servers defined by the
48
+ organization.
49
+
50
+ **Allowlist Format:**
51
+
52
+ ```json
53
+ {
54
+ "mcpServers": {
55
+ "external-provider": {
56
+ "url": "https://api.mcp-provider.com",
57
+ "type": "sse",
58
+ "trust": true,
59
+ "includeTools": ["toolA", "toolB"],
60
+ "excludeTools": []
61
+ },
62
+ "internal-corp-tool": {
63
+ "url": "https://mcp.internal-tool.corp",
64
+ "type": "http",
65
+ "includeTools": [],
66
+ "excludeTools": ["adminTool"]
67
+ }
68
+ }
69
+ }
70
+ ```
71
+
72
+ **Supported Fields:**
73
+
74
+ - `url`: (Required) The full URL of the MCP server endpoint.
75
+ - `type`: (Required) The connection type (for example, `sse` or `http`).
76
+ - `trust`: (Optional) If set to `true`, the server is trusted and tool execution
77
+ will not require user approval.
78
+ - `includeTools`: (Optional) An explicit list of tool names to allow. If
79
+ specified, only these tools will be available.
80
+ - `excludeTools`: (Optional) A list of tool names to hide. These tools will be
81
+ blocked.
82
+
83
+ **Client Enforcement Logic:**
84
+
85
+ - **Empty Allowlist**: If the admin allowlist is empty, the client uses the
86
+ user’s local configuration as is (unless the MCP toggle above is disabled).
87
+ - **Active Allowlist**: If the allowlist contains one or more servers, **all
88
+ locally configured servers not present in the allowlist are ignored**.
89
+ - **Configuration Merging**: For a server to be active, it must exist in
90
+ **both** the admin allowlist and the user’s local configuration (matched by
91
+ name). The client merges these definitions as follows:
92
+ - **Override Fields**: The `url`, `type`, & `trust` are always taken from the
93
+ admin allowlist, overriding any local values.
94
+ - **Tools Filtering**: If `includeTools` or `excludeTools` are defined in the
95
+ allowlist, the admin’s rules are used exclusively. If both are undefined in
96
+ the admin allowlist, the client falls back to the user’s local tool
97
+ settings.
98
+ - **Cleared Fields**: To ensure security and consistency, the client
99
+ automatically clears local execution fields (`command`, `args`, `env`,
100
+ `cwd`, `httpUrl`, `tcp`). This prevents users from overriding the connection
101
+ method.
102
+ - **Other Fields**: All other MCP fields are pulled from the user’s local
103
+ configuration.
104
+ - **Missing Allowlisted Servers**: If a server appears in the admin allowlist
105
+ but is missing from the local configuration, it will not be initialized. This
106
+ ensures users maintain final control over which permitted servers are actually
107
+ active in their environment.
108
+
109
+ #### Required MCP Servers (preview)
110
+
111
+ **Default**: empty
112
+
113
+ Allows administrators to define MCP servers that are **always injected** into
114
+ the user's environment. Unlike the allowlist (which filters user-configured
115
+ servers), required servers are automatically added regardless of the user's
116
+ local configuration.
117
+
118
+ **Required Servers Format:**
119
+
120
+ ```json
121
+ {
122
+ "requiredMcpServers": {
123
+ "corp-compliance-tool": {
124
+ "url": "https://mcp.corp/compliance",
125
+ "type": "http",
126
+ "trust": true,
127
+ "description": "Corporate compliance tool"
128
+ },
129
+ "internal-registry": {
130
+ "url": "https://registry.corp/mcp",
131
+ "type": "sse",
132
+ "authProviderType": "google_credentials",
133
+ "oauth": {
134
+ "scopes": ["https://www.googleapis.com/auth/scope"]
135
+ }
136
+ }
137
+ }
138
+ }
139
+ ```
140
+
141
+ **Supported Fields:**
142
+
143
+ - `url`: (Required) The full URL of the MCP server endpoint.
144
+ - `type`: (Required) The connection type (`sse` or `http`).
145
+ - `trust`: (Optional) If set to `true`, tool execution will not require user
146
+ approval. Defaults to `true` for required servers.
147
+ - `description`: (Optional) Human-readable description of the server.
148
+ - `authProviderType`: (Optional) Authentication provider (`dynamic_discovery`,
149
+ `google_credentials`, or `service_account_impersonation`).
150
+ - `oauth`: (Optional) OAuth configuration including `scopes`, `clientId`, and
151
+ `clientSecret`.
152
+ - `targetAudience`: (Optional) OAuth target audience for service-to-service
153
+ auth.
154
+ - `targetServiceAccount`: (Optional) Service account email to impersonate.
155
+ - `headers`: (Optional) Additional HTTP headers to send with requests.
156
+ - `includeTools` / `excludeTools`: (Optional) Tool filtering lists.
157
+ - `timeout`: (Optional) Timeout in milliseconds for MCP requests.
158
+
159
+ **Client Enforcement Logic:**
160
+
161
+ - Required servers are injected **after** allowlist filtering, so they are
162
+ always available even if the allowlist is active.
163
+ - If a required server has the **same name** as a locally configured server, the
164
+ admin configuration **completely overrides** the local one.
165
+ - Required servers only support remote transports (`sse`, `http`). Local
166
+ execution fields (`command`, `args`, `env`, `cwd`) are not supported.
167
+ - Required servers can coexist with allowlisted servers — both features work
168
+ independently.
169
+
170
+ ### Unmanaged Capabilities
171
+
172
+ **Enabled/Disabled** | Default: disabled
173
+
174
+ If disabled, users will not be able to use certain features. Currently, this
175
+ control disables Agent Skills. See [Agent Skills](../cli/skills.md) for more
176
+ details.
docs/assets/gemini-screenshot.png ADDED
docs/assets/monitoring-dashboard-metrics.png ADDED
docs/assets/monitoring-dashboard-overview.png ADDED
docs/assets/theme-tokyonight-dark.png ADDED
docs/changelogs/index.md ADDED
@@ -0,0 +1,1214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Gemini CLI release notes
2
+
3
+ Gemini CLI has three major release channels: nightly, preview, and stable. For
4
+ most users, we recommend the stable release.
5
+
6
+ On this page, you can find information regarding the current releases and
7
+ announcements from each release.
8
+
9
+ For the full changelog, refer to
10
+ [Releases - google-gemini/gemini-cli](https://github.com/google-gemini/gemini-cli/releases)
11
+ on GitHub.
12
+
13
+ ## Current releases
14
+
15
+ | Release channel | Notes |
16
+ | :-------------------- | :---------------------------------------------- |
17
+ | Nightly | Nightly release with the most recent changes. |
18
+ | [Preview](preview.md) | Experimental features ready for early feedback. |
19
+ | [Stable](latest.md) | Stable, recommended for general use. |
20
+
21
+ ## Announcements: v0.60.0 - 2026-09-15
22
+
23
+ - **Extension & Tool Safety Hardening:** Prompt for user consent on environment
24
+ changes and sanitize runtime-altering environment variables, while enforcing
25
+ envelope metadata provenance for untrusted tool outputs
26
+ ([#28863](https://github.com/google-gemini/gemini-cli/pull/28863) by
27
+ @amelidev, [#29215](https://github.com/google-gemini/gemini-cli/pull/29215) by
28
+ @luisfelipe-alt).
29
+ - **Sandbox Directory Isolation:** Isolated settings and temporary directories
30
+ inside sandbox containers, including the macOS Seatbelt sandbox
31
+ ([#29171](https://github.com/google-gemini/gemini-cli/pull/29171),
32
+ [#29216](https://github.com/google-gemini/gemini-cli/pull/29216) by
33
+ @jvargassanchez-dot).
34
+
35
+ ## Announcements: v0.59.0 - 2026-09-08
36
+
37
+ - **MCP OAuth SSRF Mitigation:** Prevented Server-Side Request Forgery (SSRF)
38
+ during Model Context Protocol (MCP) OAuth metadata discovery and
39
+ authentication
40
+ ([#29081](https://github.com/google-gemini/gemini-cli/pull/29081) by
41
+ @josebalius).
42
+ - **Fail-Closed Workspace Trust:** Enforced a secure, fail-closed workspace
43
+ trust policy and filtered available `mcpServers` when operating in restricted
44
+ mode ([#29099](https://github.com/google-gemini/gemini-cli/pull/29099) by
45
+ @luisfelipe-alt).
46
+
47
+ ## Announcements: v0.58.0 - 2026-09-01
48
+
49
+ - **Core Security & Path Handling:** Enforced consistent symlink evaluation in
50
+ ignore path handling and declared top-level safety checkers in write policy
51
+ configuration
52
+ ([#28915](https://github.com/google-gemini/gemini-cli/pull/28915),
53
+ [#28961](https://github.com/google-gemini/gemini-cli/pull/28961) by
54
+ @luisfelipe-alt).
55
+ - **macOS Seatbelt Sandbox:** Isolated Docker and container runtime sockets and
56
+ binaries to restrict container runtime access in the macOS sandbox
57
+ ([#28935](https://github.com/google-gemini/gemini-cli/pull/28935) by
58
+ @josebalius).
59
+ - **Session & Recovery Optimizations:** Optimized history rollback mechanics,
60
+ retry nudge prompts, and resolved stale cancellation errors in the
61
+ Agent-to-Agent server
62
+ ([#28934](https://github.com/google-gemini/gemini-cli/pull/28934) by
63
+ @DavidAPierce,
64
+ [#28940](https://github.com/google-gemini/gemini-cli/pull/28940) by
65
+ @amelidev).
66
+
67
+ ## Announcements: v0.54.0 - 2026-08-06
68
+
69
+ - **PR Automation & Antigravity Agent:** Integrated the Antigravity agent runner
70
+ with dual-locking Firestore concurrency controls to secure the PR generator
71
+ ([#28434](https://github.com/google-gemini/gemini-cli/pull/28434),
72
+ [#28432](https://github.com/google-gemini/gemini-cli/pull/28432) by
73
+ @joneba-google).
74
+ - **Caretaker Triaging & Security:** Enhanced caretaker triage to post comments
75
+ prior to auto-closing issues and sanitized issue titles under untrusted
76
+ context ([#28411](https://github.com/google-gemini/gemini-cli/pull/28411),
77
+ [#28352](https://github.com/google-gemini/gemini-cli/pull/28352) by @chadd28).
78
+ - **Security and Session Robustness:** Prevented cleartext credential leakage by
79
+ enforcing HTTPS, rotated session IDs on model fallbacks, and skipped merged
80
+ function-response turns in active loops
81
+ ([#28517](https://github.com/google-gemini/gemini-cli/pull/28517) by
82
+ @amelidev, [#28565](https://github.com/google-gemini/gemini-cli/pull/28565) by
83
+ @adamfweidman).
84
+
85
+ ## Announcements: v0.53.0 - 2026-07-28
86
+
87
+ - **Caretaker Triage Orchestration:** Implemented an LLM triage orchestrator and
88
+ container build setup
89
+ ([#28345](https://github.com/google-gemini/gemini-cli/pull/28345) by
90
+ @chadd28).
91
+ - **Eval Coverage Reporting:** Introduced a new command for generating
92
+ evaluation coverage reports
93
+ ([#28169](https://github.com/google-gemini/gemini-cli/pull/28169) by @ved015).
94
+ - **Security & Loop Mitigations:** Enforced workspace trust and task isolation
95
+ in the A2A server, aligned macOS Seatbelt profiles with the deny-default
96
+ model, and mitigated infinite ReAct/prompt injection loops
97
+ ([#28470](https://github.com/google-gemini/gemini-cli/pull/28470) by
98
+ @luisfelipe-alt,
99
+ [#28424](https://github.com/google-gemini/gemini-cli/pull/28424) by
100
+ @ompatel-aiml).
101
+
102
+ ## Announcements: v0.52.0 - 2026-07-22
103
+
104
+ - **Caretaker Triage & Egress Services:** Implemented the core triage worker
105
+ foundational modules, main worker execution loops, and egress action
106
+ publishers alongside the octokit GitHub Action handler for egress services
107
+ ([#28163](https://github.com/google-gemini/gemini-cli/pull/28163),
108
+ [#28306](https://github.com/google-gemini/gemini-cli/pull/28306) by @chadd28).
109
+ - **Core Tool Enhancements:** Bypassed LLM correction for JSON and IPYNB files
110
+ in `write_file` and `replace` tools, and simplified plan mode write policy to
111
+ support relative paths
112
+ ([#28223](https://github.com/google-gemini/gemini-cli/pull/28223) by
113
+ @amelidev, [#28398](https://github.com/google-gemini/gemini-cli/pull/28398) by
114
+ @DavidAPierce).
115
+ - **Auth & Privacy Improvements:** Displayed clear error messages when user
116
+ account has no Code Assist tier, and bumped `google-auth-library` to version
117
+ 10.9.0 ([#28304](https://github.com/google-gemini/gemini-cli/pull/28304) by
118
+ @ompatel-aiml,
119
+ [#28385](https://github.com/google-gemini/gemini-cli/pull/28385) by
120
+ @jerrylin3321).
121
+
122
+ ## Announcements: v0.50.0 - 2026-07-08
123
+
124
+ - **Tool Registry Discovery:** Introduced tool registry discovery capabilities
125
+ to automatically detect and register available tools
126
+ ([#28113](https://github.com/google-gemini/gemini-cli/pull/28113) by @ved015).
127
+ - **Release Verification & CI Stability:** Enhanced release verification by
128
+ ignoring scripts during verification, preventing workspace binary shadowing,
129
+ and safeguarding against bad NPM releases
130
+ ([#28116](https://github.com/google-gemini/gemini-cli/pull/28116) by
131
+ @rmedranollamas,
132
+ [#28132](https://github.com/google-gemini/gemini-cli/pull/28132) by
133
+ @galdawave).
134
+
135
+ ## Announcements: v0.45.0 - 2026-06-03
136
+
137
+ - **Context Simplification:** Completed major architectural work to simplify the
138
+ `ContextManager`, improving system robustness and performance
139
+ ([#27345](https://github.com/google-gemini/gemini-cli/pull/27345) by
140
+ @joshualitt).
141
+ - **A2A Usage Metadata:** Exposed critical usage metadata in the Agent-to-Agent
142
+ (A2A) protocol for better resource tracking
143
+ ([#27288](https://github.com/google-gemini/gemini-cli/pull/27288) by
144
+ @jvargassanchez-dot).
145
+ - **Reliability Fixes:** Addressed Termux relaunch loops, PTY resize errors, and
146
+ forced sequential execution for topic updates
147
+ ([#27110](https://github.com/google-gemini/gemini-cli/pull/27110) by @saymanq,
148
+ [#27357](https://github.com/google-gemini/gemini-cli/pull/27357) by
149
+ @jvargassanchez-dot,
150
+ [#27461](https://github.com/google-gemini/gemini-cli/pull/27461) by
151
+ @scidomino).
152
+
153
+ ## Announcements: v0.44.0 - 2026-05-27
154
+
155
+ - **Unified Auto Mode:** Streamlined the automation experience by merging
156
+ specialized Auto modes into a single, unified mode
157
+ ([#26714](https://github.com/google-gemini/gemini-cli/pull/26714) by
158
+ @DavidAPierce).
159
+ - **New Editor Integrations:** Added native support for Sublime Text and Emacs
160
+ Client ([#21090](https://github.com/google-gemini/gemini-cli/pull/21090) by
161
+ @alberti42).
162
+ - **Enhanced TUI Testing:** Introduced `agent-tui` and `tui-tester` skills for
163
+ programmatic testing and automation of terminal UI applications
164
+ ([#27121](https://github.com/google-gemini/gemini-cli/pull/27121) by
165
+ @adamfweidman).
166
+
167
+ ## Announcements: v0.43.0 - 2026-05-22
168
+
169
+ - **Surgical Code Edits:** Steered Gemini models to prefer the `edit` tool for
170
+ surgical modifications, improving speed and precision
171
+ ([#26480](https://github.com/google-gemini/gemini-cli/pull/26480) by
172
+ @aishaneeshah).
173
+ - **Session Export and Import:** Added the ability to export sessions to files
174
+ and import them via a new flag, facilitating session portability
175
+ ([#26514](https://github.com/google-gemini/gemini-cli/pull/26514) by
176
+ @cocosheng-g).
177
+ - **Adaptive Token Estimation:** Introduced an adaptive token calculator for
178
+ more accurate content size estimation, enhancing context management efficiency
179
+ ([#26888](https://github.com/google-gemini/gemini-cli/pull/26888) by
180
+ @joshualitt).
181
+
182
+ ## Announcements: v0.42.0 - 2026-05-12
183
+
184
+ - **Auto Memory Inbox:** Introduced a new inbox flow for Auto Memory with a
185
+ canonical-patch contract for seamless skill management
186
+ ([#26338](https://github.com/google-gemini/gemini-cli/pull/26338) by
187
+ @SandyTao520).
188
+ - **Gemma 4 by Default:** Enabled Gemma 4 models by default via the Gemini API
189
+ for all users
190
+ ([#26307](https://github.com/google-gemini/gemini-cli/pull/26307) by
191
+ @Abhijit-2592).
192
+ - **Voice Mode Enhancements:** Added wave animations and privacy/compliance UX
193
+ warnings for the Gemini Live backend
194
+ ([#26284](https://github.com/google-gemini/gemini-cli/pull/26284) by
195
+ @devr0306, [#26454](https://github.com/google-gemini/gemini-cli/pull/26454) by
196
+ @cocosheng-g).
197
+
198
+ ## Announcements: v0.41.0 - 2026-05-05
199
+
200
+ - **Real-time Voice Mode:** Implemented real-time voice mode with cloud and
201
+ local backends
202
+ ([#24174](https://github.com/google-gemini/gemini-cli/pull/24174) by
203
+ @Abhijit-2592).
204
+ - **Secure Environment Loading:** Enforced workspace trust and secured .env
205
+ loading in headless mode
206
+ ([#25814](https://github.com/google-gemini/gemini-cli/pull/25814) by
207
+ @ehedlund).
208
+ - **Advanced Shell Validation:** Enhanced shell command validation and added
209
+ core tools allowlist for improved security
210
+ ([#25720](https://github.com/google-gemini/gemini-cli/pull/25720) by @galz10).
211
+
212
+ ## Announcements: v0.40.0 - 2026-04-28
213
+
214
+ - **Offline Search and Themes:** Bundled ripgrep for offline search support and
215
+ added GitHub-style colorblind themes
216
+ ([#25342](https://github.com/google-gemini/gemini-cli/pull/25342) by
217
+ @scidomino, [#15504](https://github.com/google-gemini/gemini-cli/pull/15504)
218
+ by @Z1xus).
219
+ - **Advanced Resource and Memory Management:** Introduced MCP resource tools and
220
+ transitioned to a prompt-driven, four-tier memory management system
221
+ ([#25395](https://github.com/google-gemini/gemini-cli/pull/25395) by
222
+ @ruomengz, [#25716](https://github.com/google-gemini/gemini-cli/pull/25716) by
223
+ @SandyTao520).
224
+ - **UX and Local Models:** Enabled topic update narrations by default and
225
+ streamlined Gemma local model setup with `gemini gemma`
226
+ ([#25586](https://github.com/google-gemini/gemini-cli/pull/25586) by
227
+ @gundermanc, [#25498](https://github.com/google-gemini/gemini-cli/pull/25498)
228
+ by @Samee24).
229
+
230
+ ## Announcements: v0.39.0 - 2026-04-23
231
+
232
+ - **Skill Management:** Added a new `/memory` inbox command for reviewing and
233
+ patching skills extracted during sessions
234
+ ([#24544](https://github.com/google-gemini/gemini-cli/pull/24544) by
235
+ @SandyTao520, [#25148](https://github.com/google-gemini/gemini-cli/pull/25148)
236
+ by @SandyTao520).
237
+ - **Improved Transparency:** Plan Mode now requires confirmation for skill
238
+ activation and allows plan inspection
239
+ ([#24946](https://github.com/google-gemini/gemini-cli/pull/24946),
240
+ [#25058](https://github.com/google-gemini/gemini-cli/pull/25058) by
241
+ @ruomengz).
242
+ - **Architecture & Reliability:** Introduced a decoupled `ContextManager`
243
+ architecture and resolved several critical memory leaks and PTY exhaustion
244
+ issues ([#24752](https://github.com/google-gemini/gemini-cli/pull/24752) by
245
+ @joshualitt, [#25079](https://github.com/google-gemini/gemini-cli/pull/25079)
246
+ by @spencer426).
247
+
248
+ ## Announcements: v0.38.0 - 2026-04-14
249
+
250
+ - **Chapters Narrative Flow:** Group agent interactions into "Chapters" based on
251
+ intent and tool usage for better session structure
252
+ ([#23150](https://github.com/google-gemini/gemini-cli/pull/23150) by
253
+ @Abhijit-2592,
254
+ [#24079](https://github.com/google-gemini/gemini-cli/pull/24079) by
255
+ @gundermanc).
256
+ - **Context Compression Service:** Advanced context management to efficiently
257
+ distill conversation history
258
+ ([#24483](https://github.com/google-gemini/gemini-cli/pull/24483) by
259
+ @joshualitt).
260
+ - **UI Flicker & UX Enhancements:** Solved rendering flicker with "Terminal
261
+ Buffer" mode and introduced selective topic expansion
262
+ ([#24512](https://github.com/google-gemini/gemini-cli/pull/24512) by
263
+ @jacob314, [#24793](https://github.com/google-gemini/gemini-cli/pull/24793) by
264
+ @Abhijit-2592).
265
+ - **Persistent Policy Approvals:** Implemented context-aware persistent
266
+ approvals for tool execution
267
+ ([#23257](https://github.com/google-gemini/gemini-cli/pull/23257) by @jerop).
268
+
269
+ ## Announcements: v0.37.0 - 2026-04-08
270
+
271
+ - **Dynamic Sandbox Expansion:** Implemented dynamic sandbox expansion and
272
+ worktree support for Linux and Windows, improving developer workflows in
273
+ isolated environments
274
+ ([#23692](https://github.com/google-gemini/gemini-cli/pull/23692) by @galz10,
275
+ [#23691](https://github.com/google-gemini/gemini-cli/pull/23691) by
276
+ @scidomino).
277
+ - **Chapters Narrative Flow:** Introduced tool-based topic grouping ("Chapters")
278
+ to provide better session structure and narrative continuity
279
+ ([#23150](https://github.com/google-gemini/gemini-cli/pull/23150) by
280
+ @Abhijit-2592,
281
+ [#24079](https://github.com/google-gemini/gemini-cli/pull/24079) by
282
+ @gundermanc).
283
+ - **Advanced Browser Capabilities:** Enhanced the browser agent with persistent
284
+ sessions and dynamic tool discovery
285
+ ([#21306](https://github.com/google-gemini/gemini-cli/pull/21306) by
286
+ @kunal-10-cloud,
287
+ [#23805](https://github.com/google-gemini/gemini-cli/pull/23805) by
288
+ @cynthialong0-0).
289
+
290
+ ## Announcements: v0.36.0 - 2026-04-01
291
+
292
+ - **Multi-Registry Architecture and Sandboxing:** Introduced a multi-registry
293
+ architecture and implemented native macOS Seatbelt and Windows sandboxing for
294
+ enhanced subagent security
295
+ ([#22712](https://github.com/google-gemini/gemini-cli/pull/22712),
296
+ [#22718](https://github.com/google-gemini/gemini-cli/pull/22718) by @akh64bit,
297
+ [#22832](https://github.com/google-gemini/gemini-cli/pull/22832) by @ehedlund,
298
+ [#21807](https://github.com/google-gemini/gemini-cli/pull/21807) by
299
+ @mattKorwel).
300
+ - **Refreshed Composer UX:** Implemented a refreshed user experience for the
301
+ Composer layout and improved terminal interaction robustness
302
+ ([#21212](https://github.com/google-gemini/gemini-cli/pull/21212),
303
+ [#23286](https://github.com/google-gemini/gemini-cli/pull/23286) by
304
+ @jwhelangoog).
305
+ - **Git Worktree Support:** Added native support for Git worktrees, allowing for
306
+ isolated parallel sessions
307
+ ([#22973](https://github.com/google-gemini/gemini-cli/pull/22973),
308
+ [#23265](https://github.com/google-gemini/gemini-cli/pull/23265) by @jerop).
309
+ - **Subagent Context and Feedback:** Enhanced subagents with JIT context
310
+ injection and resilient tool rejection with contextual feedback
311
+ ([#23032](https://github.com/google-gemini/gemini-cli/pull/23032),
312
+ [#22951](https://github.com/google-gemini/gemini-cli/pull/22951) by
313
+ @abhipatel12).
314
+
315
+ ## Announcements: v0.35.0 - 2026-03-24
316
+
317
+ - **Customizable Keyboard Shortcuts:** Users can now customize their keyboard
318
+ shortcuts, including support for literal character keybindings and the
319
+ extended Kitty protocol
320
+ ([#21945](https://github.com/google-gemini/gemini-cli/pull/21945),
321
+ [#21972](https://github.com/google-gemini/gemini-cli/pull/21972) by
322
+ @scidomino).
323
+ - **Vim Mode Improvements:** Added missing motions (X, ~, r, f/F/t/T) and
324
+ yank/paste support with the unnamed register
325
+ ([#21932](https://github.com/google-gemini/gemini-cli/pull/21932),
326
+ [#22026](https://github.com/google-gemini/gemini-cli/pull/22026) by @aanari).
327
+ - **Tool Isolation and Sandboxing:** Introduced `SandboxManager` to isolate
328
+ process-spawning tools and added Linux bubblewrap/seccomp sandboxing support
329
+ ([#21774](https://github.com/google-gemini/gemini-cli/pull/21774),
330
+ [#22231](https://github.com/google-gemini/gemini-cli/pull/22231) by @galz10,
331
+ [#22680](https://github.com/google-gemini/gemini-cli/pull/22680) by
332
+ @DavidAPierce).
333
+ - **JIT Context Discovery:** Implemented Just-In-Time context discovery for file
334
+ system tools to improve model performance and accuracy
335
+ ([#22082](https://github.com/google-gemini/gemini-cli/pull/22082),
336
+ [#22736](https://github.com/google-gemini/gemini-cli/pull/22736) by
337
+ @SandyTao520).
338
+
339
+ ## Announcements: v0.34.0 - 2026-03-17
340
+
341
+ - **Plan Mode Enabled by Default:** Plan Mode is now enabled by default to help
342
+ you break down complex tasks and execute them systematically
343
+ ([#21713](https://github.com/google-gemini/gemini-cli/pull/21713) by @jerop).
344
+ - **Sandboxing Enhancements:** We've added native gVisor (runsc) and
345
+ experimental LXC container sandboxing support for safer execution environments
346
+ ([#21062](https://github.com/google-gemini/gemini-cli/pull/21062) by
347
+ @Zheyuan-Lin, [#20735](https://github.com/google-gemini/gemini-cli/pull/20735)
348
+ by @h30s).
349
+
350
+ ## Announcements: v0.33.0 - 2026-03-11
351
+
352
+ - **Agent Architecture Enhancements:** Introduced HTTP authentication for A2A
353
+ remote agents and authenticated A2A agent card discovery
354
+ ([#20510](https://github.com/google-gemini/gemini-cli/pull/20510) by
355
+ @SandyTao520, [#20622](https://github.com/google-gemini/gemini-cli/pull/20622)
356
+ by @SandyTao520).
357
+ - **Plan Mode Updates:** Expanded Plan Mode with built-in research subagents,
358
+ annotation support for feedback, and a new `copy` subcommand
359
+ ([#20972](https://github.com/google-gemini/gemini-cli/pull/20972) by @Adib234,
360
+ [#20988](https://github.com/google-gemini/gemini-cli/pull/20988) by
361
+ @ruomengz).
362
+ - **CLI UX & Admin Controls:** Redesigned the header to be compact with an ASCII
363
+ icon, inverted context window display to show usage, and enabled a 30-day
364
+ default retention for chat history
365
+ ([#18713](https://github.com/google-gemini/gemini-cli/pull/18713) by
366
+ @keithguerin, [#20853](https://github.com/google-gemini/gemini-cli/pull/20853)
367
+ by @skeshive).
368
+
369
+ ## Announcements: v0.32.0 - 2026-03-03
370
+
371
+ - **Generalist Agent:** The generalist agent is now enabled to improve task
372
+ delegation and routing
373
+ ([#19665](https://github.com/google-gemini/gemini-cli/pull/19665) by
374
+ @joshualitt).
375
+ - **Model Steering in Workspace:** Added support for model steering directly in
376
+ the workspace
377
+ ([#20343](https://github.com/google-gemini/gemini-cli/pull/20343) by
378
+ @joshualitt).
379
+ - **Plan Mode Enhancements:** Users can now open and modify plans in an external
380
+ editor, and the planning workflow has been adapted to handle complex tasks
381
+ more effectively with multi-select options
382
+ ([#20348](https://github.com/google-gemini/gemini-cli/pull/20348) by @Adib234,
383
+ [#20465](https://github.com/google-gemini/gemini-cli/pull/20465) by @jerop).
384
+ - **Interactive Shell Autocompletion:** Introduced interactive shell
385
+ autocompletion for a more seamless experience
386
+ ([#20082](https://github.com/google-gemini/gemini-cli/pull/20082) by
387
+ @mrpmohiburrahman).
388
+ - **Parallel Extension Loading:** Extensions are now loaded in parallel to
389
+ improve startup times
390
+ ([#20229](https://github.com/google-gemini/gemini-cli/pull/20229) by
391
+ @scidomino).
392
+
393
+ ## Announcements: v0.31.0 - 2026-02-27
394
+
395
+ - **Gemini 3.1 Pro Preview:** Gemini CLI now supports the new Gemini 3.1 Pro
396
+ Preview model
397
+ ([#19676](https://github.com/google-gemini/gemini-cli/pull/19676) by
398
+ @sehoon38).
399
+ - **Experimental Browser Agent:** We've introduced a new experimental browser
400
+ agent to interact with web pages
401
+ ([#19284](https://github.com/google-gemini/gemini-cli/pull/19284) by
402
+ @gsquared94).
403
+ - **Policy Engine Updates:** The policy engine now supports project-level
404
+ policies, MCP server wildcards, and tool annotation matching
405
+ ([#18682](https://github.com/google-gemini/gemini-cli/pull/18682) by
406
+ @Abhijit-2592,
407
+ [#20024](https://github.com/google-gemini/gemini-cli/pull/20024) by @jerop).
408
+ - **Web Fetch Improvements:** We've implemented an experimental direct web fetch
409
+ feature and added rate limiting to mitigate DDoS risks
410
+ ([#19557](https://github.com/google-gemini/gemini-cli/pull/19557) by @mbleigh,
411
+ [#19567](https://github.com/google-gemini/gemini-cli/pull/19567) by
412
+ @mattKorwel).
413
+
414
+ ## Announcements: v0.30.0 - 2026-02-25
415
+
416
+ - **SDK & Custom Skills:** Introduced the initial SDK package, enabling dynamic
417
+ system instructions, `SessionContext` for SDK tool calls, and support for
418
+ custom skills
419
+ ([#18861](https://github.com/google-gemini/gemini-cli/pull/18861) by
420
+ @mbleigh).
421
+ - **Policy Engine Enhancements:** Added a new `--policy` flag for user-defined
422
+ policies, introduced strict seatbelt profiles, and deprecated
423
+ `--allowed-tools` in favor of the policy engine
424
+ ([#18500](https://github.com/google-gemini/gemini-cli/pull/18500) by
425
+ @allenhutchison).
426
+ - **UI & Themes:** Added a generic searchable list for settings and extensions,
427
+ new Solarized themes, text wrapping for markdown tables, and a clean UI toggle
428
+ prototype ([#19064](https://github.com/google-gemini/gemini-cli/pull/19064) by
429
+ @rmedranollamas).
430
+ - **Vim & Terminal Interaction:** Improved Vim support to feel more complete and
431
+ added support for Ctrl-Z terminal suspension
432
+ ([#18755](https://github.com/google-gemini/gemini-cli/pull/18755) by
433
+ @ppgranger, [#18931](https://github.com/google-gemini/gemini-cli/pull/18931)
434
+ by @scidomino).
435
+
436
+ ## Announcements: v0.29.0 - 2026-02-17
437
+
438
+ - **Plan Mode:** A new comprehensive planning capability with `/plan`,
439
+ `enter_plan_mode` tool, and dedicated documentation
440
+ ([#17698](https://github.com/google-gemini/gemini-cli/pull/17698) by @Adib234,
441
+ [#18324](https://github.com/google-gemini/gemini-cli/pull/18324) by @jerop).
442
+ - **Gemini 3 Default:** We've removed the preview flag and enabled Gemini 3 by
443
+ default for all users
444
+ ([#18414](https://github.com/google-gemini/gemini-cli/pull/18414) by
445
+ @sehoon38).
446
+ - **Extension Exploration:** New UI and settings to explore and manage
447
+ extensions more easily
448
+ ([#18686](https://github.com/google-gemini/gemini-cli/pull/18686) by
449
+ @sripasg).
450
+ - **Admin Control:** Administrators can now allowlist specific MCP server
451
+ configurations
452
+ ([#18311](https://github.com/google-gemini/gemini-cli/pull/18311) by
453
+ @skeshive).
454
+
455
+ ## Announcements: v0.28.0 - 2026-02-10
456
+
457
+ - **IDE Support:** Gemini CLI now supports the Positron IDE
458
+ ([#15047](https://github.com/google-gemini/gemini-cli/pull/15047) by
459
+ @kapsner).
460
+ - **Customization:** You can now use custom themes in extensions, and we've
461
+ implemented automatic theme switching based on your terminal's background
462
+ ([#17327](https://github.com/google-gemini/gemini-cli/pull/17327) by
463
+ @spencer426, [#17976](https://github.com/google-gemini/gemini-cli/pull/17976)
464
+ by @Abhijit-2592).
465
+ - **Authentication:** We've added interactive and non-interactive consent for
466
+ OAuth, and you can now include your auth method in bug reports
467
+ ([#17699](https://github.com/google-gemini/gemini-cli/pull/17699) by
468
+ @ehedlund, [#17569](https://github.com/google-gemini/gemini-cli/pull/17569) by
469
+ @erikus).
470
+
471
+ ## Announcements: v0.27.0 - 2026-02-03
472
+
473
+ - **Event-Driven Architecture:** The CLI now uses a new event-driven scheduler
474
+ for tool execution, resulting in a more responsive and performant experience
475
+ ([#17078](https://github.com/google-gemini/gemini-cli/pull/17078) by
476
+ @abhipatel12).
477
+ - **Enhanced User Experience:** This release includes queued tool confirmations,
478
+ and expandable large text pastes for a smoother workflow.
479
+ - **New `/rewind` Command:** Easily navigate your session history with the new
480
+ `/rewind` command
481
+ ([#15720](https://github.com/google-gemini/gemini-cli/pull/15720) by
482
+ @Adib234).
483
+ - **Linux Clipboard Support:** You can now paste images on Linux with Wayland
484
+ and X11 ([#17144](https://github.com/google-gemini/gemini-cli/pull/17144) by
485
+ @devr0306).
486
+
487
+ ## Announcements: v0.26.0 - 2026-01-27
488
+
489
+ - **Agents and Skills:** We've introduced a new `skill-creator` skill
490
+ ([#16394](https://github.com/google-gemini/gemini-cli/pull/16394) by
491
+ @NTaylorMullen), enabled agent skills by default, and added a generalist agent
492
+ to improve task routing
493
+ ([#16638](https://github.com/google-gemini/gemini-cli/pull/16638) by
494
+ @joshualitt).
495
+ - **UI/UX Improvements:** You can now "Rewind" through your conversation history
496
+ ([#15717](https://github.com/google-gemini/gemini-cli/pull/15717) by
497
+ @Adib234).
498
+ - **Core and Scheduler Refactoring:** The core scheduler has been significantly
499
+ refactored to improve performance and reliability
500
+ ([#16895](https://github.com/google-gemini/gemini-cli/pull/16895) by
501
+ @abhipatel12), and numerous performance and stability fixes have been
502
+ included.
503
+
504
+ ## Announcements: v0.25.0 - 2026-01-20
505
+
506
+ - **Skills and Agents Improvements:** We've enhanced the `activate_skill` tool,
507
+ added a new `pr-creator` skill
508
+ ([#16232](https://github.com/google-gemini/gemini-cli/pull/16232) by
509
+ [@NTaylorMullen](https://github.com/NTaylorMullen)), enabled skills by
510
+ default, improved the `cli_help` agent
511
+ ([#16100](https://github.com/google-gemini/gemini-cli/pull/16100) by
512
+ [@scidomino](https://github.com/scidomino)), and added a new `/agents refresh`
513
+ command ([#16204](https://github.com/google-gemini/gemini-cli/pull/16204) by
514
+ [@joshualitt](https://github.com/joshualitt)).
515
+ - **UI/UX Refinements:** You'll notice more transparent feedback for skills
516
+ ([#15954](https://github.com/google-gemini/gemini-cli/pull/15954) by
517
+ [@NTaylorMullen](https://github.com/NTaylorMullen)), the ability to switch
518
+ focus between the shell and input with Tab
519
+ ([#14332](https://github.com/google-gemini/gemini-cli/pull/14332) by
520
+ [@jacob314](https://github.com/jacob314)), and dynamic terminal tab titles
521
+ ([#16378](https://github.com/google-gemini/gemini-cli/pull/16378) by
522
+ [@NTaylorMullen](https://github.com/NTaylorMullen)).
523
+ - **Core Functionality & Performance:** This release includes support for
524
+ built-in agent skills
525
+ ([#16045](https://github.com/google-gemini/gemini-cli/pull/16045) by
526
+ [@NTaylorMullen](https://github.com/NTaylorMullen)), refined Gemini 3 system
527
+ instructions ([#16139](https://github.com/google-gemini/gemini-cli/pull/16139)
528
+ by [@NTaylorMullen](https://github.com/NTaylorMullen)), caching for ignore
529
+ instances to improve performance
530
+ ([#16185](https://github.com/google-gemini/gemini-cli/pull/16185) by
531
+ [@EricRahm](https://github.com/EricRahm)), and enhanced retry mechanisms
532
+ ([#16489](https://github.com/google-gemini/gemini-cli/pull/16489) by
533
+ [@sehoon38](https://github.com/sehoon38)).
534
+ - **Bug Fixes and Stability:** We've squashed numerous bugs across the CLI,
535
+ core, and workflows, addressing issues with subagent delegation, unicode
536
+ character crashes, and sticky header regressions.
537
+
538
+ ## Announcements: v0.24.0 - 2026-01-14
539
+
540
+ - **Agent Skills:** We've introduced significant advancements in Agent Skills.
541
+ This includes initial documentation and tutorials to help you get started,
542
+ alongside enhanced support for remote agents, allowing for more distributed
543
+ and powerful automation within Gemini CLI.
544
+ ([#15869](https://github.com/google-gemini/gemini-cli/pull/15869) by
545
+ [@NTaylorMullen](https://github.com/NTaylorMullen)),
546
+ ([#16013](https://github.com/google-gemini/gemini-cli/pull/16013) by
547
+ [@adamweidman](https://github.com/adamweidman))
548
+ - **Improved UI/UX:** The user interface has received several updates, featuring
549
+ visual indicators for hook execution, a more refined display for settings, and
550
+ the ability to use the Tab key to effortlessly switch focus between the shell
551
+ and input areas.
552
+ ([#15408](https://github.com/google-gemini/gemini-cli/pull/15408) by
553
+ [@abhipatel12](https://github.com/abhipatel12)),
554
+ ([#14332](https://github.com/google-gemini/gemini-cli/pull/14332) by
555
+ [@galz10](https://github.com/galz10))
556
+ - **Enhanced Security:** Security has been a major focus, with default folder
557
+ trust now set to untrusted for increased safety. The Policy Engine has been
558
+ improved to allow specific modes in user and administrator policies, and
559
+ granular allowlisting for shell commands has been implemented, providing finer
560
+ control over tool execution.
561
+ ([#15943](https://github.com/google-gemini/gemini-cli/pull/15943) by
562
+ [@galz10](https://github.com/galz10)),
563
+ ([#15977](https://github.com/google-gemini/gemini-cli/pull/15977) by
564
+ [@NTaylorMullen](https://github.com/NTaylorMullen))
565
+ - **Core Functionality:** This release includes a mandatory MessageBus
566
+ injection, marking Phase 3 of a hard migration to a more robust internal
567
+ communication system. We've also added support for built-in skills with the
568
+ CLI itself, and enhanced model routing to effectively utilize subagents.
569
+ ([#15776](https://github.com/google-gemini/gemini-cli/pull/15776) by
570
+ [@abhipatel12](https://github.com/abhipatel12)),
571
+ ([#16300](https://github.com/google-gemini/gemini-cli/pull/16300) by
572
+ [@NTaylorMullen](https://github.com/NTaylorMullen))
573
+ - **Terminal Features:** Terminal interactions are more seamless with new
574
+ features like OSC 52 paste support, along with fixes for Windows clipboard
575
+ paste issues and general improvements to pasting in Windows terminals.
576
+ ([#15336](https://github.com/google-gemini/gemini-cli/pull/15336) by
577
+ [@scidomino](https://github.com/scidomino)),
578
+ ([#15932](https://github.com/google-gemini/gemini-cli/pull/15932) by
579
+ [@scidomino](https://github.com/scidomino))
580
+ - **New Commands:** To manage the new features, we've added several new
581
+ commands: `/agents refresh` to update agent configurations, `/skills reload`
582
+ to refresh skill definitions, and `/skills install/uninstall` for easier
583
+ management of your Agent Skills.
584
+ ([#16204](https://github.com/google-gemini/gemini-cli/pull/16204) by
585
+ [@NTaylorMullen](https://github.com/NTaylorMullen)),
586
+ ([#15865](https://github.com/google-gemini/gemini-cli/pull/15865) by
587
+ [@NTaylorMullen](https://github.com/NTaylorMullen)),
588
+ ([#16377](https://github.com/google-gemini/gemini-cli/pull/16377) by
589
+ [@NTaylorMullen](https://github.com/NTaylorMullen))
590
+
591
+ ## Announcements: v0.23.0 - 2026-01-07
592
+
593
+ - 🎉 **Experimental Agent Skills Support in Preview:** Gemini CLI now supports
594
+ [Agent Skills](https://agentskills.io/home) in our preview builds. This is an
595
+ early preview where we’re looking for feedback!
596
+ - Install Preview: `npm install -g @google/gemini-cli@preview`
597
+ - Enable in `/settings`
598
+ - Docs:
599
+ [https://geminicli.com/docs/cli/skills/](https://geminicli.com/docs/cli/skills/)
600
+ - **Gemini CLI wrapped:** Run `npx gemini-wrapped` to visualize your usage
601
+ stats, top models, languages, and more!
602
+ - **Windows clipboard image support:** Windows users can now paste images
603
+ directly from their clipboard into the CLI using `Alt`+`V`.
604
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/13997) by
605
+ [@sgeraldes](https://github.com/sgeraldes))
606
+ - **Terminal background color detection:** Automatically optimizes your
607
+ terminal's background color to select compatible themes and provide
608
+ accessibility warnings.
609
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/15132) by
610
+ [@jacob314](https://github.com/jacob314))
611
+ - **Session logout:** Use the new `/logout` command to instantly clear
612
+ credentials and reset your authentication state for seamless account
613
+ switching. ([pr](https://github.com/google-gemini/gemini-cli/pull/13383) by
614
+ [@CN-Scars](https://github.com/CN-Scars))
615
+
616
+ ## Announcements: v0.22.0 - 2025-12-22
617
+
618
+ - 🎉**Free Tier + Gemini 3:** Free tier users now all have access to Gemini 3
619
+ Pro & Flash. Enable in `/settings` by toggling "Preview Features" to `true`.
620
+ - 🎉**Gemini CLI + Colab:** Gemini CLI is now pre-installed. Can be used
621
+ headlessly in notebook cells or interactively in the built-in terminal
622
+ ([pic](https://imgur.com/a/G0Tn7vi))
623
+ - 🎉**Gemini CLI Extensions:**
624
+
625
+ - **Conductor:** Planning++, Gemini works with you to build out a detailed
626
+ plan, pull in extra details as needed, ultimately to give the LLM guardrails
627
+ with artifacts. Measure twice, implement once!
628
+
629
+ `gemini extensions install https://github.com/gemini-cli-extensions/conductor`
630
+
631
+ Blog:
632
+ [https://developers.googleblog.com/conductor-introducing-context-driven-development-for-gemini-cli/](https://developers.googleblog.com/conductor-introducing-context-driven-development-for-gemini-cli/)
633
+
634
+ - **Endor Labs:** Perform code analysis, vulnerability scanning, and
635
+ dependency checks using natural language.
636
+
637
+ `gemini extensions install https://github.com/endorlabs/gemini-extension`
638
+
639
+ ## Announcements: v0.21.0 - 2025-12-15
640
+
641
+ - **⚡️⚡️⚡️ Gemini 3 Flash + Gemini CLI:** Better, faster and cheaper than 2.5
642
+ Pro - and in some scenarios better than 3 Pro! For paid tiers + free tier
643
+ users who were on the wait list enable **Preview Features** in `/settings.`
644
+ - For more information:
645
+ [Gemini 3 Flash is now available in Gemini CLI](https://developers.googleblog.com/gemini-3-flash-is-now-available-in-gemini-cli/).
646
+ - 🎉 Gemini CLI Extensions:
647
+ - Rill: Utilize natural language to analyze Rill data, enabling the
648
+ exploration of metrics and trends without the need for manual queries.
649
+ `gemini extensions install https://github.com/rilldata/rill-gemini-extension`
650
+ - Browserbase: Interact with web pages, take screenshots, extract information,
651
+ and perform automated actions with atomic precision.
652
+ `gemini extensions install https://github.com/browserbase/mcp-server-browserbase`
653
+ - Quota Visibility: The `/stats` command now displays quota information for all
654
+ available models, including those not used in the current session. (@sehoon38)
655
+ - Fuzzy Setting Search: Users can now quickly find settings using fuzzy search
656
+ within the settings dialog. (@sehoon38)
657
+ - MCP Resource Support: Users can now discover, view, and search through
658
+ resources using the @ command. (@MrLesk)
659
+ - Auto-execute Simple Slash Commands: Simple slash commands are now executed
660
+ immediately on enter. (@jackwotherspoon)
661
+
662
+ ## Announcements: v0.20.0 - 2025-12-01
663
+
664
+ - **Multi-file Drag & Drop:** Users can now drag and drop multiple files into
665
+ the terminal, and the CLI will automatically prefix each valid path with `@`.
666
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/14832) by
667
+ [@jackwotherspoon](https://github.com/jackwotherspoon))
668
+ - **Persistent "Always Allow" Policies:** Users can now save "Always Allow"
669
+ decisions for tool executions, with granular control over specific shell
670
+ commands and multi-cloud platform tools.
671
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/14737) by
672
+ [@allenhutchison](https://github.com/allenhutchison))
673
+
674
+ ## Announcements: v0.19.0 - 2025-11-24
675
+
676
+ - 🎉 **New extensions:**
677
+ - **Eleven Labs:** Create, play, manage your audio play tracks with the Eleven
678
+ Labs Gemini CLI extension:
679
+ `gemini extensions install https://github.com/elevenlabs/elevenlabs-mcp`
680
+ - **Zed integration:** Users can now leverage Gemini 3 within the Zed
681
+ integration after enabling "Preview Features" in their CLI’s `/settings`.
682
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/13398) by
683
+ [@benbrandt](https://github.com/benbrandt))
684
+ - **Interactive shell:**
685
+ - **Click-to-Focus:** When "Use Alternate Buffer" setting is enabled, users
686
+ can click within the embedded shell output to focus it for input.
687
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/13341) by
688
+ [@galz10](https://github.com/galz10))
689
+ - **Loading phrase:** Clearly indicates when the interactive shell is awaiting
690
+ user input. ([vid](https://imgur.com/a/kjK8bUK),
691
+ [pr](https://github.com/google-gemini/gemini-cli/pull/12535) by
692
+ [@jackwotherspoon](https://github.com/jackwotherspoon))
693
+
694
+ ## Announcements: v0.18.0 - 2025-11-17
695
+
696
+ - 🎉 **New extensions:**
697
+ - **Google Workspace**: Integrate Gemini CLI with your Workspace data. Write
698
+ docs, build slides, chat with others or even get your calc on in sheets:
699
+ `gemini extensions install https://github.com/gemini-cli-extensions/workspace`
700
+ - Blog:
701
+ [https://allen.hutchison.org/2025/11/19/bringing-the-office-to-the-terminal/](https://allen.hutchison.org/2025/11/19/bringing-the-office-to-the-terminal/)
702
+ - **Redis:** Manage and search data in Redis with natural language:
703
+ `gemini extensions install https://github.com/redis/mcp-redis`
704
+ - **Anomalo:** Query your data warehouse table metadata and quality status
705
+ through commands and natural language:
706
+ `gemini extensions install https://github.com/datagravity-ai/anomalo-gemini-extension`
707
+ - **Experimental permission improvements:** We are now experimenting with a new
708
+ policy engine in Gemini CLI. This allows users and administrators to create
709
+ fine-grained policy for tool calls. Currently behind a flag. See
710
+ [policy engine documentation](../reference/policy-engine.md) for more
711
+ information.
712
+ - Blog:
713
+ [https://allen.hutchison.org/2025/11/26/the-guardrails-of-autonomy/](https://allen.hutchison.org/2025/11/26/the-guardrails-of-autonomy/)
714
+ - **Gemini 3 support for paid:** Gemini 3 support has been rolled out to all API
715
+ key, Google AI Pro or Google AI Ultra (for individuals, not businesses) and
716
+ Gemini Code Assist Enterprise users. Enable it via `/settings` and toggling on
717
+ **Preview Features**.
718
+ - **Updated UI rollback:** We’ve temporarily rolled back our updated UI to give
719
+ it more time to bake. This means for a time you won’t have embedded scrolling
720
+ or mouse support. You can re-enable with `/settings` -> **Use Alternate Screen
721
+ Buffer** -> `true`.
722
+ - **Model in history:** Users can now toggle in `/settings` to display model in
723
+ their chat history. ([gif](https://imgur.com/a/uEmNKnQ),
724
+ [pr](https://github.com/google-gemini/gemini-cli/pull/13034) by
725
+ [@scidomino](https://github.com/scidomino))
726
+ - **Multi-uninstall:** Users can now uninstall multiple extensions with a single
727
+ command. ([pic](https://imgur.com/a/9Dtq8u2),
728
+ [pr](https://github.com/google-gemini/gemini-cli/pull/13016) by
729
+ [@JayadityaGit](https://github.com/JayadityaGit))
730
+
731
+ ## Announcements: v0.16.0 - 2025-11-10
732
+
733
+ - **Gemini 3 + Gemini CLI:** launch 🚀🚀🚀
734
+ - **Data Commons Gemini CLI Extension** - A new Data Commons Gemini CLI
735
+ extension that lets you query open-source statistical data from
736
+ datacommons.org. **To get started, you'll need a Data Commons API key and uv
737
+ installed**. These and other details to get you started with the extension can
738
+ be found at
739
+ [https://github.com/gemini-cli-extensions/datacommons](https://github.com/gemini-cli-extensions/datacommons).
740
+
741
+ ## Announcements: v0.15.0 - 2025-11-03
742
+
743
+ - **🎉 Seamless scrollable UI and mouse support:** We’ve given Gemini CLI a
744
+ major facelift to make your terminal experience smoother and much more
745
+ polished. You now get a flicker-free display with sticky headers that keep
746
+ important context visible and a stable input prompt that doesn't jump around.
747
+ We even added mouse support so you can click right where you need to type!
748
+ ([gif](https://imgur.com/a/O6qc7bx),
749
+ [@jacob314](https://github.com/jacob314)).
750
+ - **Announcement:**
751
+ [https://developers.googleblog.com/en/making-the-terminal-beautiful-one-pixel-at-a-time/](https://developers.googleblog.com/en/making-the-terminal-beautiful-one-pixel-at-a-time/)
752
+ - **🎉 New partner extensions:**
753
+
754
+ - **Arize:** Seamlessly instrument AI applications with Arize AX and grant
755
+ direct access to Arize support:
756
+
757
+ `gemini extensions install https://github.com/Arize-ai/arize-tracing-assistant`
758
+
759
+ - **Chronosphere:** Retrieve logs, metrics, traces, events, and specific
760
+ entities:
761
+
762
+ `gemini extensions install https://github.com/chronosphereio/chronosphere-mcp`
763
+
764
+ - **Transmit:** Comprehensive context, validation, and automated fixes for
765
+ creating production-ready authentication and identity workflows:
766
+
767
+ `gemini extensions install https://github.com/TransmitSecurity/transmit-security-journey-builder`
768
+
769
+ - **Todo planning:** Complex questions now get broken down into todo lists that
770
+ the model can manage and check off. ([gif](https://imgur.com/a/EGDfNlZ),
771
+ [pr](https://github.com/google-gemini/gemini-cli/pull/12905) by
772
+ [@anj-s](https://github.com/anj-s))
773
+ - **Disable GitHub extensions:** Users can now prevent the installation and
774
+ loading of extensions from GitHub.
775
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/12838) by
776
+ [@kevinjwang1](https://github.com/kevinjwang1)).
777
+ - **Extensions restart:** Users can now explicitly restart extensions using the
778
+ `/extensions restart` command.
779
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/12739) by
780
+ [@jakemac53](https://github.com/jakemac53)).
781
+ - **Better Angular support:** Angular workflows should now be more seamless
782
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/10252) by
783
+ [@MarkTechson](https://github.com/MarkTechson)).
784
+ - **Validate command:** Users can now check that local extensions are formatted
785
+ correctly. ([pr](https://github.com/google-gemini/gemini-cli/pull/12186) by
786
+ [@kevinjwang1](https://github.com/kevinjwang1)).
787
+
788
+ ## Announcements: v0.12.0 - 2025-10-27
789
+
790
+ ![Codebase investigator subagent in Gemini CLI.](https://i.imgur.com/4J1njsx.png)
791
+
792
+ - **🎉 New partner extensions:**
793
+
794
+ - **🤗 Hugging Face extension:** Access the Hugging Face hub.
795
+ ([gif](https://drive.google.com/file/d/1LEzIuSH6_igFXq96_tWev11svBNyPJEB/view?usp=sharing&resourcekey=0-LtPTzR1woh-rxGtfPzjjfg))
796
+
797
+ `gemini extensions install https://github.com/huggingface/hf-mcp-server`
798
+
799
+ - **Monday.com extension**: Analyze your sprints, update your task boards,
800
+ etc.
801
+ ([gif](https://drive.google.com/file/d/1cO0g6kY1odiBIrZTaqu5ZakaGZaZgpQv/view?usp=sharing&resourcekey=0-xEr67SIjXmAXRe1PKy7Jlw))
802
+
803
+ `gemini extensions install https://github.com/mondaycom/mcp`
804
+
805
+ - **Data Commons extension:** Query public datasets or ground responses on
806
+ data from Data Commons
807
+ ([gif](https://drive.google.com/file/d/1cuj-B-vmUkeJnoBXrO_Y1CuqphYc6p-O/view?usp=sharing&resourcekey=0-0adXCXDQEd91ZZW63HbW-Q)).
808
+
809
+ `gemini extensions install https://github.com/gemini-cli-extensions/datacommons`
810
+
811
+ - **Model selection:** Choose the Gemini model for your session with `/model`.
812
+ ([pic](https://imgur.com/a/ABFcWWw),
813
+ [pr](https://github.com/google-gemini/gemini-cli/pull/8940) by
814
+ [@abhipatel12](https://github.com/abhipatel12)).
815
+ - **Model routing:** Gemini CLI will now intelligently pick the best model for
816
+ the task. Simple queries will be sent to Flash while complex analytical or
817
+ creative tasks will still use the power of Pro. This ensures your quota will
818
+ last for a longer period of time. You can always opt-out of this via `/model`.
819
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/9262) by
820
+ [@abhipatel12](https://github.com/abhipatel12)).
821
+ - Discussion:
822
+ [https://github.com/google-gemini/gemini-cli/discussions/12375](https://github.com/google-gemini/gemini-cli/discussions/12375)
823
+ - **Codebase investigator subagent:** We now have a new built-in subagent that
824
+ will explore your workspace and resolve relevant information to improve
825
+ overall performance.
826
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/9988) by
827
+ [@abhipatel12](https://github.com/abhipatel12),
828
+ [pr](https://github.com/google-gemini/gemini-cli/pull/10282) by
829
+ [@silviojr](https://github.com/silviojr)).
830
+ - Enable, disable, or limit turns in `/settings`, plus advanced configs in
831
+ `settings.json` ([pic](https://imgur.com/a/yJiggNO),
832
+ [pr](https://github.com/google-gemini/gemini-cli/pull/10844) by
833
+ [@silviojr](https://github.com/silviojr)).
834
+ - **Explore extensions with `/extension`:** Users can now open the extensions
835
+ page in their default browser directly from the CLI using the `/extension`
836
+ explore command. ([pr](https://github.com/google-gemini/gemini-cli/pull/11846)
837
+ by [@JayadityaGit](https://github.com/JayadityaGit)).
838
+ - **Configurable compression:** Users can modify the context compression
839
+ threshold in `/settings` (decimal with percentage display). The default has
840
+ been made more proactive
841
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/12317) by
842
+ [@scidomino](https://github.com/scidomino)).
843
+ - **API key authentication:** Users can now securely enter and store their
844
+ Gemini API key via a new dialog, eliminating the need for environment
845
+ variables and repeated entry.
846
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/11760) by
847
+ [@galz10](https://github.com/galz10)).
848
+ - **Sequential approval:** Users can now approve multiple tool calls
849
+ sequentially during execution.
850
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/11593) by
851
+ [@joshualitt](https://github.com/joshualitt)).
852
+
853
+ ## Announcements: v0.11.0 - 2025-10-20
854
+
855
+ ![Gemini CLI and Jules](https://storage.googleapis.com/gweb-developer-goog-blog-assets/images/Jules_Extension_-_Blog_Header_O346JNt.original.png)
856
+
857
+ - �� **Gemini CLI Jules Extension:** Use Gemini CLI to orchestrate Jules. Spawn
858
+ remote workers, delegate tedious tasks, or check in on running jobs!
859
+ - Install:
860
+ `gemini extensions install https://github.com/gemini-cli-extensions/jules`
861
+ - Announcement:
862
+ [https://developers.googleblog.com/en/introducing-the-jules-extension-for-gemini-cli/](https://developers.googleblog.com/en/introducing-the-jules-extension-for-gemini-cli/)
863
+ - **Stream JSON output:** Stream real-time JSONL events with
864
+ `--output-format stream-json` to monitor AI agent progress when run
865
+ headlessly. ([gif](https://imgur.com/a/0UCE81X),
866
+ [pr](https://github.com/google-gemini/gemini-cli/pull/10883) by
867
+ [@anj-s](https://github.com/anj-s))
868
+ - **Markdown toggle:** Users can now switch between rendered and raw markdown
869
+ display using `alt+m `or` ctrl+m`. ([gif](https://imgur.com/a/lDNdLqr),
870
+ [pr](https://github.com/google-gemini/gemini-cli/pull/10383) by
871
+ [@srivatsj](https://github.com/srivatsj))
872
+ - **Queued message editing:** Users can now quickly edit queued messages by
873
+ pressing the up arrow key when the input is empty.
874
+ ([gif](https://imgur.com/a/ioRslLd),
875
+ [pr](https://github.com/google-gemini/gemini-cli/pull/10392) by
876
+ [@akhil29](https://github.com/akhil29))
877
+ - **JSON web fetch**: Non-HTML content like JSON APIs or raw source code are now
878
+ properly shown to the model (previously only supported HTML)
879
+ ([gif](https://imgur.com/a/Q58U4qJ),
880
+ [pr](https://github.com/google-gemini/gemini-cli/pull/11284) by
881
+ [@abhipatel12](https://github.com/abhipatel12))
882
+ - **Non-interactive MCP commands:** Users can now run MCP slash commands in
883
+ non-interactive mode `gemini "/some-mcp-prompt"`.
884
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/10194) by
885
+ [@capachino](https://github.com/capachino))
886
+ - **Removal of deprecated flags:** We’ve finally removed a number of deprecated
887
+ flags to cleanup Gemini CLI’s invocation profile:
888
+ - `--all-files` / `-a` in favor of `@` from within Gemini CLI.
889
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/11228) by
890
+ [@allenhutchison](https://github.com/allenhutchison))
891
+ - `--telemetry-*` flags in favor of
892
+ [environment variables](https://github.com/google-gemini/gemini-cli/pull/11318)
893
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/11318) by
894
+ [@allenhutchison](https://github.com/allenhutchison))
895
+
896
+ ## Announcements: v0.10.0 - 2025-10-13
897
+
898
+ - **Polish:** The team has been heads down bug fixing and investing heavily into
899
+ polishing existing flows, tools, and interactions.
900
+ - **Interactive Shell Tool calling:** Gemini CLI can now also execute
901
+ interactive tools if needed
902
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/11225) by
903
+ [@galz10](https://github.com/galz10)).
904
+ - **Alt+Key support:** Enables broader support for Alt+Key keyboard shortcuts
905
+ across different terminals.
906
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/10767) by
907
+ [@srivatsj](https://github.com/srivatsj)).
908
+ - **Telemetry Diff stats:** Track line changes made by the model and user during
909
+ file operations via OTEL.
910
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/10819) by
911
+ [@jerop](https://github.com/jerop)).
912
+
913
+ ## Announcements: v0.9.0 - 2025-10-06
914
+
915
+ - 🎉 **Interactive Shell:** Run interactive commands like `vim`, `rebase -i`, or
916
+ even `gemini` 😎 directly in Gemini CLI:
917
+ - Blog:
918
+ [https://developers.googleblog.com/en/say-hello-to-a-new-level-of-interactivity-in-gemini-cli/](https://developers.googleblog.com/en/say-hello-to-a-new-level-of-interactivity-in-gemini-cli/)
919
+ - **Install pre-release extensions:** Install the latest `--pre-release`
920
+ versions of extensions. Used for when an extension’s release hasn’t been
921
+ marked as "latest".
922
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/10752) by
923
+ [@jakemac53](https://github.com/jakemac53))
924
+ - **Simplified extension creation:** Create a new, empty extension. Templates
925
+ are no longer required.
926
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/10629) by
927
+ [@chrstnb](https://github.com/chrstnb))
928
+ - **OpenTelemetry GenAI metrics:** Aligns telemetry with industry-standard
929
+ semantic conventions for improved interoperability.
930
+ ([spec](https://opentelemetry.io/docs/concepts/semantic-conventions/),
931
+ [pr](https://github.com/google-gemini/gemini-cli/pull/10343) by
932
+ [@jerop](https://github.com/jerop))
933
+ - **List memory files:** Quickly find the location of your long-term memory
934
+ files with `/memory list`.
935
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/10108) by
936
+ [@sgnagnarella](https://github.com/sgnagnarella))
937
+
938
+ ## Announcements: v0.8.0 - 2025-09-29
939
+
940
+ - 🎉 **Announcing Gemini CLI Extensions** 🎉
941
+ - Completely customize your Gemini CLI experience to fit your workflow.
942
+ - Build and share your own Gemini CLI extensions with the world.
943
+ - Launching with a growing catalog of community, partner, and Google-built
944
+ extensions.
945
+ - Check extensions from
946
+ [key launch partners](https://github.com/google-gemini/gemini-cli/discussions/10718).
947
+ - Easy install:
948
+ - `gemini extensions install <github url|folder path>`
949
+ - Easy management:
950
+ - `gemini extensions install|uninstall|link`
951
+ - `gemini extensions enable|disable`
952
+ - `gemini extensions list|update|new`
953
+ - Or use commands while running with `/extensions list|update`.
954
+ - Everything you need to know:
955
+ [Now open for building: Introducing Gemini CLI extensions](https://blog.google/technology/developers/gemini-cli-extensions/).
956
+ - 🎉 **Our New Home Page & Better Documentation** 🎉
957
+ - Check out our new home page for better getting started material, reference
958
+ documentation, extensions and more!
959
+ - _Homepage:_ [https://geminicli.com](https://geminicli.com)
960
+ - ‼️*NEW documentation:*
961
+ [https://geminicli.com/docs](https://geminicli.com/docs) (Have any
962
+ [suggestions](https://github.com/google-gemini/gemini-cli/discussions/8722)?)
963
+ - _Extensions:_
964
+ [https://geminicli.com/extensions](https://geminicli.com/extensions)
965
+ - **Non-Interactive Allowed Tools:** `--allowed-tools` will now also work in
966
+ non-interactive mode.
967
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/9114) by
968
+ [@mistergarrison](https://github.com/mistergarrison))
969
+ - **Terminal Title Status:** See the CLI's real-time status and thoughts
970
+ directly in the terminal window's title by setting `showStatusInTitle: true`.
971
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/4386) by
972
+ [@Fridayxiao](https://github.com/Fridayxiao))
973
+ - **Small features, polish, reliability & bug fixes:** A large amount of
974
+ changes, smaller features, UI updates, reliability and bug fixes + general
975
+ polish made it in this week!
976
+
977
+ ## Announcements: v0.7.0 - 2025-09-22
978
+
979
+ - 🎉**Build your own Gemini CLI IDE plugin:** We've published a spec for
980
+ creating IDE plugins to enable rich context-aware experiences and native
981
+ in-editor diffing in your IDE of choice.
982
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/8479) by
983
+ [@skeshive](https://github.com/skeshive))
984
+ - 🎉 **Gemini CLI extensions**
985
+ - **Flutter:** An early version to help you create, build, test, and run
986
+ Flutter apps with Gemini CLI
987
+ ([extension](https://github.com/gemini-cli-extensions/flutter))
988
+ - **nanobanana:** Integrate nanobanana into Gemini CLI
989
+ ([extension](https://github.com/gemini-cli-extensions/nanobanana))
990
+ - **Telemetry config via environment:** Manage telemetry settings using
991
+ environment variables for a more flexible setup.
992
+ ([docs](https://github.com/google-gemini/gemini-cli/blob/main/docs/cli/telemetry.md#configuration),
993
+ [pr](https://github.com/google-gemini/gemini-cli/pull/9113) by
994
+ [@jerop](https://github.com/jerop))
995
+ - **​​Experimental todos:** Track and display progress on complex tasks with a
996
+ managed checklist. Off by default but can be enabled via
997
+ `"useWriteTodos": true`
998
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/8761) by
999
+ [@anj-s](https://github.com/anj-s))
1000
+ - **Share chat support for tools:** Using `/chat share` will now also render
1001
+ function calls and responses in the final markdown file.
1002
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/8693) by
1003
+ [@rramkumar1](https://github.com/rramkumar1))
1004
+ - **Citations:** Now enabled for all users
1005
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/8570) by
1006
+ [@scidomino](https://github.com/scidomino))
1007
+ - **Custom commands in Headless Mode:** Run custom slash commands directly from
1008
+ the command line in non-interactive mode: `gemini "/joke Chuck Norris"`
1009
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/8305) by
1010
+ [@capachino](https://github.com/capachino))
1011
+ - **Small features, polish, reliability & bug fixes:** A large amount of
1012
+ changes, smaller features, UI updates, reliability and bug fixes + general
1013
+ polish made it in this week!
1014
+
1015
+ ## Announcements: v0.6.0 - 2025-09-15
1016
+
1017
+ - 🎉 **Higher limits for Google AI Pro and Ultra subscribers:** We’re psyched to
1018
+ finally announce that Google AI Pro and AI Ultra subscribers now get access to
1019
+ significantly higher 2.5 quota limits for Gemini CLI!
1020
+ - **Announcement:**
1021
+ [https://blog.google/technology/developers/gemini-cli-code-assist-higher-limits/](https://blog.google/technology/developers/gemini-cli-code-assist-higher-limits/)
1022
+ - 🎉**Gemini CLI Databases and BigQuery Extensions:** Connect Gemini CLI to all
1023
+ of your cloud data with Gemini CLI.
1024
+ - Announcement and how to get started with each of the below extensions:
1025
+ [https://cloud.google.com/blog/products/databases/gemini-cli-extensions-for-google-data-cloud?e=48754805](https://cloud.google.com/blog/products/databases/gemini-cli-extensions-for-google-data-cloud?e=48754805)
1026
+ - **AlloyDB:** Interact, manage and observe AlloyDB for PostgreSQL databases
1027
+ ([manage](https://github.com/gemini-cli-extensions/alloydb#configuration),
1028
+ [observe](https://github.com/gemini-cli-extensions/alloydb-observability#configuration))
1029
+ - **BigQuery:** Connect and query your BigQuery datasets or utilize a
1030
+ sub-agent for contextual insights
1031
+ ([query](https://github.com/gemini-cli-extensions/bigquery-data-analytics#configuration),
1032
+ [sub-agent](https://github.com/gemini-cli-extensions/bigquery-conversational-analytics))
1033
+ - **Cloud SQL:** Interact, manage and observe Cloud SQL for PostgreSQL
1034
+ ([manage](https://github.com/gemini-cli-extensions/cloud-sql-postgresql#configuration),[ observe](https://github.com/gemini-cli-extensions/cloud-sql-postgresql-observability#configuration)),
1035
+ Cloud SQL for MySQL
1036
+ ([manage](https://github.com/gemini-cli-extensions/cloud-sql-mysql#configuration),[ observe](https://github.com/gemini-cli-extensions/cloud-sql-mysql-observability#configuration))
1037
+ and Cloud SQL for SQL Server
1038
+ ([manage](https://github.com/gemini-cli-extensions/cloud-sql-sqlserver#configuration),[ observe](https://github.com/gemini-cli-extensions/cloud-sql-sqlserver-observability#configuration))
1039
+ databases.
1040
+ - **Dataplex:** Discover, manage, and govern data and AI artifacts
1041
+ ([extension](https://github.com/gemini-cli-extensions/dataplex#configuration))
1042
+ - **Firestore:** Interact with Firestore databases, collections and documents
1043
+ ([extension](https://github.com/gemini-cli-extensions/firestore-native#configuration))
1044
+ - **Looker:** Query data, run Looks and create dashboards
1045
+ ([extension](https://github.com/gemini-cli-extensions/looker#configuration))
1046
+ - **MySQL:** Interact with MySQL databases
1047
+ ([extension](https://github.com/gemini-cli-extensions/mysql#configuration))
1048
+ - **Postgres:** Interact with PostgreSQL databases
1049
+ ([extension](https://github.com/gemini-cli-extensions/postgres#configuration))
1050
+ - **Spanner:** Interact with Spanner databases
1051
+ ([extension](https://github.com/gemini-cli-extensions/spanner#configuration))
1052
+ - **SQL Server:** Interact with SQL Server databases
1053
+ ([extension](https://github.com/gemini-cli-extensions/sql-server#configuration))
1054
+ - **MCP Toolbox:** Configure and load custom tools for more than 30+ data
1055
+ sources
1056
+ ([extension](https://github.com/gemini-cli-extensions/mcp-toolbox#configuration))
1057
+ - **JSON output mode:** Have Gemini CLI output JSON with `--output-format json`
1058
+ when invoked headlessly for easy parsing and post-processing. Includes
1059
+ response, stats and errors.
1060
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/8119) by
1061
+ [@jerop](https://github.com/jerop))
1062
+ - **Keybinding triggered approvals:** When you use shortcuts (`shift+y` or
1063
+ `shift+tab`) to activate YOLO/auto-edit modes any pending confirmation dialogs
1064
+ will now approve. ([pr](https://github.com/google-gemini/gemini-cli/pull/6665)
1065
+ by [@bulkypanda](https://github.com/bulkypanda))
1066
+ - **Chat sharing:** Convert the current conversation to a Markdown or JSON file
1067
+ with _/chat share &lt;file.md|file.json>_
1068
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/8139) by
1069
+ [@rramkumar1](https://github.com/rramkumar1))
1070
+ - **Prompt search:** Search your prompt history using `ctrl+r`.
1071
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/5539) by
1072
+ [@Aisha630](https://github.com/Aisha630))
1073
+ - **Input undo/redo:** Recover accidentally deleted text in the input prompt
1074
+ using `ctrl+z` (undo) and `ctrl+shift+z` (redo).
1075
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/4625) by
1076
+ [@masiafrest](https://github.com/masiafrest))
1077
+ - **Loop detection confirmation:** When loops are detected you are now presented
1078
+ with a dialog to disable detection for the current session.
1079
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/8231) by
1080
+ [@SandyTao520](https://github.com/SandyTao520))
1081
+ - **Direct to Google Cloud Telemetry:** Directly send telemetry to Google Cloud
1082
+ for a simpler and more streamlined setup.
1083
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/8541) by
1084
+ [@jerop](https://github.com/jerop))
1085
+ - **Visual Mode Indicator Revamp:** ‘shell’, 'accept edits' and 'yolo' modes now
1086
+ have colors to match their impact / usage. Input box now also updates.
1087
+ ([shell](https://imgur.com/a/DovpVF1),
1088
+ [accept-edits](https://imgur.com/a/33KDz3J),
1089
+ [yolo](https://imgur.com/a/tbFwIWp),
1090
+ [pr](https://github.com/google-gemini/gemini-cli/pull/8200) by
1091
+ [@miguelsolorio](https://github.com/miguelsolorio))
1092
+ - **Small features, polish, reliability & bug fixes:** A large amount of
1093
+ changes, smaller features, UI updates, reliability and bug fixes + general
1094
+ polish made it in this week!
1095
+
1096
+ ## Announcements: v0.5.0 - 2025-09-08
1097
+
1098
+ - 🎉**FastMCP + Gemini CLI**🎉: Quickly install and manage your Gemini CLI MCP
1099
+ servers with FastMCP ([video](https://imgur.com/a/m8QdCPh),
1100
+ [pr](https://github.com/jlowin/fastmcp/pull/1709) by
1101
+ [@jackwotherspoon](https://github.com/jackwotherspoon)**)**
1102
+ - Getting started:
1103
+ [https://gofastmcp.com/integrations/gemini-cli](https://gofastmcp.com/integrations/gemini-cli)
1104
+ - **Positional Prompt for Non-Interactive:** Seamlessly invoke Gemini CLI
1105
+ headlessly via `gemini "Hello"`. Synonymous with passing `-p`.
1106
+ ([gif](https://imgur.com/a/hcBznpB),
1107
+ [pr](https://github.com/google-gemini/gemini-cli/pull/7668) by
1108
+ [@allenhutchison](https://github.com/allenhutchison))
1109
+ - **Experimental Tool output truncation:** Enable truncating shell tool outputs
1110
+ and saving full output to a file by setting
1111
+ `"enableToolOutputTruncation": true `([pr](https://github.com/google-gemini/gemini-cli/pull/8039)
1112
+ by [@SandyTao520](https://github.com/SandyTao520))
1113
+ - **Edit Tool improvements:** Gemini CLI’s ability to edit files should now be
1114
+ far more capable. ([pr](https://github.com/google-gemini/gemini-cli/pull/7679)
1115
+ by [@silviojr](https://github.com/silviojr))
1116
+ - **Custom witty messages:** The feature you’ve all been waiting for…
1117
+ Personalized witty loading messages via
1118
+ `"ui": { "customWittyPhrases": ["YOLO"]}` in `settings.json`.
1119
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/7641) by
1120
+ [@JayadityaGit](https://github.com/JayadityaGit))
1121
+ - **Nested .gitignore File Handling:** Nested `.gitignore` files are now
1122
+ respected. ([pr](https://github.com/google-gemini/gemini-cli/pull/7645) by
1123
+ [@gsquared94](https://github.com/gsquared94))
1124
+ - **Enforced authentication:** System administrators can now mandate a specific
1125
+ authentication method via
1126
+ `"enforcedAuthType": "oauth-personal|gemini-api-key|…"`in `settings.json`.
1127
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/6564) by
1128
+ [@chrstnb](https://github.com/chrstnb))
1129
+ - **A2A development-tool extension:** An RFC for an Agent2Agent
1130
+ ([A2A](https://a2a-protocol.org/latest/)) powered extension for developer tool
1131
+ use cases.
1132
+ ([feedback](https://github.com/google-gemini/gemini-cli/discussions/7822),
1133
+ [pr](https://github.com/google-gemini/gemini-cli/pull/7817) by
1134
+ [@skeshive](https://github.com/skeshive))
1135
+ - **Hands on Codelab:
1136
+ **[https://codelabs.developers.google.com/gemini-cli-hands-on](https://codelabs.developers.google.com/gemini-cli-hands-on)
1137
+ - **Small features, polish, reliability & bug fixes:** A large amount of
1138
+ changes, smaller features, UI updates, reliability and bug fixes + general
1139
+ polish made it in this week!
1140
+
1141
+ ## Announcements: v0.4.0 - 2025-09-01
1142
+
1143
+ - 🎉**Gemini CLI CloudRun and Security Integrations**🎉: Automate app deployment
1144
+ and security analysis with CloudRun and Security extension integrations. Once
1145
+ installed deploy your app to the cloud with `/deploy` and find and fix
1146
+ security vulnerabilities with `/security:analyze`.
1147
+ - Announcement and how to get started:
1148
+ [https://cloud.google.com/blog/products/ai-machine-learning/automate-app-deployment-and-security-analysis-with-new-gemini-cli-extensions](https://cloud.google.com/blog/products/ai-machine-learning/automate-app-deployment-and-security-analysis-with-new-gemini-cli-extensions)
1149
+ - **Experimental**
1150
+ - **Edit Tool:** Give our new edit tool a try by setting
1151
+ `"useSmartEdit": true` in `settings.json`!
1152
+ ([feedback](https://github.com/google-gemini/gemini-cli/discussions/7758),
1153
+ [pr](https://github.com/google-gemini/gemini-cli/pull/6823) by
1154
+ [@silviojr](https://github.com/silviojr))
1155
+ - **Model talking to itself fix:** We’ve removed a model workaround that would
1156
+ encourage Gemini CLI to continue conversations on your behalf. This may be
1157
+ disruptive and can be disabled via `"skipNextSpeakerCheck": false` in your
1158
+ `settings.json`
1159
+ ([feedback](https://github.com/google-gemini/gemini-cli/discussions/6666),
1160
+ [pr](https://github.com/google-gemini/gemini-cli/pull/7614) by
1161
+ [@SandyTao520](https://github.com/SandyTao520))
1162
+ - **Prompt completion:** Get real-time AI suggestions to complete your prompts
1163
+ as you type. Enable it with `"general": { "enablePromptCompletion": true }`
1164
+ and share your feedback!
1165
+ ([gif](https://miro.medium.com/v2/resize:fit:2000/format:webp/1*hvegW7YXOg6N_beUWhTdxA.gif),
1166
+ [pr](https://github.com/google-gemini/gemini-cli/pull/4691) by
1167
+ [@3ks](https://github.com/3ks))
1168
+ - **Footer visibility configuration:** Customize the CLI's footer look and feel
1169
+ in `settings.json`
1170
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/7419) by
1171
+ [@miguelsolorio](https://github.com/miguelsolorio))
1172
+ - `hideCWD`: hide current working directory.
1173
+ - `hideSandboxStatus`: hide sandbox status.
1174
+ - `hideModelInfo`: hide current model information.
1175
+ - `hideContextSummary`: hide request context summary.
1176
+ - **Citations:** For enterprise Code Assist licenses users will now see
1177
+ citations in their responses by default. Enable this yourself with
1178
+ `"showCitations": true`
1179
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/7350) by
1180
+ [@scidomino](https://github.com/scidomino))
1181
+ - **Pro Quota Dialog:** Handle daily Pro model usage limits with an interactive
1182
+ dialog that lets you immediately switch auth or fallback.
1183
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/7094) by
1184
+ [@JayadityaGit](https://github.com/JayadityaGit))
1185
+ - **Custom commands @:** Embed local file or directory content directly into
1186
+ your custom command prompts using `@{path}` syntax
1187
+ ([gif](https://miro.medium.com/v2/resize:fit:2000/format:webp/1*GosBAo2SjMfFffAnzT7ZMg.gif),
1188
+ [pr](https://github.com/google-gemini/gemini-cli/pull/6716) by
1189
+ [@abhipatel12](https://github.com/abhipatel12))
1190
+ - **2.5 Flash Lite support:** You can now use the `gemini-2.5-flash-lite` model
1191
+ for Gemini CLI via `gemini -m …`.
1192
+ ([gif](https://miro.medium.com/v2/resize:fit:2000/format:webp/1*P4SKwnrsyBuULoHrFqsFKQ.gif),
1193
+ [pr](https://github.com/google-gemini/gemini-cli/pull/4652) by
1194
+ [@psinha40898](https://github.com/psinha40898))
1195
+ - **CLI streamlining:** We have deprecated a number of command line arguments in
1196
+ favor of `settings.json` alternatives. We will remove these arguments in a
1197
+ future release. See the PR for the full list of deprecations.
1198
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/7360) by
1199
+ [@allenhutchison](https://github.com/allenhutchison))
1200
+ - **JSON session summary:** Track and save detailed CLI session statistics to a
1201
+ JSON file for performance analysis with `--session-summary <path>`
1202
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/7347) by
1203
+ [@leehagoodjames](https://github.com/leehagoodjames))
1204
+ - **Robust keyboard handling:** More reliable and consistent behavior for arrow
1205
+ keys, special keys (Home, End, etc.), and modifier combinations across various
1206
+ terminals. ([pr](https://github.com/google-gemini/gemini-cli/pull/7118) by
1207
+ [@deepankarsharma](https://github.com/deepankarsharma))
1208
+ - **MCP loading indicator:** Provides visual feedback during CLI initialization
1209
+ when connecting to multiple servers.
1210
+ ([pr](https://github.com/google-gemini/gemini-cli/pull/6923) by
1211
+ [@swissspidy](https://github.com/swissspidy))
1212
+ - **Small features, polish, reliability & bug fixes:** A large amount of
1213
+ changes, smaller features, UI updates, reliability and bug fixes + general
1214
+ polish made it in this week!
docs/changelogs/latest.md ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Latest stable release: v0.60.0
2
+
3
+ Released: September 15, 2026
4
+
5
+ For most users, our latest stable release is the recommended release. Install
6
+ the latest stable version with:
7
+
8
+ ```
9
+ npm install -g @google/gemini-cli
10
+ ```
11
+
12
+ ## Highlights
13
+
14
+ - **Extension Consent & Isolation:** Introduced explicit prompting for user
15
+ consent on environment changes requested by extensions, along with
16
+ sanitization of runtime-altering environment variables to ensure secure
17
+ execution environments.
18
+ - **Sandbox & Directory Hardening:** Isolated the settings directory and
19
+ temporary directories within sandbox containers, including specific path
20
+ isolation enhancements for the macOS Seatbelt sandbox.
21
+ - **Robust Boundary & Path Resolution:** Hardened workspace boundary validation,
22
+ symlink resolution, and NTFS 8.3 short name (SFN) path mitigation across
23
+ command safety and file discovery utilities.
24
+ - **Enhanced API & Connection Security:** Implemented strict RFC 9207 issuer
25
+ identification in the Model Context Protocol (MCP) OAuth flow, along with
26
+ improved destination validation and connection routing inside web fetch
27
+ utilities.
28
+
29
+ ## What's Changed
30
+
31
+ - fix(core): improve destination validation and connection routing in web fetch
32
+ utilities by @diegogodinezr in
33
+ [#29120](https://github.com/google-gemini/gemini-cli/pull/29120)
34
+ - fix(core): enforce RFC 9207 issuer identification in MCP OAuth flow by
35
+ @jvargassanchez-dot in
36
+ [#29117](https://github.com/google-gemini/gemini-cli/pull/29117)
37
+ - chore(release): bump version to 0.60.0-nightly.20260901.g0bd1d4397 by
38
+ @gemini-cli-robot in
39
+ [#29162](https://github.com/google-gemini/gemini-cli/pull/29162)
40
+ - Changelog for v0.58.0 by @gemini-cli-robot in
41
+ [#29161](https://github.com/google-gemini/gemini-cli/pull/29161)
42
+ - fix(cli): isolate temporary directory for macOS Seatbelt sandbox by
43
+ @jvargassanchez-dot in
44
+ [#29171](https://github.com/google-gemini/gemini-cli/pull/29171)
45
+ - feat(extensions): harden path resolution and boundary validation in extension
46
+ loader by @diegogodinezr in
47
+ [#29169](https://github.com/google-gemini/gemini-cli/pull/29169)
48
+ - Changelog for v0.59.0-preview.0 by @gemini-cli-robot in
49
+ [#29159](https://github.com/google-gemini/gemini-cli/pull/29159)
50
+ - fix(core): sanitize and remove hardcoded Google CrUX API key in
51
+ chrome-devtools-mcp by @amelidev in
52
+ [#29158](https://github.com/google-gemini/gemini-cli/pull/29158)
53
+ - fix(extensions): prompt for consent on environment changes and sanitize
54
+ runtime-altering environment variables by @amelidev in
55
+ [#28863](https://github.com/google-gemini/gemini-cli/pull/28863)
56
+ - fix(core): enhance workspace path boundary checks and symlink resolution in
57
+ command safety and file discovery by @jesussamuel-byte in
58
+ [#29170](https://github.com/google-gemini/gemini-cli/pull/29170)
59
+ - fix(config): enforce strict permission and ownership checks on system-wide
60
+ configuration paths by @jesussamuel-byte in
61
+ [#29115](https://github.com/google-gemini/gemini-cli/pull/29115)
62
+ - fix(core): mitigate NTFS 8.3 short name (SFN) path by @urielefrenvirtusa in
63
+ [#29116](https://github.com/google-gemini/gemini-cli/pull/29116)
64
+ - fix(cli): isolate settings directory in sandbox containers by
65
+ @jvargassanchez-dot in
66
+ [#29216](https://github.com/google-gemini/gemini-cli/pull/29216)
67
+ - fix(core): enforce envelope metadata provenance for untrusted tool outputs by
68
+ @luisfelipe-alt in
69
+ [#29215](https://github.com/google-gemini/gemini-cli/pull/29215)
70
+
71
+ **Full Changelog**:
72
+ https://github.com/google-gemini/gemini-cli/compare/v0.59.0...v0.60.0
docs/changelogs/preview.md ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Preview release: v0.61.0-preview.0
2
+
3
+ Released: September 15, 2026
4
+
5
+ Our preview release includes the latest, new, and experimental features. This
6
+ release may not be as stable as our [latest weekly release](latest.md).
7
+
8
+ To install the preview release:
9
+
10
+ ```
11
+ npm install -g @google/gemini-cli@preview
12
+ ```
13
+
14
+ ## Highlights
15
+
16
+ - **Sandbox Isolation**: Enhanced filesystem boundaries and isolated runtime
17
+ state within the sandbox environments to restrict untrusted execution.
18
+ - **Prompt Injection Defense**: Prevented potential indirect prompt injection
19
+ vulnerabilities related to build file modifications and untrusted command
20
+ flags.
21
+ - **Flash Model ID Preservation**: Fixed core logic to properly preserve
22
+ explicit, versioned Flash model IDs without overriding them.
23
+ - **Agent Loop Reliability**: Resolved an issue where crucial `AgentLoopContext`
24
+ properties were discarded during object spread, stabilizing the main agent
25
+ loop.
26
+
27
+ ## What's Changed
28
+
29
+ - Changelog for v0.60.0-preview.0 by @gemini-cli-robot in
30
+ [#29251](https://github.com/google-gemini/gemini-cli/pull/29251)
31
+ - chore(release): bump version to 0.61.0-nightly.20260908.gc647533d6 by
32
+ @gemini-cli-robot in
33
+ [#29254](https://github.com/google-gemini/gemini-cli/pull/29254)
34
+ - Changelog for v0.59.0 by @gemini-cli-robot in
35
+ [#29253](https://github.com/google-gemini/gemini-cli/pull/29253)
36
+ - fix(core): preserve explicit versioned Flash model IDs by @SandyTao520 in
37
+ [#29252](https://github.com/google-gemini/gemini-cli/pull/29252)
38
+ - fix(core): prevent indirect prompt injection via build file modifications and
39
+ untrusted flags by @villahernandez-coder in
40
+ [#29250](https://github.com/google-gemini/gemini-cli/pull/29250)
41
+ - fix(sandbox): harden filesystem boundaries and isolate runtime state by
42
+ @diegogodinezr in
43
+ [#29214](https://github.com/google-gemini/gemini-cli/pull/29214)
44
+ - fix(core): ensure AgentLoopContext properties are preserved across object
45
+ spread by @diegogodinezr in
46
+ [#29335](https://github.com/google-gemini/gemini-cli/pull/29335)
47
+
48
+ **Full Changelog**:
49
+ https://github.com/google-gemini/gemini-cli/compare/v0.60.0-preview.0...v0.61.0-preview.0
docs/cli/acp-mode.md ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ACP Mode
2
+
3
+ ACP (Agent Client Protocol) mode is a special operational mode of Gemini CLI
4
+ designed for programmatic control, primarily for IDE and other developer tool
5
+ integrations. It uses a JSON-RPC protocol over stdio to communicate between
6
+ Gemini CLI agent and a client.
7
+
8
+ To start Gemini CLI in ACP mode, use the `--acp` flag:
9
+
10
+ ```bash
11
+ gemini --acp
12
+ ```
13
+
14
+ ## Agent Client Protocol (ACP)
15
+
16
+ ACP is an open protocol that standardizes how AI coding agents communicate with
17
+ code editors and IDEs. It addresses the challenge of fragmented distribution,
18
+ where agents traditionally needed custom integrations for each client. With ACP,
19
+ developers can implement their agent once, and it becomes compatible with any
20
+ ACP-compliant editor.
21
+
22
+ For a comprehensive introduction to ACP, including its architecture and
23
+ benefits, refer to the official
24
+ [ACP Introduction](https://agentclientprotocol.com/get-started/introduction)
25
+ documentation.
26
+
27
+ ### Existing integrations using ACP
28
+
29
+ The ACP Agent Registry simplifies the distribution and management of
30
+ ACP-compatible agents across various IDEs. Gemini CLI is an ACP-compatible agent
31
+ and can be found in this registry.
32
+
33
+ For more general information about the registry, and how to use it with specific
34
+ IDEs like JetBrains and Zed, refer to the
35
+ [IDE Integration](../ide-integration/index.md) documentation.
36
+
37
+ You can also find more information on the official
38
+ [ACP Agent Registry](https://agentclientprotocol.com/get-started/registry) page.
39
+
40
+ ## Architecture and protocol basics
41
+
42
+ ACP mode establishes a client-server relationship between your tool (the client)
43
+ and Gemini CLI (the server).
44
+
45
+ - **Communication:** The entire communication happens over standard input/output
46
+ (stdio) using the JSON-RPC 2.0 protocol.
47
+ - **Client's role:** The client is responsible for sending requests (for
48
+ example, prompts) and handling responses and notifications from Gemini CLI.
49
+ - **Gemini CLI's role:** In ACP mode, Gemini CLI listens for incoming JSON-RPC
50
+ requests, processes them, and sends back responses.
51
+
52
+ The core of the ACP implementation can be found in
53
+ `packages/cli/src/acp/acpClient.ts`.
54
+
55
+ ### Extending with MCP
56
+
57
+ ACP can be used with the Model Context Protocol (MCP). This lets an ACP client
58
+ (like an IDE) expose its own functionality as "tools" that the Gemini model can
59
+ use.
60
+
61
+ 1. The client implements an **MCP server** that advertises its tools.
62
+ 2. During the ACP `initialize` handshake, the client provides the connection
63
+ details for its MCP server.
64
+ 3. Gemini CLI connects to the MCP server, discovers the available tools, and
65
+ makes them available to the AI model.
66
+ 4. When the model decides to use one of these tools, Gemini CLI sends a tool
67
+ call request to the MCP server.
68
+
69
+ This mechanism lets for a powerful, two-way integration where the agent can
70
+ leverage the IDE's capabilities to perform tasks. The MCP client logic is in
71
+ `packages/core/src/tools/mcp-client.ts`.
72
+
73
+ ## Capabilities and supported methods
74
+
75
+ The ACP protocol exposes a number of methods for ACP clients (for example IDEs)
76
+ to control Gemini CLI.
77
+
78
+ ### Core methods
79
+
80
+ - `initialize`: Establishes the initial connection and lets the client to
81
+ register its MCP server.
82
+ - `authenticate`: Authenticates the user.
83
+ - `newSession`: Starts a new chat session.
84
+ - `loadSession`: Loads a previous session.
85
+ - `prompt`: Sends a prompt to the agent.
86
+ - `cancel`: Cancels an ongoing prompt.
87
+
88
+ ### Session control
89
+
90
+ - `setSessionMode`: Allows changing the approval level for tool calls (for
91
+ example, to `auto-approve`).
92
+ - `unstable_setSessionModel`: Changes the model for the current session.
93
+
94
+ ### File system proxy
95
+
96
+ ACP includes a proxied file system service. This means that when the agent needs
97
+ to read or write files, it does so through the ACP client. This is a security
98
+ feature that ensures the agent only has access to the files that the client (and
99
+ by extension, the user) has explicitly allowed.
100
+
101
+ ## Debugging and telemetry
102
+
103
+ You can get insights into the ACP communication and the agent's behavior through
104
+ debugging logs and telemetry.
105
+
106
+ ### Debugging logs
107
+
108
+ To enable general debugging logs, start Gemini CLI with the `--debug` flag:
109
+
110
+ ```bash
111
+ gemini --acp --debug
112
+ ```
113
+
114
+ ### Telemetry
115
+
116
+ For more detailed telemetry, you can use the following environment variables to
117
+ capture telemetry data to a file:
118
+
119
+ - `GEMINI_TELEMETRY_ENABLED=true`
120
+ - `GEMINI_TELEMETRY_TARGET=local`
121
+ - `GEMINI_TELEMETRY_OUTFILE=/path/to/your/log.json`
122
+
123
+ This will write a JSON log file containing detailed information about all the
124
+ events happening within the agent, including ACP requests and responses. The
125
+ integration test `integration-tests/acp-telemetry.test.ts` provides a working
126
+ example of how to set this up.
docs/cli/auto-memory.md ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Auto Memory
2
+
3
+ Auto Memory is an experimental feature that mines your past Gemini CLI sessions
4
+ in the background and proposes durable memory updates and reusable
5
+ [Agent Skills](./skills.md). You review each candidate before it becomes
6
+ available to future sessions: apply memory updates, promote skills, or discard
7
+ anything you do not want.
8
+
9
+ <!-- prettier-ignore -->
10
+ > [!NOTE]
11
+ > This is an experimental feature currently under active development.
12
+
13
+ ## Overview
14
+
15
+ Every session you run with Gemini CLI is recorded locally as a transcript. Auto
16
+ Memory scans those transcripts for durable facts, preferences, workflow
17
+ constraints, and procedural patterns that recur across sessions. It can draft
18
+ memory updates as unified diff `.patch` files and draft reusable procedures as
19
+ `SKILL.md` files. All candidates are held in a project-local inbox until you
20
+ approve or discard them.
21
+
22
+ You'll use Auto Memory when you want to:
23
+
24
+ - **Capture team workflows** that you find yourself walking the agent through
25
+ more than once.
26
+ - **Preserve durable project context** such as repeated verification commands,
27
+ local constraints, or personal project notes.
28
+ - **Codify hard-won fixes** for project-specific landmines so future sessions
29
+ avoid them.
30
+ - **Bootstrap a skills library** without writing every `SKILL.md` by hand.
31
+
32
+ Auto Memory complements direct memory-file editing. The agent can still persist
33
+ explicit user instructions by editing the appropriate Markdown memory file; Auto
34
+ Memory infers candidates from past sessions, writes reviewable patches or skill
35
+ drafts, and never applies them without your approval.
36
+
37
+ ## Prerequisites
38
+
39
+ - Gemini CLI installed and authenticated.
40
+ - At least one idle project session with 10 or more user messages. Auto Memory
41
+ ignores active, trivial, and sub-agent sessions.
42
+
43
+ ## How to enable Auto Memory
44
+
45
+ Auto Memory is off by default. Enable it in your settings file:
46
+
47
+ 1. Open your global settings file at `~/.gemini/settings.json`. If you only
48
+ want Auto Memory in one project, edit `.gemini/settings.json` in that
49
+ project instead.
50
+
51
+ 2. Add the experimental flag:
52
+
53
+ ```json
54
+ {
55
+ "experimental": {
56
+ "autoMemory": true
57
+ }
58
+ }
59
+ ```
60
+
61
+ 3. Restart Gemini CLI. The flag requires a restart because the extraction
62
+ service starts during session boot.
63
+
64
+ ## How Auto Memory works
65
+
66
+ Auto Memory runs as a background task on session startup. It does not block the
67
+ UI, consume your interactive turns, or surface tool prompts.
68
+
69
+ 1. **Eligibility scan.** The service indexes recent sessions from
70
+ `~/.gemini/tmp/<project>/chats/`. Sessions are eligible only if they have
71
+ been idle for at least three hours and contain at least 10 user messages.
72
+ 2. **Lock acquisition.** A lock file in the project's memory directory
73
+ coordinates across multiple CLI instances so extraction runs at most once at
74
+ a time. A state file records processed session versions, and extraction is
75
+ throttled so short back-to-back CLI launches do not repeatedly scan history.
76
+ 3. **Candidate extraction.** A background extraction agent reviews the session
77
+ index, reads any sessions that look like they contain durable memory or
78
+ repeated procedural workflows, and drafts candidates. It defaults to
79
+ creating no artifacts unless the evidence is strong, so many runs produce no
80
+ inbox items.
81
+ 4. **Safety boundaries.** Auto Memory writes candidates to a review inbox. It
82
+ cannot directly edit active memory files, settings, credentials, or project
83
+ `GEMINI.md` files.
84
+ 5. **Patch validation.** Skill update patches are parsed and dry-run before
85
+ they are surfaced. Memory patches are parsed, target-allowlisted, and
86
+ applied atomically only when you approve them from the inbox.
87
+ 6. **Notification.** When a run produces new candidates, Gemini CLI surfaces an
88
+ inline message telling you how many items are waiting.
89
+
90
+ ## How to review extracted items
91
+
92
+ Use the `/memory inbox` slash command to open the inbox dialog at any time:
93
+
94
+ **Command:** `/memory inbox`
95
+
96
+ The dialog groups pending items into new skills, skill updates, and memory
97
+ updates. From there you can:
98
+
99
+ - **Read** the full `SKILL.md` body before deciding.
100
+ - **Promote** a skill to your user (`~/.gemini/skills/`) or workspace
101
+ (`.gemini/skills/`) directory.
102
+ - **Discard** a skill you do not want.
103
+ - **Apply** or reject a `.patch` proposal against an existing skill.
104
+ - **Review** memory diffs before they touch active files.
105
+ - **Apply** or dismiss private and global memory patches. Private patches target
106
+ the project memory directory; global patches target only your personal
107
+ `~/.gemini/GEMINI.md` file.
108
+
109
+ Promoted skills become discoverable in the next session and follow the standard
110
+ [skill discovery precedence](./skills.md#skill-discovery-tiers). Applied memory
111
+ patches update the underlying memory files and reload memory for the current
112
+ session.
113
+
114
+ ## How to disable Auto Memory
115
+
116
+ To turn off background extraction, set the flag back to `false` in your settings
117
+ file and restart Gemini CLI:
118
+
119
+ ```json
120
+ {
121
+ "experimental": {
122
+ "autoMemory": false
123
+ }
124
+ }
125
+ ```
126
+
127
+ Disabling the flag stops the background service immediately on the next session
128
+ start. Existing inbox items remain on disk; you can either drain them with
129
+ `/memory inbox` first or remove the project memory directory manually.
130
+
131
+ ## Data and privacy
132
+
133
+ - Auto Memory only reads session files that already exist locally on your
134
+ machine.
135
+ - Auto Memory uses model calls to analyze selected local transcript content
136
+ during extraction. No candidates are applied automatically, but transcript
137
+ excerpts may be sent to the configured model as part of those calls.
138
+ - The extraction agent is instructed to redact secrets, tokens, and credentials
139
+ it encounters and to never copy large tool outputs verbatim.
140
+ - Drafted skills and memory patches live in your project's memory directory
141
+ until you promote, apply, dismiss, or discard them. They are not automatically
142
+ loaded into any session.
143
+
144
+ ## Limitations
145
+
146
+ - The extraction agent runs on a preview Gemini Flash model. Extraction quality
147
+ depends on the model's ability to recognize durable patterns versus one-off
148
+ incidents.
149
+ - Auto Memory does not extract memory or skills from the current session. It
150
+ only considers sessions that have been idle for three hours or more.
151
+ - Project or workspace shared instructions in project `GEMINI.md` files are not
152
+ auto-extractable. Auto Memory can propose private project memory, global
153
+ personal memory, and skills.
154
+ - Inbox items are stored per project. Skills extracted in one workspace are not
155
+ visible from another until you promote them to the user-scope skills
156
+ directory.
157
+
158
+ ## Next steps
159
+
160
+ - Learn how skills are discovered and activated in [Agent Skills](./skills.md).
161
+ - Explore the [memory management tutorial](./tutorials/memory-management.md) for
162
+ the complementary explicit-memory and `GEMINI.md` workflows.
163
+ - Review the experimental settings catalog in
164
+ [Settings](./settings.md#experimental).
docs/cli/checkpointing.md ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Checkpointing
2
+
3
+ Gemini CLI includes a Checkpointing feature that automatically saves a snapshot
4
+ of your project's state before any file modifications are made by AI-powered
5
+ tools. This lets you safely experiment with and apply code changes, knowing you
6
+ can instantly revert back to the state before the tool was run.
7
+
8
+ ## How it works
9
+
10
+ When you approve a tool that modifies the file system (like `write_file` or
11
+ `replace`), the CLI automatically creates a "checkpoint." This checkpoint
12
+ includes:
13
+
14
+ 1. **A Git snapshot:** A commit is made in a special, shadow Git repository
15
+ located in your home directory (`~/.gemini/history/<project_hash>`). This
16
+ snapshot captures the complete state of your project files at that moment.
17
+ It does **not** interfere with your own project's Git repository.
18
+ 2. **Conversation history:** The entire conversation you've had with the agent
19
+ up to that point is saved.
20
+ 3. **The tool call:** The specific tool call that was about to be executed is
21
+ also stored.
22
+
23
+ If you want to undo the change or simply go back, you can use the `/restore`
24
+ command. Restoring a checkpoint will:
25
+
26
+ - Revert all files in your project to the state captured in the snapshot.
27
+ - Restore the conversation history in the CLI.
28
+ - Re-propose the original tool call, allowing you to run it again, modify it, or
29
+ simply ignore it.
30
+
31
+ All checkpoint data, including the Git snapshot and conversation history, is
32
+ stored locally on your machine. The Git snapshot is stored in the shadow
33
+ repository while the conversation history and tool calls are saved in a JSON
34
+ file in your project's temporary directory, typically located at
35
+ `~/.gemini/tmp/<project_hash>/checkpoints`.
36
+
37
+ ## Enabling the feature
38
+
39
+ The Checkpointing feature is disabled by default. To enable it, you need to edit
40
+ your `settings.json` file.
41
+
42
+ <!-- prettier-ignore -->
43
+ > [!CAUTION]
44
+ > The `--checkpointing` command-line flag was removed in version
45
+ > 0.11.0. Checkpointing can now only be enabled through the `settings.json`
46
+ > configuration file.
47
+
48
+ Add the following key to your `settings.json`:
49
+
50
+ ```json
51
+ {
52
+ "general": {
53
+ "checkpointing": {
54
+ "enabled": true
55
+ }
56
+ }
57
+ }
58
+ ```
59
+
60
+ ## Using the `/restore` command
61
+
62
+ Once enabled, checkpoints are created automatically. To manage them, you use the
63
+ `/restore` command.
64
+
65
+ ### List available checkpoints
66
+
67
+ To see a list of all saved checkpoints for the current project, simply run:
68
+
69
+ ```
70
+ /restore
71
+ ```
72
+
73
+ The CLI will display a list of available checkpoint files. These file names are
74
+ typically composed of a timestamp, the name of the file being modified, and the
75
+ name of the tool that was about to be run (for example,
76
+ `2025-06-22T10-00-00_000Z-my-file.txt-write_file`).
77
+
78
+ ### Restore a specific checkpoint
79
+
80
+ To restore your project to a specific checkpoint, use the checkpoint file from
81
+ the list:
82
+
83
+ ```
84
+ /restore <checkpoint_file>
85
+ ```
86
+
87
+ For example:
88
+
89
+ ```
90
+ /restore 2025-06-22T10-00-00_000Z-my-file.txt-write_file
91
+ ```
92
+
93
+ After running the command, your files and conversation will be immediately
94
+ restored to the state they were in when the checkpoint was created, and the
95
+ original tool prompt will reappear.
docs/cli/cli-reference.md ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Gemini CLI cheatsheet
2
+
3
+ This page provides a reference for commonly used Gemini CLI commands, options,
4
+ and parameters.
5
+
6
+ ## CLI commands
7
+
8
+ | Command | Description | Example |
9
+ | ---------------------------------- | ---------------------------------- | ------------------------------------------------------------ |
10
+ | `gemini` | Start interactive REPL | `gemini` |
11
+ | `gemini -p "query"` | Query non-interactively | `gemini -p "summarize README.md"` |
12
+ | gemini "query" | Query and continue interactively | gemini "explain this project" |
13
+ | `cat file \| gemini` | Process piped content | `cat logs.txt \| gemini`<br>`Get-Content logs.txt \| gemini` |
14
+ | `gemini -i "query"` | Execute and continue interactively | `gemini -i "What is the purpose of this project?"` |
15
+ | `gemini -r "latest"` | Continue most recent session | `gemini -r "latest"` |
16
+ | `gemini -r "latest" "query"` | Continue session with a new prompt | `gemini -r "latest" "Check for type errors"` |
17
+ | `gemini -r "<session-id>" "query"` | Resume session by ID | `gemini -r "abc123" "Finish this PR"` |
18
+ | `gemini update` | Update to latest version | `gemini update` |
19
+ | `gemini extensions` | Manage extensions | See [Extensions Management](#extensions-management) |
20
+ | `gemini mcp` | Configure MCP servers | See [MCP Server Management](#mcp-server-management) |
21
+
22
+ ### Positional arguments
23
+
24
+ | Argument | Type | Description |
25
+ | -------- | ----------------- | ---------------------------------------------------------------------------------------------------------- |
26
+ | `query` | string (variadic) | Positional prompt. Defaults to interactive mode in a TTY. Use `-p/--prompt` for non-interactive execution. |
27
+
28
+ ## Interactive commands
29
+
30
+ These commands are available within the interactive REPL.
31
+
32
+ | Command | Description |
33
+ | -------------------- | ----------------------------------------------- |
34
+ | `/skills reload` | Reload discovered skills from disk |
35
+ | `/agents reload` | Reload the agent registry |
36
+ | `/commands list` | List available custom slash commands |
37
+ | `/commands reload` | Reload custom slash commands |
38
+ | `/memory reload` | Reload context files (for example, `GEMINI.md`) |
39
+ | `/mcp reload` | Restart and reload MCP servers |
40
+ | `/extensions reload` | Reload all active extensions |
41
+ | `/help` | Show help for all commands |
42
+ | `/quit` | Exit the interactive session |
43
+
44
+ ## CLI Options
45
+
46
+ | Option | Alias | Type | Default | Description |
47
+ | -------------------------------- | ----- | ------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
48
+ | `--debug` | `-d` | boolean | `false` | Run in debug mode with verbose logging |
49
+ | `--version` | `-v` | - | - | Show CLI version number and exit |
50
+ | `--help` | `-h` | - | - | Show help information |
51
+ | `--model` | `-m` | string | `auto` | Model to use. See [Model Selection](#model-selection) for available values. |
52
+ | `--prompt` | `-p` | string | - | Prompt text. Appended to stdin input if provided. Forces non-interactive mode. |
53
+ | `--prompt-interactive` | `-i` | string | - | Execute prompt and continue in interactive mode |
54
+ | `--worktree` | `-w` | string | - | Start Gemini in a new git worktree. If no name is provided, one is generated automatically. Requires `experimental.worktrees: true` in settings. |
55
+ | `--sandbox` | `-s` | boolean | `false` | Run in a sandboxed environment for safer execution |
56
+ | `--skip-trust` | - | boolean | `false` | Trust the current workspace for this session, skipping the folder trust check. |
57
+ | `--approval-mode` | - | string | `default` | Approval mode for tool execution. Choices: `default`, `auto_edit`, `yolo`, `plan` |
58
+ | `--yolo` | `-y` | boolean | `false` | **Deprecated.** Auto-approve all actions. Use `--approval-mode=yolo` instead. |
59
+ | `--experimental-acp` | - | boolean | - | Start in ACP (Agent Code Pilot) mode. **Experimental feature.** |
60
+ | `--experimental-zed-integration` | - | boolean | - | Run in Zed editor integration mode. **Experimental feature.** |
61
+ | `--allowed-mcp-server-names` | - | array | - | Allowed MCP server names (comma-separated or multiple flags) |
62
+ | `--allowed-tools` | - | array | - | **Deprecated.** Use the [Policy Engine](../reference/policy-engine.md) instead. Tools that are allowed to run without confirmation (comma-separated or multiple flags) |
63
+ | `--extensions` | `-e` | array | - | List of extensions to use. If not provided, all extensions are enabled (comma-separated or multiple flags) |
64
+ | `--list-extensions` | `-l` | boolean | - | List all available extensions and exit |
65
+ | `--resume` | `-r` | string | - | Resume a previous session. Use `"latest"` for most recent or index number (for example `--resume 5`) |
66
+ | `--list-sessions` | - | boolean | - | List available sessions for the current project and exit |
67
+ | `--delete-session` | - | string | - | Delete a session by index number (use `--list-sessions` to see available sessions) |
68
+ | `--include-directories` | - | array | - | Additional directories to include in the workspace (comma-separated or multiple flags) |
69
+ | `--screen-reader` | - | boolean | - | Enable screen reader mode for accessibility |
70
+ | `--output-format` | `-o` | string | `text` | The format of the CLI output. Choices: `text`, `json`, `stream-json` |
71
+
72
+ ## Model selection
73
+
74
+ The `--model` (or `-m`) flag lets you specify which Gemini model to use. You can
75
+ use either model aliases (user-friendly names) or concrete model names.
76
+
77
+ ### Model aliases
78
+
79
+ These are convenient shortcuts that map to specific models:
80
+
81
+ | Alias | Resolves To | Description |
82
+ | ------------ | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------- |
83
+ | `auto` | `gemini-2.5-pro` or `gemini-3-pro-preview` | **Default.** Resolves to the preview model if preview features are enabled, otherwise resolves to the standard pro model. |
84
+ | `pro` | `gemini-2.5-pro` or `gemini-3-pro-preview` | For complex reasoning tasks. Uses preview model if enabled. |
85
+ | `flash` | `gemini-2.5-flash` | Fast, balanced model for most tasks. |
86
+ | `flash-lite` | `gemini-2.5-flash-lite` | Fastest model for simple tasks. |
87
+
88
+ ## Extensions management
89
+
90
+ | Command | Description | Example |
91
+ | -------------------------------------------------- | -------------------------------------------- | ------------------------------------------------------------------------------ |
92
+ | `gemini extensions install <source>` | Install extension from Git URL or local path | `gemini extensions install https://github.com/user/my-extension` |
93
+ | `gemini extensions install <source> --ref <ref>` | Install from specific branch/tag/commit | `gemini extensions install https://github.com/user/my-extension --ref develop` |
94
+ | `gemini extensions install <source> --auto-update` | Install with auto-update enabled | `gemini extensions install https://github.com/user/my-extension --auto-update` |
95
+ | `gemini extensions uninstall <name>` | Uninstall one or more extensions | `gemini extensions uninstall my-extension` |
96
+ | `gemini extensions list` | List all installed extensions | `gemini extensions list` |
97
+ | `gemini extensions update <name>` | Update a specific extension | `gemini extensions update my-extension` |
98
+ | `gemini extensions update --all` | Update all extensions | `gemini extensions update --all` |
99
+ | `gemini extensions enable <name>` | Enable an extension | `gemini extensions enable my-extension` |
100
+ | `gemini extensions disable <name>` | Disable an extension | `gemini extensions disable my-extension` |
101
+ | `gemini extensions link <path>` | Link local extension for development | `gemini extensions link /path/to/extension` |
102
+ | `gemini extensions new <path>` | Create new extension from template | `gemini extensions new ./my-extension` |
103
+ | `gemini extensions validate <path>` | Validate extension structure | `gemini extensions validate ./my-extension` |
104
+
105
+ See [Extensions Documentation](../extensions/index.md) for more details.
106
+
107
+ ## MCP server management
108
+
109
+ | Command | Description | Example |
110
+ | ------------------------------------------------------------- | ------------------------------- | ---------------------------------------------------------------------------------------------------- |
111
+ | `gemini mcp add <name> <command>` | Add stdio-based MCP server | `gemini mcp add github npx -y @modelcontextprotocol/server-github` |
112
+ | `gemini mcp add <name> <url> --transport http` | Add HTTP-based MCP server | `gemini mcp add api-server http://localhost:3000 --transport http` |
113
+ | `gemini mcp add <name> <command> --env KEY=value` | Add with environment variables | `gemini mcp add slack node server.js --env SLACK_TOKEN=xoxb-xxx` |
114
+ | `gemini mcp add <name> <command> --scope user` | Add with user scope | `gemini mcp add db node db-server.js --scope user` |
115
+ | `gemini mcp add <name> <command> --include-tools tool1,tool2` | Add with specific tools | `gemini mcp add github npx -y @modelcontextprotocol/server-github --include-tools list_repos,get_pr` |
116
+ | `gemini mcp remove <name>` | Remove an MCP server | `gemini mcp remove github` |
117
+ | `gemini mcp list` | List all configured MCP servers | `gemini mcp list` |
118
+
119
+ See [MCP Server Integration](../tools/mcp-server.md) for more details.
120
+
121
+ ## Skills management
122
+
123
+ | Command | Description | Example |
124
+ | -------------------------------- | ------------------------------------- | ------------------------------------------------- |
125
+ | `gemini skills list` | List all discovered agent skills | `gemini skills list` |
126
+ | `gemini skills install <source>` | Install skill from Git, path, or file | `gemini skills install https://github.com/u/repo` |
127
+ | `gemini skills link <path>` | Link local agent skills via symlink | `gemini skills link /path/to/my-skills` |
128
+ | `gemini skills uninstall <name>` | Uninstall an agent skill | `gemini skills uninstall my-skill` |
129
+ | `gemini skills enable <name>` | Enable an agent skill | `gemini skills enable my-skill` |
130
+ | `gemini skills disable <name>` | Disable an agent skill | `gemini skills disable my-skill` |
131
+ | `gemini skills enable --all` | Enable all skills | `gemini skills enable --all` |
132
+ | `gemini skills disable --all` | Disable all skills | `gemini skills disable --all` |
133
+
134
+ See [Agent Skills Documentation](./skills.md) for more details.
docs/cli/creating-skills.md ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Creating Agent Skills
2
+
3
+ Agent Skills let you extend Gemini CLI with specialized expertise, procedural
4
+ workflows, and task-specific resources. This guide walks you through both
5
+ automated and manual methods for creating and organizing your skills.
6
+
7
+ ## Quickstart: Create a skill with a prompt
8
+
9
+ The fastest way to create a new skill is to use the built-in `skill-creator`.
10
+ This meta-skill guides you through designing, scaffolding, and validating your
11
+ expertise.
12
+
13
+ Simply ask Gemini CLI to create a skill for you:
14
+
15
+ > "Create a new skill called 'code-reviewer' that analyzes local files for
16
+ > common errors and style violations."
17
+
18
+ Gemini will then:
19
+
20
+ 1. Generate a new directory for your skill (for example, `my-new-skill/`).
21
+ 2. Create a `SKILL.md` file with the necessary YAML frontmatter (`name` and
22
+ `description`).
23
+ 3. Create the standard resource directories: `scripts/`, `references/`, and
24
+ `assets/`.
25
+
26
+ Once created, you can find your new skill in `.gemini/skills/code-reviewer/`.
27
+
28
+ ## Manual creation
29
+
30
+ 1. **Create a directory** for your skill (for example, `my-new-skill/`).
31
+ 2. **Create a `SKILL.md` file** inside the new directory.
32
+
33
+ ### 1. Create the directory structure
34
+
35
+ The first step is to create the necessary folders for your skill and its
36
+ scripts.
37
+
38
+ **macOS/Linux**
39
+
40
+ ```bash
41
+ mkdir -p .gemini/skills/code-reviewer/scripts
42
+ ```
43
+
44
+ **Windows (PowerShell)**
45
+
46
+ ```powershell
47
+ New-Item -ItemType Directory -Force -Path ".gemini\skills\code-reviewer\scripts"
48
+ ```
49
+
50
+ ### 2. Define the skill (`SKILL.md`)
51
+
52
+ The `SKILL.md` file defines the skill's purpose and instructions for the agent.
53
+ Create a file at `.gemini/skills/code-reviewer/SKILL.md`.
54
+
55
+ ```markdown
56
+ ---
57
+ name: code-reviewer
58
+ description:
59
+ Expertise in reviewing code changes for correctness, security, and style. Use
60
+ when the user asks to "review" their code or a PR.
61
+ ---
62
+
63
+ # Code Reviewer Instructions
64
+
65
+ You act as a senior software engineer specialized in code quality. When this
66
+ skill is active, you MUST:
67
+
68
+ 1. **Analyze**: Review the provided code for logical errors, security
69
+ vulnerabilities, and style violations.
70
+ 2. **Review**: Use the bundled `scripts/review.js` utility to perform an
71
+ automated check.
72
+ 3. **Feedback**: Provide constructive feedback, clearly distinguishing between
73
+ critical issues and minor improvements.
74
+ ```
75
+
76
+ ### 3. Add the tool logic
77
+
78
+ Skills can bundle resources like scripts to perform deterministic tasks. Create
79
+ a file at `.gemini/skills/code-reviewer/scripts/review.js`.
80
+
81
+ ```javascript
82
+ // .gemini/skills/code-reviewer/scripts/review.js
83
+ const file = process.argv[2];
84
+
85
+ if (!file) {
86
+ console.error('Usage: node review.js <file>');
87
+ process.exit(1);
88
+ }
89
+
90
+ console.log(`Reviewing ${file}...`);
91
+ // Simple mock review logic
92
+ setTimeout(() => {
93
+ console.log(`Result: Success (No major issues found in ${file})`);
94
+ }, 500);
95
+ ```
96
+
97
+ ### 4. Test the skill
98
+
99
+ Gemini CLI automatically discovers skills in the `.gemini/skills` directory.
100
+
101
+ 1. Start a new session and ask a question that triggers the skill's
102
+ description: "Can you review index.js"
103
+ 2. Gemini identifies the request matches the `code-reviewer` description and
104
+ asks for permission to activate it.
105
+ 3. Once you approve, Gemini executes the bundled script:
106
+ `node .gemini/skills/code-reviewer/scripts/review.js index.js`
107
+
108
+ To determine whether your skill has been correctly loaded, run the command:
109
+
110
+ ```bash
111
+ /skills
112
+ ```
113
+
114
+ ### 5. Optional: Share your skill
115
+
116
+ You can share your skills in several ways depending on your target audience.
117
+
118
+ - **Workspace skills**: Commit your skill to a `.gemini/skills/` directory in
119
+ your project repository.
120
+ - **Extensions**: Bundle your skill within a
121
+ [Gemini CLI extension](../extensions/writing-extensions.md).
122
+ - **Git repositories**: Share the skill directory as a standalone Git repo and
123
+ install it using `gemini skills install <url>`.
124
+
125
+ ---
126
+
127
+ ## Core concepts
128
+
129
+ Now that you've built your first skill, let's explore the core components and
130
+ workflows for developing more complex expertise.
131
+
132
+ ### Skill structure
133
+
134
+ While a `SKILL.md` file is the only required component, we recommend the
135
+ following structure for organizing your skill's resources.
136
+
137
+ ```text
138
+ my-skill/
139
+ ├── SKILL.md (Required) Instructions and metadata
140
+ ├── scripts/ (Optional) Executable scripts
141
+ ├── references/ (Optional) Static documentation
142
+ └── assets/ (Optional) Templates and other resources
143
+ ```
144
+
145
+ When a skill is activated, the model is granted access to this entire directory.
146
+ You can instruct the model to use the tools and files found within these
147
+ folders.
148
+
149
+ ### Metadata and triggers
150
+
151
+ The `SKILL.md` file uses YAML frontmatter for metadata.
152
+
153
+ - **`name`**: A unique identifier for the skill. This should match the directory
154
+ name.
155
+ - **`description`**: **CRITICAL.** This is how Gemini decides when to use the
156
+ skill. Be specific about the tasks it handles and the keywords that should
157
+ trigger it.
158
+
159
+ ### Discovery tiers
160
+
161
+ Gemini CLI discovers skills from several locations, following a specific order
162
+ of precedence (lowest to highest):
163
+
164
+ 1. **Built-in Skills**: Included with Gemini CLI (pre-approved).
165
+ 2. **Extension Skills**: Bundled within [extensions](../extensions/).
166
+ 3. **User Skills**: `~/.gemini/skills/` or the `~/.agents/skills/` alias.
167
+ 4. **Workspace Skills**: `.gemini/skills/` or the `.agents/skills/` alias.
168
+
169
+ ### Discovery aliases
170
+
171
+ You can use `.agents/skills` as an alternative to `.gemini/skills`. This alias
172
+ is compatible with other AI agent tools following the
173
+ [Agent Skills](https://agentskills.io) standard.
174
+
175
+ ## Advanced development
176
+
177
+ Once you've built a basic skill, you can use specialized scripts and workflows
178
+ to streamline your development process.
179
+
180
+ ### Creation scripts
181
+
182
+ If you are developing a skill and want to use the same scripts the built-in
183
+ tools use, you can find them in the core package. These scripts help automate
184
+ the initialization, validation, and packaging of skills.
185
+
186
+ - **Initialize**: `node scripts/init_skill.cjs <name> --path <dir>`
187
+ - **Validate**: `node scripts/validate_skill.cjs <path/to/skill>`
188
+ - **Package**: `node scripts/package_skill.cjs <path/to/skill>` (Creates a
189
+ `.skill` zip file)
190
+
191
+ ### Linking for local development
192
+
193
+ If you are developing a skill in a separate directory, you can link it to your
194
+ user skills directory for testing:
195
+
196
+ ```bash
197
+ gemini skills link .
198
+ ```
199
+
200
+ ## Next steps
201
+
202
+ - [Skill best practices](./skills-best-practices.md): Learn strategies for
203
+ building reliable and effective skills.
204
+ - [Agent Skills overview](./skills.md): Deep dive into discovery tiers and the
205
+ skill lifecycle.
206
+ - [Get started with Agent Skills](./tutorials/skills-getting-started.md): A
207
+ quick walkthrough of triggering and using skills.
docs/cli/custom-commands.md ADDED
@@ -0,0 +1,331 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Custom commands
2
+
3
+ Custom commands let you save and reuse your favorite or most frequently used
4
+ prompts as personal shortcuts within Gemini CLI. You can create commands that
5
+ are specific to a single project or commands that are available globally across
6
+ all your projects, streamlining your workflow and ensuring consistency.
7
+
8
+ ## File locations and precedence
9
+
10
+ Gemini CLI discovers commands from two locations, loaded in a specific order:
11
+
12
+ 1. **User commands (global):** Located in `~/.gemini/commands/`. These commands
13
+ are available in any project you are working on.
14
+ 2. **Project commands (local):** Located in
15
+ `<your-project-root>/.gemini/commands/`. These commands are specific to the
16
+ current project and can be checked into version control to be shared with
17
+ your team.
18
+
19
+ If a command in the project directory has the same name as a command in the user
20
+ directory, the **project command will always be used.** This allows projects to
21
+ override global commands with project-specific versions.
22
+
23
+ ## Naming and namespacing
24
+
25
+ The name of a command is determined by its file path relative to its `commands`
26
+ directory. Subdirectories are used to create namespaced commands, with the path
27
+ separator (`/` or `\`) being converted to a colon (`:`).
28
+
29
+ - A file at `~/.gemini/commands/test.toml` becomes the command `/test`.
30
+ - A file at `<project>/.gemini/commands/git/commit.toml` becomes the namespaced
31
+ command `/git:commit`.
32
+
33
+ <!-- prettier-ignore -->
34
+ > [!TIP]
35
+ > After creating or modifying `.toml` command files, run
36
+ > `/commands reload` to pick up your changes without restarting the CLI.
37
+ > To see all available command files, run `/commands list`.
38
+
39
+ ## TOML file format (v1)
40
+
41
+ Your command definition files must be written in the TOML format and use the
42
+ `.toml` file extension.
43
+
44
+ ### Required fields
45
+
46
+ - `prompt` (String): The prompt that will be sent to the Gemini model when the
47
+ command is executed. This can be a single-line or multi-line string.
48
+
49
+ ### Optional fields
50
+
51
+ - `description` (String): A brief, one-line description of what the command
52
+ does. This text will be displayed next to your command in the `/help` menu.
53
+ **If you omit this field, a generic description will be generated from the
54
+ filename.**
55
+
56
+ ## Handling arguments
57
+
58
+ Custom commands support two powerful methods for handling arguments. The CLI
59
+ automatically chooses the correct method based on the content of your command's
60
+ `prompt`.
61
+
62
+ ### 1. Context-aware injection with `{{args}}`
63
+
64
+ If your `prompt` contains the special placeholder `{{args}}`, the CLI will
65
+ replace that placeholder with the text the user typed after the command name.
66
+
67
+ The behavior of this injection depends on where it is used:
68
+
69
+ **A. Raw injection (outside shell commands)**
70
+
71
+ When used in the main body of the prompt, the arguments are injected exactly as
72
+ the user typed them.
73
+
74
+ **Example (`git/fix.toml`):**
75
+
76
+ ```toml
77
+ # Invoked via: /git:fix "Button is misaligned"
78
+
79
+ description = "Generates a fix for a given issue."
80
+ prompt = "Please provide a code fix for the issue described here: {{args}}."
81
+ ```
82
+
83
+ The model receives:
84
+ `Please provide a code fix for the issue described here: "Button is misaligned".`
85
+
86
+ **B. Using arguments in shell commands (inside `!{...}` blocks)**
87
+
88
+ When you use `{{args}}` inside a shell injection block (`!{...}`), the arguments
89
+ are automatically **shell-escaped** before replacement. This lets you safely
90
+ pass arguments to shell commands, ensuring the resulting command is
91
+ syntactically correct and secure while preventing command injection
92
+ vulnerabilities.
93
+
94
+ **Example (`/grep-code.toml`):**
95
+
96
+ ```toml
97
+ prompt = """
98
+ Please summarize the findings for the pattern `{{args}}`.
99
+
100
+ Search Results:
101
+ !{grep -r {{args}} .}
102
+ """
103
+ ```
104
+
105
+ When you run `/grep-code It's complicated`:
106
+
107
+ 1. The CLI sees `{{args}}` used both outside and inside `!{...}`.
108
+ 2. Outside: The first `{{args}}` is replaced raw with `It's complicated`.
109
+ 3. Inside: The second `{{args}}` is replaced with the escaped version (for
110
+ example, on Linux: `"It\'s complicated"`).
111
+ 4. The command executed is `grep -r "It's complicated" .`.
112
+ 5. The CLI prompts you to confirm this exact, secure command before execution.
113
+ 6. The final prompt is sent.
114
+
115
+ ### 2. Default argument handling
116
+
117
+ If your `prompt` does **not** contain the special placeholder `{{args}}`, the
118
+ CLI uses a default behavior for handling arguments.
119
+
120
+ If you provide arguments to the command (for example, `/mycommand arg1`), the
121
+ CLI will append the full command you typed to the end of the prompt, separated
122
+ by two newlines. This allows the model to see both the original instructions and
123
+ the specific arguments you just provided.
124
+
125
+ If you do **not** provide any arguments (for example, `/mycommand`), the prompt
126
+ is sent to the model exactly as it is, with nothing appended.
127
+
128
+ **Example (`changelog.toml`):**
129
+
130
+ This example shows how to create a robust command by defining a role for the
131
+ model, explaining where to find the user's input, and specifying the expected
132
+ format and behavior.
133
+
134
+ ```toml
135
+ # In: <project>/.gemini/commands/changelog.toml
136
+ # Invoked via: /changelog 1.2.0 added "Support for default argument parsing."
137
+
138
+ description = "Adds a new entry to the project's CHANGELOG.md file."
139
+ prompt = """
140
+ # Task: Update Changelog
141
+
142
+ You are an expert maintainer of this software project. A user has invoked a command to add a new entry to the changelog.
143
+
144
+ **The user's raw command is appended below your instructions.**
145
+
146
+ Your task is to parse the `<version>`, `<change_type>`, and `<message>` from their input and use the `write_file` tool to correctly update the `CHANGELOG.md` file.
147
+
148
+ ## Expected Format
149
+ The command follows this format: `/changelog <version> <type> <message>`
150
+ - `<type>` must be one of: "added", "changed", "fixed", "removed".
151
+
152
+ ## Behavior
153
+ 1. Read the `CHANGELOG.md` file.
154
+ 2. Find the section for the specified `<version>`.
155
+ 3. Add the `<message>` under the correct `<type>` heading.
156
+ 4. If the version or type section doesn't exist, create it.
157
+ 5. Adhere strictly to the "Keep a Changelog" format.
158
+ """
159
+ ```
160
+
161
+ When you run `/changelog 1.2.0 added "New feature"`, the final text sent to the
162
+ model will be the original prompt followed by two newlines and the command you
163
+ typed.
164
+
165
+ ### 3. Executing shell commands with `!{...}`
166
+
167
+ You can make your commands dynamic by executing shell commands directly within
168
+ your `prompt` and injecting their output. This is ideal for gathering context
169
+ from your local environment, like reading file content or checking the status of
170
+ Git.
171
+
172
+ When a custom command attempts to execute a shell command, Gemini CLI will now
173
+ prompt you for confirmation before proceeding. This is a security measure to
174
+ ensure that only intended commands can be run.
175
+
176
+ **How it works:**
177
+
178
+ 1. **Inject commands:** Use the `!{...}` syntax.
179
+ 2. **Argument substitution:** If `{{args}}` is present inside the block, it is
180
+ automatically shell-escaped (see
181
+ [Context-Aware Injection](#1-context-aware-injection-with-args) above).
182
+ 3. **Robust parsing:** The parser correctly handles complex shell commands that
183
+ include nested braces, such as JSON payloads. The content inside `!{...}`
184
+ must have balanced braces (`{` and `}`). If you need to execute a command
185
+ containing unbalanced braces, consider wrapping it in an external script
186
+ file and calling the script within the `!{...}` block.
187
+ 4. **Security check and confirmation:** The CLI performs a security check on
188
+ the final, resolved command (after arguments are escaped and substituted). A
189
+ dialog will appear showing the exact command(s) to be executed.
190
+ 5. **Execution and error reporting:** The command is executed. If the command
191
+ fails, the output injected into the prompt will include the error messages
192
+ (stderr) followed by a status line, for example,
193
+ `[Shell command exited with code 1]`. This helps the model understand the
194
+ context of the failure.
195
+
196
+ **Example (`git/commit.toml`):**
197
+
198
+ This command gets the staged git diff and uses it to ask the model to write a
199
+ commit message.
200
+
201
+ ````toml
202
+ # In: <project>/.gemini/commands/git/commit.toml
203
+ # Invoked via: /git:commit
204
+
205
+ description = "Generates a Git commit message based on staged changes."
206
+
207
+ # The prompt uses !{...} to execute the command and inject its output.
208
+ prompt = """
209
+ Please generate a Conventional Commit message based on the following git diff:
210
+
211
+ ```diff
212
+ !{git diff --staged}
213
+ ```
214
+
215
+ """
216
+
217
+ ````
218
+
219
+ When you run `/git:commit`, the CLI first executes `git diff --staged`, then
220
+ replaces `!{git diff --staged}` with the output of that command before sending
221
+ the final, complete prompt to the model.
222
+
223
+ ### 4. Injecting file content with `@{...}`
224
+
225
+ You can directly embed the content of a file or a directory listing into your
226
+ prompt using the `@{...}` syntax. This is useful for creating commands that
227
+ operate on specific files.
228
+
229
+ **How it works:**
230
+
231
+ - **File injection**: `@{path/to/file.txt}` is replaced by the content of
232
+ `file.txt`.
233
+ - **Multimodal support**: If the path points to a supported image (for example,
234
+ PNG, JPEG), PDF, audio, or video file, it will be correctly encoded and
235
+ injected as multimodal input. Other binary files are handled gracefully and
236
+ skipped.
237
+ - **Directory listing**: `@{path/to/dir}` is traversed and each file present
238
+ within the directory and all subdirectories is inserted into the prompt. This
239
+ respects `.gitignore` and `.geminiignore` if enabled.
240
+ - **Workspace-aware**: The command searches for the path in the current
241
+ directory and any other workspace directories. Absolute paths are allowed if
242
+ they are within the workspace.
243
+ - **Processing order**: File content injection with `@{...}` is processed
244
+ _before_ shell commands (`!{...}`) and argument substitution (`{{args}}`).
245
+ - **Parsing**: The parser requires the content inside `@{...}` (the path) to
246
+ have balanced braces (`{` and `}`).
247
+
248
+ **Example (`review.toml`):**
249
+
250
+ This command injects the content of a _fixed_ best practices file
251
+ (`docs/best-practices.md`) and uses the user's arguments to provide context for
252
+ the review.
253
+
254
+ ```toml
255
+ # In: <project>/.gemini/commands/review.toml
256
+ # Invoked via: /review FileCommandLoader.ts
257
+
258
+ description = "Reviews the provided context using a best practice guide."
259
+ prompt = """
260
+ You are an expert code reviewer.
261
+
262
+ Your task is to review {{args}}.
263
+
264
+ Use the following best practices when providing your review:
265
+
266
+ @{docs/best-practices.md}
267
+ """
268
+ ```
269
+
270
+ When you run `/review FileCommandLoader.ts`, the `@{docs/best-practices.md}`
271
+ placeholder is replaced by the content of that file, and `{{args}}` is replaced
272
+ by the text you provided, before the final prompt is sent to the model.
273
+
274
+ ---
275
+
276
+ ## Example: A "Pure Function" refactoring command
277
+
278
+ Let's create a global command that asks the model to refactor a piece of code.
279
+
280
+ **1. Create the file and directories:**
281
+
282
+ First, ensure the user commands directory exists, then create a `refactor`
283
+ subdirectory for organization and the final TOML file.
284
+
285
+ **macOS/Linux**
286
+
287
+ ```bash
288
+ mkdir -p ~/.gemini/commands/refactor
289
+ touch ~/.gemini/commands/refactor/pure.toml
290
+ ```
291
+
292
+ **Windows (PowerShell)**
293
+
294
+ ```powershell
295
+ New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.gemini\commands\refactor"
296
+ New-Item -ItemType File -Force -Path "$env:USERPROFILE\.gemini\commands\refactor\pure.toml"
297
+ ```
298
+
299
+ **2. Add the content to the file:**
300
+
301
+ Open `~/.gemini/commands/refactor/pure.toml` in your editor and add the
302
+ following content. We are including the optional `description` for best
303
+ practice.
304
+
305
+ ```toml
306
+ # In: ~/.gemini/commands/refactor/pure.toml
307
+ # This command will be invoked via: /refactor:pure
308
+
309
+ description = "Asks the model to refactor the current context into a pure function."
310
+
311
+ prompt = """
312
+ Please analyze the code I've provided in the current context.
313
+ Refactor it into a pure function.
314
+
315
+ Your response should include:
316
+ 1. The refactored, pure function code block.
317
+ 2. A brief explanation of the key changes you made and why they contribute to purity.
318
+ """
319
+ ```
320
+
321
+ **3. Run the command:**
322
+
323
+ That's it! You can now run your command in the CLI. First, you might add a file
324
+ to the context, and then invoke your command:
325
+
326
+ ```
327
+ > @my-messy-function.js
328
+ > /refactor:pure
329
+ ```
330
+
331
+ Gemini CLI will then execute the multi-line prompt defined in your TOML file.
docs/cli/enterprise.md ADDED
@@ -0,0 +1,613 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Gemini CLI for the enterprise
2
+
3
+ This document outlines configuration patterns and best practices for deploying
4
+ and managing Gemini CLI in an enterprise environment. By leveraging system-level
5
+ settings, administrators can enforce security policies, manage tool access, and
6
+ ensure a consistent experience for all users.
7
+
8
+ <!-- prettier-ignore -->
9
+ > [!WARNING]
10
+ > The patterns described in this document are intended to help
11
+ > administrators create a more controlled and secure environment for using
12
+ > Gemini CLI. However, they should not be considered a foolproof security
13
+ > boundary. A determined user with sufficient privileges on their local machine
14
+ > may still be able to circumvent these configurations. These measures are
15
+ > designed to prevent accidental misuse and enforce corporate policy in a
16
+ > managed environment, not to defend against a malicious actor with local
17
+ > administrative rights.
18
+
19
+ ## Centralized configuration: The system settings file
20
+
21
+ The most powerful tools for enterprise administration are the system-wide
22
+ settings files. These files allow you to define a baseline configuration
23
+ (`system-defaults.json`) and a set of overrides (`settings.json`) that apply to
24
+ all users on a machine. For a complete overview of configuration options, see
25
+ the [Configuration documentation](../reference/configuration.md).
26
+
27
+ Settings are merged from four files. The precedence order for single-value
28
+ settings (like `theme`) is:
29
+
30
+ 1. System Defaults (`system-defaults.json`)
31
+ 2. User Settings (`~/.gemini/settings.json`)
32
+ 3. Workspace Settings (`<project>/.gemini/settings.json`)
33
+ 4. System Overrides (`settings.json`)
34
+
35
+ This means the System Overrides file has the final say. For settings that are
36
+ arrays (`includeDirectories`) or objects (`mcpServers`), the values are merged.
37
+
38
+ **Example of merging and precedence:**
39
+
40
+ Here is how settings from different levels are combined.
41
+
42
+ - **System defaults `system-defaults.json`:**
43
+
44
+ ```json
45
+ {
46
+ "ui": {
47
+ "theme": "default-corporate-theme"
48
+ },
49
+ "context": {
50
+ "includeDirectories": ["/etc/gemini-cli/common-context"]
51
+ }
52
+ }
53
+ ```
54
+
55
+ - **User `settings.json` (`~/.gemini/settings.json`):**
56
+
57
+ ```json
58
+ {
59
+ "ui": {
60
+ "theme": "user-preferred-dark-theme"
61
+ },
62
+ "mcpServers": {
63
+ "corp-server": {
64
+ "command": "/usr/local/bin/corp-server-dev"
65
+ },
66
+ "user-tool": {
67
+ "command": "npm start --prefix ~/tools/my-tool"
68
+ }
69
+ },
70
+ "context": {
71
+ "includeDirectories": ["~/gemini-context"]
72
+ }
73
+ }
74
+ ```
75
+
76
+ - **Workspace `settings.json` (`<project>/.gemini/settings.json`):**
77
+
78
+ ```json
79
+ {
80
+ "ui": {
81
+ "theme": "project-specific-light-theme"
82
+ },
83
+ "mcpServers": {
84
+ "project-tool": {
85
+ "command": "npm start"
86
+ }
87
+ },
88
+ "context": {
89
+ "includeDirectories": ["./project-context"]
90
+ }
91
+ }
92
+ ```
93
+
94
+ - **System overrides `settings.json`:**
95
+ ```json
96
+ {
97
+ "ui": {
98
+ "theme": "system-enforced-theme"
99
+ },
100
+ "mcpServers": {
101
+ "corp-server": {
102
+ "command": "/usr/local/bin/corp-server-prod"
103
+ }
104
+ },
105
+ "context": {
106
+ "includeDirectories": ["/etc/gemini-cli/global-context"]
107
+ }
108
+ }
109
+ ```
110
+
111
+ This results in the following merged configuration:
112
+
113
+ - **Final merged configuration:**
114
+ ```json
115
+ {
116
+ "ui": {
117
+ "theme": "system-enforced-theme"
118
+ },
119
+ "mcpServers": {
120
+ "corp-server": {
121
+ "command": "/usr/local/bin/corp-server-prod"
122
+ },
123
+ "user-tool": {
124
+ "command": "npm start --prefix ~/tools/my-tool"
125
+ },
126
+ "project-tool": {
127
+ "command": "npm start"
128
+ }
129
+ },
130
+ "context": {
131
+ "includeDirectories": [
132
+ "/etc/gemini-cli/common-context",
133
+ "~/gemini-context",
134
+ "./project-context",
135
+ "/etc/gemini-cli/global-context"
136
+ ]
137
+ }
138
+ }
139
+ ```
140
+
141
+ **Why:**
142
+
143
+ - **`theme`**: The value from the system overrides (`system-enforced-theme`) is
144
+ used, as it has the highest precedence.
145
+ - **`mcpServers`**: The objects are merged. The `corp-server` definition from
146
+ the system overrides takes precedence over the user's definition. The unique
147
+ `user-tool` and `project-tool` are included.
148
+ - **`includeDirectories`**: The arrays are concatenated in the order of System
149
+ Defaults, User, Workspace, and then System Overrides.
150
+
151
+ - **Location**:
152
+ - **Linux**: `/etc/gemini-cli/settings.json`
153
+ - **Windows**: `C:\ProgramData\gemini-cli\settings.json`
154
+ - **macOS**: `/Library/Application Support/GeminiCli/settings.json`
155
+ - The path can be overridden using the `GEMINI_CLI_SYSTEM_SETTINGS_PATH`
156
+ environment variable.
157
+ - **Control**: This file should be managed by system administrators and
158
+ protected with appropriate file permissions to prevent unauthorized
159
+ modification by users.
160
+
161
+ By using the system settings file, you can enforce the security and
162
+ configuration patterns described below.
163
+
164
+ ### Enforcing system settings with a wrapper script
165
+
166
+ While the `GEMINI_CLI_SYSTEM_SETTINGS_PATH` environment variable provides
167
+ flexibility, a user could potentially override it to point to a different
168
+ settings file, bypassing the centrally managed configuration. To mitigate this,
169
+ enterprises can deploy a wrapper script or alias that ensures the environment
170
+ variable is always set to the corporate-controlled path.
171
+
172
+ This approach ensures that no matter how the user calls the `gemini` command,
173
+ the enterprise settings are always loaded with the highest precedence.
174
+
175
+ **Example wrapper script:**
176
+
177
+ Administrators can create a script named `gemini` and place it in a directory
178
+ that appears earlier in the user's `PATH` than the actual Gemini CLI binary (for
179
+ example, `/usr/local/bin/gemini`).
180
+
181
+ ```bash
182
+ #!/bin/bash
183
+
184
+ # Enforce the path to the corporate system settings file.
185
+ # This ensures that the company's configuration is always applied.
186
+ export GEMINI_CLI_SYSTEM_SETTINGS_PATH="/etc/gemini-cli/settings.json"
187
+
188
+ # Find the original gemini executable.
189
+ # This is a simple example; a more robust solution might be needed
190
+ # depending on the installation method.
191
+ REAL_GEMINI_PATH=$(type -aP gemini | grep -v "^$(type -P gemini)$" | head -n 1)
192
+
193
+ if [ -z "$REAL_GEMINI_PATH" ]; then
194
+ echo "Error: The original 'gemini' executable was not found." >&2
195
+ exit 1
196
+ fi
197
+
198
+ # Pass all arguments to the real Gemini CLI executable.
199
+ exec "$REAL_GEMINI_PATH" "$@"
200
+ ```
201
+
202
+ By deploying this script, the `GEMINI_CLI_SYSTEM_SETTINGS_PATH` is set within
203
+ the script's environment, and the `exec` command replaces the script process
204
+ with the actual Gemini CLI process, which inherits the environment variable.
205
+ This makes it significantly more difficult for a user to bypass the enforced
206
+ settings.
207
+
208
+ **PowerShell Profile (Windows alternative):**
209
+
210
+ On Windows, administrators can achieve similar results by adding the environment
211
+ variable to the system-wide or user-specific PowerShell profile:
212
+
213
+ ```powershell
214
+ Add-Content -Path $PROFILE -Value '$env:GEMINI_CLI_SYSTEM_SETTINGS_PATH="C:\ProgramData\gemini-cli\settings.json"'
215
+ ```
216
+
217
+ ## User isolation in shared environments
218
+
219
+ In shared compute environments (like ML experiment runners or shared build
220
+ servers), you can isolate Gemini CLI state by overriding the user's home
221
+ directory.
222
+
223
+ By default, Gemini CLI stores configuration and history in `~/.gemini`. You can
224
+ use the `GEMINI_CLI_HOME` environment variable to point to a unique directory
225
+ for a specific user or job. The CLI will create a `.gemini` folder inside the
226
+ specified path.
227
+
228
+ **macOS/Linux**
229
+
230
+ ```bash
231
+ # Isolate state for a specific job
232
+ export GEMINI_CLI_HOME="/tmp/gemini-job-123"
233
+ gemini
234
+ ```
235
+
236
+ **Windows (PowerShell)**
237
+
238
+ ```powershell
239
+ # Isolate state for a specific job
240
+ $env:GEMINI_CLI_HOME="C:\temp\gemini-job-123"
241
+ gemini
242
+ ```
243
+
244
+ ## Restricting tool access
245
+
246
+ You can significantly enhance security by controlling which tools the Gemini
247
+ model can use. This is achieved through the `tools.core` setting and the
248
+ [Policy Engine](../reference/policy-engine.md). For a list of available tools,
249
+ see the [Tools reference](../reference/tools.md).
250
+
251
+ ### Allowlisting with `coreTools`
252
+
253
+ The most secure approach is to explicitly add the tools and commands that users
254
+ are permitted to execute to an allowlist. This prevents the use of any tool not
255
+ on the approved list.
256
+
257
+ **Example:** Allow only safe, read-only file operations and listing files.
258
+
259
+ ```json
260
+ {
261
+ "tools": {
262
+ "core": ["ReadFileTool", "GlobTool", "ShellTool(ls)"]
263
+ }
264
+ }
265
+ ```
266
+
267
+ ### Blocklisting with `excludeTools` (Deprecated)
268
+
269
+ > **Deprecated:** Use the [Policy Engine](../reference/policy-engine.md) for
270
+ > more robust control.
271
+
272
+ Alternatively, you can add specific tools that are considered dangerous in your
273
+ environment to a blocklist.
274
+
275
+ **Example:** Prevent the use of the shell tool for removing files.
276
+
277
+ ```json
278
+ {
279
+ "tools": {
280
+ "exclude": ["ShellTool(rm -rf)"]
281
+ }
282
+ }
283
+ ```
284
+
285
+ <!-- prettier-ignore -->
286
+ > [!WARNING]
287
+ > Blocklisting with `excludeTools` is less secure than
288
+ > allowlisting with `tools.core`, as it relies on blocking known-bad commands,
289
+ > and clever users may find ways to bypass simple string-based blocks.
290
+ > **Allowlisting is the recommended approach.**
291
+
292
+ ### Disabling YOLO mode
293
+
294
+ To ensure that users cannot bypass the confirmation prompt for tool execution,
295
+ you can disable YOLO mode at the policy level. This adds a critical layer of
296
+ safety, as it prevents the model from executing tools without explicit user
297
+ approval.
298
+
299
+ **Example:** Force all tool executions to require user confirmation.
300
+
301
+ ```json
302
+ {
303
+ "security": {
304
+ "disableYoloMode": true
305
+ }
306
+ }
307
+ ```
308
+
309
+ This setting is highly recommended in an enterprise environment to prevent
310
+ unintended tool execution.
311
+
312
+ ## Managing custom tools (MCP servers)
313
+
314
+ If your organization uses custom tools via
315
+ [Model-Context Protocol (MCP) servers](../tools/mcp-server.md), it is crucial to
316
+ understand how server configurations are managed to apply security policies
317
+ effectively.
318
+
319
+ ### How MCP server configurations are merged
320
+
321
+ Gemini CLI loads `settings.json` files from three levels: System, Workspace, and
322
+ User. When it comes to the `mcpServers` object, these configurations are
323
+ **merged**:
324
+
325
+ 1. **Merging:** The lists of servers from all three levels are combined into a
326
+ single list.
327
+ 2. **Precedence:** If a server with the **same name** is defined at multiple
328
+ levels (for example, a server named `corp-api` exists in both system and
329
+ user settings), the definition from the highest-precedence level is used.
330
+ The order of precedence is: **System > Workspace > User**.
331
+
332
+ This means a user **cannot** override the definition of a server that is already
333
+ defined in the system-level settings. However, they **can** add new servers with
334
+ unique names.
335
+
336
+ ### Enforcing a catalog of tools
337
+
338
+ The security of your MCP tool ecosystem depends on a combination of defining the
339
+ canonical servers and adding their names to an allowlist.
340
+
341
+ ### Restricting tools within an MCP server
342
+
343
+ For even greater security, especially when dealing with third-party MCP servers,
344
+ you can restrict which specific tools from a server are exposed to the model.
345
+ This is done using the `includeTools` and `excludeTools` properties within a
346
+ server's definition. This lets you use a subset of tools from a server without
347
+ allowing potentially dangerous ones.
348
+
349
+ Following the principle of least privilege, it is highly recommended to use
350
+ `includeTools` to create an allowlist of only the necessary tools.
351
+
352
+ **Example:** Only allow the `code-search` and `get-ticket-details` tools from a
353
+ third-party MCP server, even if the server offers other tools like
354
+ `delete-ticket`.
355
+
356
+ ```json
357
+ {
358
+ "mcp": {
359
+ "allowed": ["third-party-analyzer"]
360
+ },
361
+ "mcpServers": {
362
+ "third-party-analyzer": {
363
+ "command": "/usr/local/bin/start-3p-analyzer.sh",
364
+ "includeTools": ["code-search", "get-ticket-details"]
365
+ }
366
+ }
367
+ }
368
+ ```
369
+
370
+ #### More secure pattern: Define and add to allowlist in system settings
371
+
372
+ To create a secure, centrally-managed catalog of tools, the system administrator
373
+ **must** do both of the following in the system-level `settings.json` file:
374
+
375
+ 1. **Define the full configuration** for every approved server in the
376
+ `mcpServers` object. This ensures that even if a user defines a server with
377
+ the same name, the secure system-level definition will take precedence.
378
+ 2. **Add the names** of those servers to an allowlist using the `mcp.allowed`
379
+ setting. This is a critical security step that prevents users from running
380
+ any servers that are not on this list. If this setting is omitted, the CLI
381
+ will merge and allow any server defined by the user.
382
+
383
+ **Example system `settings.json`:**
384
+
385
+ 1. Add the _names_ of all approved servers to an allowlist. This will prevent
386
+ users from adding their own servers.
387
+
388
+ 2. Provide the canonical _definition_ for each server on the allowlist.
389
+
390
+ ```json
391
+ {
392
+ "mcp": {
393
+ "allowed": ["corp-data-api", "source-code-analyzer"]
394
+ },
395
+ "mcpServers": {
396
+ "corp-data-api": {
397
+ "command": "/usr/local/bin/start-corp-api.sh",
398
+ "timeout": 5000
399
+ },
400
+ "source-code-analyzer": {
401
+ "command": "/usr/local/bin/start-analyzer.sh"
402
+ }
403
+ }
404
+ }
405
+ ```
406
+
407
+ This pattern is more secure because it uses both definition and an allowlist.
408
+ Any server a user defines will either be overridden by the system definition (if
409
+ it has the same name) or blocked because its name is not in the `mcp.allowed`
410
+ list.
411
+
412
+ ### Less secure pattern: Omitting the allowlist
413
+
414
+ If the administrator defines the `mcpServers` object but fails to also specify
415
+ the `mcp.allowed` allowlist, users may add their own servers.
416
+
417
+ **Example system `settings.json`:**
418
+
419
+ This configuration defines servers but does not enforce the allowlist. The
420
+ administrator has NOT included the "mcp.allowed" setting.
421
+
422
+ ```json
423
+ {
424
+ "mcpServers": {
425
+ "corp-data-api": {
426
+ "command": "/usr/local/bin/start-corp-api.sh"
427
+ }
428
+ }
429
+ }
430
+ ```
431
+
432
+ In this scenario, a user can add their own server in their local
433
+ `settings.json`. Because there is no `mcp.allowed` list to filter the merged
434
+ results, the user's server will be added to the list of available tools and
435
+ allowed to run.
436
+
437
+ ## Enforcing sandboxing for security
438
+
439
+ To mitigate the risk of potentially harmful operations, you can enforce the use
440
+ of sandboxing for all tool execution. The sandbox isolates tool execution in a
441
+ containerized environment.
442
+
443
+ **Example:** Force all tool execution to happen within a Docker sandbox.
444
+
445
+ ```json
446
+ {
447
+ "tools": {
448
+ "sandbox": "docker"
449
+ }
450
+ }
451
+ ```
452
+
453
+ You can also specify a custom, hardened Docker image for the sandbox by building
454
+ a custom `sandbox.Dockerfile` as described in the
455
+ [Sandboxing documentation](./sandbox.md).
456
+
457
+ ## Controlling network access via proxy
458
+
459
+ In corporate environments with strict network policies, you can configure Gemini
460
+ CLI to route all outbound traffic through a corporate proxy. This can be set via
461
+ an environment variable, but it can also be enforced for custom tools via the
462
+ `mcpServers` configuration.
463
+
464
+ **Example (for an MCP server):**
465
+
466
+ ```json
467
+ {
468
+ "mcpServers": {
469
+ "proxied-server": {
470
+ "command": "node",
471
+ "args": ["mcp_server.js"],
472
+ "env": {
473
+ "HTTP_PROXY": "http://proxy.example.com:8080",
474
+ "HTTPS_PROXY": "http://proxy.example.com:8080"
475
+ }
476
+ }
477
+ }
478
+ }
479
+ ```
480
+
481
+ ## Telemetry and auditing
482
+
483
+ For auditing and monitoring purposes, you can configure Gemini CLI to send
484
+ telemetry data to a central location. This lets you track tool usage and other
485
+ events. For more information, see the [telemetry documentation](./telemetry.md).
486
+
487
+ **Example:** Enable telemetry and send it to a local OTLP collector. If
488
+ `otlpEndpoint` is not specified, it defaults to `http://localhost:4317`.
489
+
490
+ ```json
491
+ {
492
+ "telemetry": {
493
+ "enabled": true,
494
+ "target": "gcp",
495
+ "logPrompts": false
496
+ }
497
+ }
498
+ ```
499
+
500
+ <!-- prettier-ignore -->
501
+ > [!NOTE]
502
+ > Ensure that `logPrompts` is set to `false` in an enterprise setting to
503
+ > avoid collecting potentially sensitive information from user prompts.
504
+
505
+ ## Authentication
506
+
507
+ You can enforce a specific authentication method for all users by setting the
508
+ `security.auth.enforcedType` in the system-level `settings.json` file. This
509
+ prevents users from choosing a different authentication method. See the
510
+ [Authentication docs](../get-started/authentication.mdx) for more details.
511
+
512
+ **Example:** Enforce the use of Google login for all users.
513
+
514
+ ```json
515
+ {
516
+ "security": {
517
+ "auth": {
518
+ "enforcedType": "oauth-personal"
519
+ }
520
+ }
521
+ }
522
+ ```
523
+
524
+ If a user has a different authentication method configured, they will be
525
+ prompted to switch to the enforced method. In non-interactive mode, the CLI will
526
+ exit with an error if the configured authentication method does not match the
527
+ enforced one.
528
+
529
+ ### Restricting logins to corporate domains
530
+
531
+ For enterprises using Google Workspace, you can enforce that users only
532
+ authenticate with their corporate Google accounts. This is a network-level
533
+ control that is configured on a proxy server, not within Gemini CLI itself. It
534
+ works by intercepting authentication requests to Google and adding a special
535
+ HTTP header.
536
+
537
+ This policy prevents users from logging in with personal Gmail accounts or other
538
+ non-corporate Google accounts.
539
+
540
+ For detailed instructions, see the Google Workspace Admin Help article on
541
+ [blocking access to consumer accounts](https://support.google.com/a/answer/1668854?hl=en#zippy=%2Cstep-choose-a-web-proxy-server%2Cstep-configure-the-network-to-block-certain-accounts).
542
+
543
+ The general steps are as follows:
544
+
545
+ 1. **Intercept Requests**: Configure your web proxy to intercept all requests
546
+ to `google.com`.
547
+ 2. **Add HTTP Header**: For each intercepted request, add the
548
+ `X-GoogApps-Allowed-Domains` HTTP header.
549
+ 3. **Specify Domains**: The value of the header should be a comma-separated
550
+ list of your approved Google Workspace domain names.
551
+
552
+ **Example header:**
553
+
554
+ ```
555
+ X-GoogApps-Allowed-Domains: my-corporate-domain.com, secondary-domain.com
556
+ ```
557
+
558
+ When this header is present, Google's authentication service will only allow
559
+ logins from accounts belonging to the specified domains.
560
+
561
+ ## Putting it all together: example system `settings.json`
562
+
563
+ Here is an example of a system `settings.json` file that combines several of the
564
+ patterns discussed above to create a secure, controlled environment for Gemini
565
+ CLI.
566
+
567
+ ```json
568
+ {
569
+ "tools": {
570
+ "sandbox": "docker",
571
+ "core": [
572
+ "ReadFileTool",
573
+ "GlobTool",
574
+ "ShellTool(ls)",
575
+ "ShellTool(cat)",
576
+ "ShellTool(grep)"
577
+ ]
578
+ },
579
+ "mcp": {
580
+ "allowed": ["corp-tools"]
581
+ },
582
+ "mcpServers": {
583
+ "corp-tools": {
584
+ "command": "/opt/gemini-tools/start.sh",
585
+ "timeout": 5000
586
+ }
587
+ },
588
+ "telemetry": {
589
+ "enabled": true,
590
+ "target": "gcp",
591
+ "otlpEndpoint": "https://telemetry-prod.example.com:4317",
592
+ "logPrompts": false
593
+ },
594
+ "advanced": {
595
+ "bugCommand": {
596
+ "urlTemplate": "https://servicedesk.example.com/new-ticket?title={title}&details={info}"
597
+ }
598
+ },
599
+ "privacy": {
600
+ "usageStatisticsEnabled": false
601
+ }
602
+ }
603
+ ```
604
+
605
+ This configuration:
606
+
607
+ - Forces all tool execution into a Docker sandbox.
608
+ - Strictly uses an allowlist for a small set of safe shell commands and file
609
+ tools.
610
+ - Defines and allows a single corporate MCP server for custom tools.
611
+ - Enables telemetry for auditing, without logging prompt content.
612
+ - Redirects the `/bug` command to an internal ticketing system.
613
+ - Disables general usage statistics collection.
docs/cli/gemini-ignore.md ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ignoring files
2
+
3
+ This document provides an overview of the Gemini Ignore (`.geminiignore`)
4
+ feature of Gemini CLI.
5
+
6
+ Gemini CLI includes the ability to automatically ignore files, similar to
7
+ `.gitignore` (used by Git) and `.aiexclude` (used by Gemini Code Assist). Adding
8
+ paths to your `.geminiignore` file will exclude them from tools that support
9
+ this feature, although they will still be visible to other services (such as
10
+ Git).
11
+
12
+ ## How it works
13
+
14
+ When you add a path to your `.geminiignore` file, tools that respect this file
15
+ will exclude matching files and directories from their operations. For example,
16
+ when you use the `@` command to share files, any paths in your `.geminiignore`
17
+ file will be automatically excluded.
18
+
19
+ For the most part, `.geminiignore` follows the conventions of `.gitignore`
20
+ files:
21
+
22
+ - Blank lines and lines starting with `#` are ignored.
23
+ - Standard glob patterns are supported (such as `*`, `?`, and `[]`).
24
+ - Putting a `/` at the end will only match directories.
25
+ - Putting a `/` at the beginning anchors the path relative to the
26
+ `.geminiignore` file.
27
+ - `!` negates a pattern.
28
+
29
+ You can update your `.geminiignore` file at any time. To apply the changes, you
30
+ must restart your Gemini CLI session.
31
+
32
+ ## How to use `.geminiignore`
33
+
34
+ To enable `.geminiignore`:
35
+
36
+ 1. Create a file named `.geminiignore` in the root of your project directory.
37
+
38
+ To add a file or directory to `.geminiignore`:
39
+
40
+ 1. Open your `.geminiignore` file.
41
+ 2. Add the path or file you want to ignore, for example: `/archive/` or
42
+ `apikeys.txt`.
43
+
44
+ ### `.geminiignore` examples
45
+
46
+ You can use `.geminiignore` to ignore directories and files:
47
+
48
+ ```
49
+ # Exclude your /packages/ directory and all subdirectories
50
+ /packages/
51
+
52
+ # Exclude your apikeys.txt file
53
+ apikeys.txt
54
+ ```
55
+
56
+ You can use wildcards in your `.geminiignore` file with `*`:
57
+
58
+ ```
59
+ # Exclude all .md files
60
+ *.md
61
+ ```
62
+
63
+ Finally, you can exclude files and directories from exclusion with `!`:
64
+
65
+ ```
66
+ # Exclude all .md files except README.md
67
+ *.md
68
+ !README.md
69
+ ```
70
+
71
+ To remove paths from your `.geminiignore` file, delete the relevant lines.
docs/cli/gemini-md.md ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Provide context with GEMINI.md files
2
+
3
+ Context files, which use the default name `GEMINI.md`, are a powerful feature
4
+ for providing instructional context to the Gemini model. You can use these files
5
+ to give project-specific instructions, define a persona, or provide coding style
6
+ guides to make the AI's responses more accurate and tailored to your needs.
7
+
8
+ Instead of repeating instructions in every prompt, you can define them once in a
9
+ context file.
10
+
11
+ ## Understand the context hierarchy
12
+
13
+ The CLI uses a hierarchical system to source context. It loads various context
14
+ files from several locations, concatenates the contents of all found files, and
15
+ sends them to the model with every prompt. The CLI loads files in the following
16
+ order:
17
+
18
+ 1. **Global context file:**
19
+
20
+ - **Location:** `~/.gemini/GEMINI.md` (in your user home directory).
21
+ - **Scope:** Provides default instructions for all your projects.
22
+
23
+ 2. **Environment and workspace context files:**
24
+
25
+ - **Location:** The CLI searches for `GEMINI.md` files in your configured
26
+ workspace directories and their parent directories.
27
+ - **Scope:** Provides context relevant to the projects you are currently
28
+ working on.
29
+
30
+ 3. **Just-in-time (JIT) context files:**
31
+ - **Location:** When a tool accesses a file or directory, the CLI
32
+ automatically scans for `GEMINI.md` files in that directory and its
33
+ ancestors up to a trusted root.
34
+ - **Scope:** Lets the model discover highly specific instructions for
35
+ particular components only when they are needed.
36
+
37
+ The CLI footer displays the number of loaded context files, which gives you a
38
+ quick visual cue of the active instructional context.
39
+
40
+ ### Example `GEMINI.md` file
41
+
42
+ Here is an example of what you can include in a `GEMINI.md` file at the root of
43
+ a TypeScript project:
44
+
45
+ ```markdown
46
+ # Project: My TypeScript Library
47
+
48
+ ## General Instructions
49
+
50
+ - When you generate new TypeScript code, follow the existing coding style.
51
+ - Ensure all new functions and classes have JSDoc comments.
52
+ - Prefer functional programming paradigms where appropriate.
53
+
54
+ ## Coding Style
55
+
56
+ - Use 2 spaces for indentation.
57
+ - Prefix interface names with `I` (for example, `IUserService`).
58
+ - Always use strict equality (`===` and `!==`).
59
+ ```
60
+
61
+ ## Manage context with the `/memory` command
62
+
63
+ You can interact with the loaded context files by using the `/memory` command.
64
+
65
+ - **`/memory show`**: Displays the full, concatenated content of the current
66
+ hierarchical memory. This lets you inspect the exact instructional context
67
+ being provided to the model.
68
+ - **`/memory reload`**: Forces a re-scan and reload of all `GEMINI.md` files
69
+ from all configured locations.
70
+
71
+ ## Modularize context with imports
72
+
73
+ You can break down large `GEMINI.md` files into smaller, more manageable
74
+ components by importing content from other files using the `@file.md` syntax.
75
+ This feature supports both relative and absolute paths.
76
+
77
+ **Example `GEMINI.md` with imports:**
78
+
79
+ ```markdown
80
+ # Main GEMINI.md file
81
+
82
+ This is the main content.
83
+
84
+ @./components/instructions.md
85
+
86
+ More content here.
87
+
88
+ @../shared/style-guide.md
89
+ ```
90
+
91
+ For more details, see the [Memory Import Processor](../reference/memport.md)
92
+ documentation.
93
+
94
+ ## Customize the context file name
95
+
96
+ While `GEMINI.md` is the default filename, you can configure this in your
97
+ `settings.json` file. To specify a different name or a list of names, use the
98
+ `context.fileName` property.
99
+
100
+ **Example `settings.json`:**
101
+
102
+ ```json
103
+ {
104
+ "context": {
105
+ "fileName": ["AGENTS.md", "CONTEXT.md", "GEMINI.md"]
106
+ }
107
+ }
108
+ ```
109
+
110
+ ## Next steps
111
+
112
+ - Learn about [Ignoring files](./gemini-ignore.md) to exclude content from the
113
+ context system.
114
+ - Explore the [Memory tool](../tools/memory.md) to save persistent memories.
115
+ - See how to use [Custom commands](./custom-commands.md) to automate common
116
+ prompts.
docs/cli/generation-settings.md ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Advanced Model Configuration
2
+
3
+ This guide details the Model Configuration system within Gemini CLI. Designed
4
+ for researchers, AI quality engineers, and advanced users, this system provides
5
+ a rigorous framework for managing generative model hyperparameters and
6
+ behaviors.
7
+
8
+ <!-- prettier-ignore -->
9
+ > [!WARNING]
10
+ > This is a power-user feature. Configuration values are passed
11
+ > directly to the model provider with minimal validation. Incorrect settings
12
+ > (for example, incompatible parameter combinations) may result in runtime
13
+ > errors from the API.
14
+
15
+ ## 1. System Overview
16
+
17
+ The Model Configuration system (`ModelConfigService`) enables deterministic
18
+ control over model generation. It decouples the requested model identifier (for
19
+ example, a CLI flag or agent request) from the underlying API configuration.
20
+ This allows for:
21
+
22
+ - **Precise Hyperparameter Tuning**: Direct control over `temperature`, `topP`,
23
+ `thinkingBudget`, and other SDK-level parameters.
24
+ - **Environment-Specific Behavior**: Distinct configurations for different
25
+ operating contexts (for example, testing vs. production).
26
+ - **Agent-Scoped Customization**: Applying specific settings only when a
27
+ particular agent is active.
28
+
29
+ The system operates on two core primitives: **Aliases** and **Overrides**.
30
+
31
+ ## 2. Configuration Primitives
32
+
33
+ These settings are located under the `modelConfigs` key in your configuration
34
+ file.
35
+
36
+ ### Aliases (`customAliases`)
37
+
38
+ Aliases are named, reusable configuration presets. Users should define their own
39
+ aliases (or override system defaults) in the `customAliases` map.
40
+
41
+ - **Inheritance**: An alias can `extends` another alias (including system
42
+ defaults like `chat-base`), inheriting its `modelConfig`. Child aliases can
43
+ overwrite or augment inherited settings.
44
+ - **Abstract Aliases**: An alias is not required to specify a concrete `model`
45
+ if it serves purely as a base for other aliases.
46
+
47
+ **Example Hierarchy**:
48
+
49
+ ```json
50
+ "modelConfigs": {
51
+ "customAliases": {
52
+ "base": {
53
+ "modelConfig": {
54
+ "generateContentConfig": { "temperature": 0.0 }
55
+ }
56
+ },
57
+ "chat-base": {
58
+ "extends": "base",
59
+ "modelConfig": {
60
+ "generateContentConfig": { "temperature": 0.7 }
61
+ }
62
+ }
63
+ }
64
+ }
65
+ ```
66
+
67
+ ### Overrides (`overrides`)
68
+
69
+ Overrides are conditional rules that inject configuration based on the runtime
70
+ context. They are evaluated dynamically for each model request.
71
+
72
+ - **Match Criteria**: Overrides apply when the request context matches the
73
+ specified `match` properties.
74
+ - `model`: Matches the requested model name or alias.
75
+ - `overrideScope`: Matches the distinct scope of the request (typically the
76
+ agent name, for example, `codebaseInvestigator`).
77
+
78
+ **Example Override**:
79
+
80
+ ```json
81
+ "modelConfigs": {
82
+ "overrides": [
83
+ {
84
+ "match": {
85
+ "overrideScope": "codebaseInvestigator"
86
+ },
87
+ "modelConfig": {
88
+ "generateContentConfig": { "temperature": 0.1 }
89
+ }
90
+ }
91
+ ]
92
+ }
93
+ ```
94
+
95
+ ## 3. Resolution Strategy
96
+
97
+ The `ModelConfigService` resolves the final configuration through a two-step
98
+ process:
99
+
100
+ ### Step 1: Alias Resolution
101
+
102
+ The requested model string is looked up in the merged map of system `aliases`
103
+ and user `customAliases`.
104
+
105
+ 1. If found, the system recursively resolves the `extends` chain.
106
+ 2. Settings are merged from parent to child (child wins).
107
+ 3. This results in a base `ResolvedModelConfig`.
108
+ 4. If not found, the requested string is treated as the raw model name.
109
+
110
+ ### Step 2: Override Application
111
+
112
+ The system evaluates the `overrides` list against the request context (`model`
113
+ and `overrideScope`).
114
+
115
+ 1. **Filtering**: All matching overrides are identified.
116
+ 2. **Sorting**: Matches are prioritized by **specificity** (the number of
117
+ matched keys in the `match` object).
118
+ - Specific matches (for example, `model` + `overrideScope`) override broad
119
+ matches (for example, `model` only).
120
+ - Tie-breaking: If specificity is equal, the order of definition in the
121
+ `overrides` array is preserved (last one wins).
122
+ 3. **Merging**: The configurations from the sorted overrides are merged
123
+ sequentially onto the base configuration.
124
+
125
+ ## 4. Configuration Reference
126
+
127
+ The configuration follows the `ModelConfigServiceConfig` interface.
128
+
129
+ ### `ModelConfig` Object
130
+
131
+ Defines the actual parameters for the model.
132
+
133
+ | Property | Type | Description |
134
+ | :---------------------- | :------- | :------------------------------------------------------------------------ |
135
+ | `model` | `string` | The identifier of the model to be called (for example, `gemini-2.5-pro`). |
136
+ | `generateContentConfig` | `object` | The configuration object passed to the `@google/genai` SDK. |
137
+
138
+ ### `GenerateContentConfig` (Common Parameters)
139
+
140
+ Directly maps to the SDK's `GenerateContentConfig`. Common parameters include:
141
+
142
+ - **`temperature`**: (`number`) Controls output randomness. Lower values (0.0)
143
+ are deterministic; higher values (>0.7) are creative.
144
+ - **`topP`**: (`number`) Nucleus sampling probability.
145
+ - **`maxOutputTokens`**: (`number`) Limit on generated response length.
146
+ - **`thinkingConfig`**: (`object`) Configuration for models with reasoning
147
+ capabilities (for example, `thinkingBudget`, `includeThoughts`).
148
+
149
+ ## 5. Practical Examples
150
+
151
+ ### Defining a Deterministic Baseline
152
+
153
+ Create an alias for tasks requiring high precision, extending the standard chat
154
+ configuration but enforcing zero temperature.
155
+
156
+ ```json
157
+ "modelConfigs": {
158
+ "customAliases": {
159
+ "precise-mode": {
160
+ "extends": "chat-base",
161
+ "modelConfig": {
162
+ "generateContentConfig": {
163
+ "temperature": 0.0,
164
+ "topP": 1.0
165
+ }
166
+ }
167
+ }
168
+ }
169
+ }
170
+ ```
171
+
172
+ ### Agent-Specific Parameter Injection
173
+
174
+ Enforce extended thinking budgets for a specific agent without altering the
175
+ global default, for example for the `codebaseInvestigator`.
176
+
177
+ ```json
178
+ "modelConfigs": {
179
+ "overrides": [
180
+ {
181
+ "match": {
182
+ "overrideScope": "codebaseInvestigator"
183
+ },
184
+ "modelConfig": {
185
+ "generateContentConfig": {
186
+ "thinkingConfig": { "thinkingBudget": 4096 }
187
+ }
188
+ }
189
+ }
190
+ ]
191
+ }
192
+ ```
193
+
194
+ ### Experimental Model Evaluation
195
+
196
+ Route traffic for a specific alias to a preview model for A/B testing, without
197
+ changing client code.
198
+
199
+ ```json
200
+ "modelConfigs": {
201
+ "overrides": [
202
+ {
203
+ "match": {
204
+ "model": "gemini-2.5-pro"
205
+ },
206
+ "modelConfig": {
207
+ "model": "gemini-2.5-pro-experimental-001"
208
+ }
209
+ }
210
+ ]
211
+ }
212
+ ```
docs/cli/git-worktrees.md ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Git Worktrees (experimental)
2
+
3
+ When working on multiple tasks at once, you can use Git worktrees to give each
4
+ Gemini session its own copy of the codebase. Git worktrees create separate
5
+ working directories that each have their own files and branch while sharing the
6
+ same repository history. This prevents changes in one session from colliding
7
+ with another.
8
+
9
+ Learn more about [session management](./session-management.md).
10
+
11
+ <!-- prettier-ignore -->
12
+ > [!NOTE]
13
+ > This is an experimental feature currently under active development. Your
14
+ > feedback is invaluable as we refine this feature. If you have ideas,
15
+ > suggestions, or encounter issues:
16
+ >
17
+ > - [Open an issue](https://github.com/google-gemini/gemini-cli/issues/new?template=bug_report.yml) on GitHub.
18
+ > - Use the **/bug** command within Gemini CLI to file an issue.
19
+
20
+ Learn more in the official Git worktree
21
+ [documentation](https://git-scm.com/docs/git-worktree).
22
+
23
+ ## How to enable Git worktrees
24
+
25
+ Git worktrees are an experimental feature. You must enable them in your settings
26
+ using the `/settings` command or by manually editing your `settings.json` file.
27
+
28
+ 1. Use the `/settings` command.
29
+ 2. Search for and set **Enable Git Worktrees** to `true`.
30
+
31
+ Alternatively, add the following to your `settings.json`:
32
+
33
+ ```json
34
+ {
35
+ "experimental": {
36
+ "worktrees": true
37
+ }
38
+ }
39
+ ```
40
+
41
+ ## How to use Git worktrees
42
+
43
+ Use the `--worktree` (`-w`) flag to create an isolated worktree and start Gemini
44
+ CLI in it.
45
+
46
+ - **Start with a specific name:** The value you pass becomes both the directory
47
+ name (within `.gemini/worktrees/`) and the branch name.
48
+
49
+ ```bash
50
+ gemini --worktree feature-search
51
+ ```
52
+
53
+ - **Start with a random name:** If you omit the name, Gemini generates a random
54
+ one automatically (for example, `worktree-a1b2c3d4`).
55
+
56
+ ```bash
57
+ gemini --worktree
58
+ ```
59
+
60
+ <!-- prettier-ignore -->
61
+ > [!NOTE]
62
+ > Remember to initialize your development environment in each new
63
+ > worktree according to your project's setup. Depending on your stack, this
64
+ > might include running dependency installation (`npm install`, `yarn`), setting
65
+ > up virtual environments, or following your project's standard build process.
66
+
67
+ ## How to exit a Git worktree session
68
+
69
+ When you exit a worktree session (using `/quit` or `Ctrl+C`), Gemini leaves the
70
+ worktree intact so your work is not lost. This includes your uncommitted changes
71
+ (modified files, staged changes, or untracked files) and any new commits you
72
+ have made.
73
+
74
+ Gemini prioritizes a fast and safe exit: it **does not automatically delete**
75
+ your worktree or branch. You are responsible for cleaning up your worktrees
76
+ manually once you are finished with them.
77
+
78
+ When you exit, Gemini displays instructions on how to resume your work or how to
79
+ manually remove the worktree if you no longer need it.
80
+
81
+ ## Resuming work in a Git worktree
82
+
83
+ To resume a session in a worktree, navigate to the worktree directory and start
84
+ Gemini CLI with the `--resume` flag and the session ID:
85
+
86
+ ```bash
87
+ cd .gemini/worktrees/feature-search
88
+ gemini --resume <session_id>
89
+ ```
90
+
91
+ ## Managing Git worktrees manually
92
+
93
+ For more control over worktree location and branch configuration, or to clean up
94
+ a preserved worktree, you can use Git directly:
95
+
96
+ - **Clean up a preserved Git worktree:**
97
+ ```bash
98
+ git worktree remove .gemini/worktrees/feature-search --force
99
+ git branch -D worktree-feature-search
100
+ ```
101
+ - **Create a Git worktree manually:**
102
+ ```bash
103
+ git worktree add ../project-feature-search -b feature-search
104
+ cd ../project-feature-search && gemini
105
+ ```
106
+
107
+ [Open an issue]: https://github.com/google-gemini/gemini-cli/issues
docs/cli/headless.md ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Headless mode reference
2
+
3
+ Headless mode provides a programmatic interface to Gemini CLI, returning
4
+ structured text or JSON output without an interactive terminal UI.
5
+
6
+ ## Technical reference
7
+
8
+ Headless mode is triggered when the CLI is run in a non-TTY environment or when
9
+ providing a query with the `-p` (or `--prompt`) flag.
10
+
11
+ ### Output formats
12
+
13
+ You can specify the output format using the `--output-format` flag.
14
+
15
+ #### JSON output
16
+
17
+ Returns a single JSON object containing the response and usage statistics.
18
+
19
+ - **Schema:**
20
+ - `response`: (string) The model's final answer.
21
+ - `stats`: (object) Token usage and API latency metrics.
22
+ - `error`: (object, optional) Error details if the request failed.
23
+
24
+ #### Streaming JSON output
25
+
26
+ Returns a stream of newline-delimited JSON (JSONL) events.
27
+
28
+ - **Event types:**
29
+ - `init`: Session metadata (session ID, model).
30
+ - `message`: User and assistant message chunks.
31
+ - `tool_use`: Tool call requests with arguments.
32
+ - `tool_result`: Output from executed tools.
33
+ - `error`: Non-fatal warnings and system errors.
34
+ - `result`: Final outcome with aggregated statistics and per-model token usage
35
+ breakdowns.
36
+
37
+ ## Exit codes
38
+
39
+ The CLI returns standard exit codes to indicate the result of the headless
40
+ execution:
41
+
42
+ - `0`: Success.
43
+ - `1`: General error or API failure.
44
+ - `42`: Input error (invalid prompt or arguments).
45
+ - `53`: Turn limit exceeded.
46
+
47
+ ## Next steps
48
+
49
+ - Follow the [Automation tutorial](./tutorials/automation.md) for practical
50
+ scripting examples.
51
+ - See the [CLI reference](./cli-reference.md) for all available flags.
docs/cli/model-routing.md ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Model routing
2
+
3
+ Gemini CLI includes a model routing feature that automatically switches to a
4
+ fallback model in case of a model failure. This feature is enabled by default
5
+ and provides resilience when the primary model is unavailable.
6
+
7
+ ## How it works
8
+
9
+ Model routing is managed by the `ModelAvailabilityService`, which monitors model
10
+ health and automatically routes requests to available models based on defined
11
+ policies.
12
+
13
+ 1. **Model failure:** If the currently selected model fails (for example, due
14
+ to quota or server errors), the CLI will initiate the fallback process.
15
+
16
+ 2. **User consent:** Depending on the failure and the model's policy, the CLI
17
+ may prompt you to switch to a fallback model (by default always prompts
18
+ you).
19
+
20
+ Some internal utility calls (such as prompt completion and classification)
21
+ use a silent fallback chain for `gemini-2.5-flash-lite` and will fall back
22
+ to `gemini-2.5-flash` and `gemini-2.5-pro` without prompting or changing the
23
+ configured model.
24
+
25
+ 3. **Model switch:** If approved, or if the policy allows for silent fallback,
26
+ the CLI will use an available fallback model for the current turn or the
27
+ remainder of the session.
28
+
29
+ ### Local Model Routing (Experimental)
30
+
31
+ Gemini CLI supports using a local model for routing decisions. When configured,
32
+ Gemini CLI will use a locally-running **Gemma** model to make routing decisions
33
+ (instead of sending routing decisions to a hosted model). This feature can help
34
+ reduce costs associated with hosted model usage while offering similar routing
35
+ decision latency and quality.
36
+
37
+ The easiest way to set this up is using the automated `gemini gemma setup`
38
+ command.
39
+
40
+ For more details on how to configure local model routing, see
41
+ [`gemini gemma` — Local Model Routing Setup](../core/gemma-setup.md).
42
+
43
+ ### Model selection precedence
44
+
45
+ The model used by Gemini CLI is determined by the following order of precedence:
46
+
47
+ 1. **`--model` command-line flag:** A model specified with the `--model` flag
48
+ when launching the CLI will always be used.
49
+ 2. **`GEMINI_MODEL` environment variable:** If the `--model` flag is not used,
50
+ the CLI will use the model specified in the `GEMINI_MODEL` environment
51
+ variable.
52
+ 3. **`model.name` in `settings.json`:** If neither of the above are set, the
53
+ model specified in the `model.name` property of your `settings.json` file
54
+ will be used.
55
+ 4. **Local model (experimental):** If the Gemma local model router is enabled
56
+ in your `settings.json` file, the CLI will use the local Gemma model
57
+ (instead of Gemini models) to route the request to an appropriate model.
58
+ 5. **Default model:** If none of the above are set, the default model will be
59
+ used. The default model is `auto`
docs/cli/model-steering.md ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Model steering (experimental)
2
+
3
+ Model steering lets you provide real-time guidance and feedback to Gemini CLI
4
+ while it is actively executing a task. This lets you correct course, add missing
5
+ context, or skip unnecessary steps without having to stop and restart the agent.
6
+
7
+ <!-- prettier-ignore -->
8
+ > [!NOTE]
9
+ > This is an experimental feature currently under active development and
10
+ > may need to be enabled under `/settings`.
11
+
12
+ Model steering is particularly useful during complex [Plan Mode](./plan-mode.md)
13
+ workflows or long-running subagent executions where you want to ensure the agent
14
+ stays on the right track.
15
+
16
+ ## Enabling model steering
17
+
18
+ Model steering is an experimental feature and is disabled by default. You can
19
+ enable it using the `/settings` command or by updating your `settings.json`
20
+ file.
21
+
22
+ 1. Type `/settings` in Gemini CLI.
23
+ 2. Search for **Model Steering**.
24
+ 3. Set the value to **true**.
25
+
26
+ Alternatively, add the following to your `settings.json`:
27
+
28
+ ```json
29
+ {
30
+ "experimental": {
31
+ "modelSteering": true
32
+ }
33
+ }
34
+ ```
35
+
36
+ ## Using model steering
37
+
38
+ When model steering is enabled, Gemini CLI treats any text you type while the
39
+ agent is working as a steering hint.
40
+
41
+ 1. Start a task (for example, "Refactor the database service").
42
+ 2. While the agent is working (the spinner is visible), type your feedback in
43
+ the input box.
44
+ 3. Press **Enter**.
45
+
46
+ Gemini CLI acknowledges your hint with a brief message and injects it directly
47
+ into the model's context for the very next turn. The model then re-evaluates its
48
+ current plan and adjusts its actions accordingly.
49
+
50
+ ### Common use cases
51
+
52
+ You can use steering hints to guide the model in several ways:
53
+
54
+ - **Correcting a path:** "Actually, the utilities are in `src/common/utils`."
55
+ - **Skipping a step:** "Skip the unit tests for now and just focus on the
56
+ implementation."
57
+ - **Adding context:** "The `User` type is defined in `packages/core/types.ts`."
58
+ - **Redirecting the effort:** "Stop searching the codebase and start drafting
59
+ the plan now."
60
+ - **Handling ambiguity:** "Use the existing `Logger` class instead of creating a
61
+ new one."
62
+
63
+ ## How it works
64
+
65
+ When you submit a steering hint, Gemini CLI performs the following actions:
66
+
67
+ 1. **Immediate acknowledgment:** It uses a small, fast model to generate a
68
+ one-sentence acknowledgment so you know your hint was received.
69
+ 2. **Context injection:** It prepends an internal instruction to your hint that
70
+ tells the main agent to:
71
+ - Re-evaluate the active plan.
72
+ - Classify the update (for example, as a new task or extra context).
73
+ - Apply minimal-diff changes to affected tasks.
74
+ 3. **Real-time update:** The hint is delivered to the agent at the beginning of
75
+ its next turn, ensuring the most immediate course correction possible.
76
+
77
+ ## Next steps
78
+
79
+ - Tackle complex tasks with [Plan Mode](./plan-mode.md).
80
+ - Build custom [Agent Skills](./skills.md).
docs/cli/model.md ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Gemini CLI model selection (`/model` command)
2
+
3
+ Select your Gemini CLI model. The `/model` command lets you configure the model
4
+ used by Gemini CLI, giving you more control over your results. Use **Pro**
5
+ models for complex tasks and reasoning, **Flash** models for high speed results,
6
+ or the (recommended) **Auto** setting to choose the best model for your tasks.
7
+
8
+ <!-- prettier-ignore -->
9
+ > [!NOTE]
10
+ > The `/model` command (and the `--model` flag) does not override the
11
+ > model used by sub-agents. Consequently, even when using the `/model` flag you
12
+ > may see other models used in your model usage reports.
13
+
14
+ ## How to use the `/model` command
15
+
16
+ Use the following command in Gemini CLI:
17
+
18
+ ```
19
+ /model
20
+ ```
21
+
22
+ Running this command will open a dialog with your options:
23
+
24
+ | Option | Description | Models |
25
+ | ----------------- | -------------------------------------------------------------- | -------------------------------------------- |
26
+ | Auto (Gemini 3) | Let the system choose the best Gemini 3 model for your task. | gemini-3-pro-preview, gemini-3-flash-preview |
27
+ | Auto (Gemini 2.5) | Let the system choose the best Gemini 2.5 model for your task. | gemini-2.5-pro, gemini-2.5-flash |
28
+ | Manual | Select a specific model. | Any available model. |
29
+
30
+ We recommend selecting one of the above **Auto** options. However, you can
31
+ select **Manual** to select a specific model from those available.
32
+
33
+ You can also use the `--model` flag to specify a particular Gemini model on
34
+ startup. For more details, refer to the
35
+ [configuration documentation](../reference/configuration.md).
36
+
37
+ Changes to these settings will be applied to all subsequent interactions with
38
+ Gemini CLI.
39
+
40
+ ## Best practices for model selection
41
+
42
+ - **Default to Auto.** For most users, the _Auto_ option model provides a
43
+ balance between speed and performance, automatically selecting the correct
44
+ model based on the complexity of the task. Example: Developing a web
45
+ application could include a mix of complex tasks (building architecture and
46
+ scaffolding the project) and simple tasks (generating CSS).
47
+
48
+ - **Switch to Pro if you aren't getting the results you want.** If you think you
49
+ need your model to be a little "smarter," you can manually select Pro. Pro
50
+ will provide you with the highest levels of reasoning and creativity. Example:
51
+ A complex or multi-stage debugging task.
52
+
53
+ - **Switch to Flash or Flash-Lite if you need faster results.** If you need a
54
+ simple response quickly, Flash or Flash-Lite is the best option. Example:
55
+ Converting a JSON object to a YAML string.
docs/cli/notifications.md ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Notifications (experimental)
2
+
3
+ Gemini CLI can send system notifications to alert you when a session completes
4
+ or when it needs your attention, such as when it's waiting for you to approve a
5
+ tool call.
6
+
7
+ <!-- prettier-ignore -->
8
+ > [!NOTE]
9
+ > This is an experimental feature currently under active development and
10
+ > may need to be enabled under `/settings`.
11
+
12
+ Notifications are particularly useful when running long-running tasks or using
13
+ [Plan Mode](./plan-mode.md), letting you switch to other windows while Gemini
14
+ CLI works in the background.
15
+
16
+ ## Requirements
17
+
18
+ ### Terminal support
19
+
20
+ The CLI uses the OSC 9 terminal escape sequence to trigger system notifications.
21
+ This is supported by several modern terminal emulators including iTerm2,
22
+ WezTerm, Ghostty, and Kitty. If your terminal does not support OSC 9
23
+ notifications, Gemini CLI falls back to a terminal bell (BEL) to get your
24
+ attention. Most terminals respond to BEL with a taskbar flash or system alert
25
+ sound.
26
+
27
+ ## Enable notifications
28
+
29
+ Notifications are disabled by default. You can enable them using the `/settings`
30
+ command or by updating your `settings.json` file.
31
+
32
+ 1. Open the settings dialog by typing `/settings` in an interactive session.
33
+ 2. Navigate to the **General** category.
34
+ 3. Toggle the **Enable Notifications** setting to **On**.
35
+
36
+ Alternatively, add the following to your `settings.json`:
37
+
38
+ ```json
39
+ {
40
+ "general": {
41
+ "enableNotifications": true
42
+ }
43
+ }
44
+ ```
45
+
46
+ ## Types of notifications
47
+
48
+ Gemini CLI sends notifications for the following events:
49
+
50
+ - **Action required:** Triggered when the model is waiting for user input or
51
+ tool approval. This helps you know when the CLI has paused and needs you to
52
+ intervene.
53
+ - **Session complete:** Triggered when a session finishes successfully. This is
54
+ useful for tracking the completion of automated tasks.
55
+
56
+ ## Next steps
57
+
58
+ - Start planning with [Plan Mode](./plan-mode.md).
59
+ - Configure your experience with other [settings](./settings.md).
docs/cli/plan-mode.md ADDED
@@ -0,0 +1,509 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Plan Mode
2
+
3
+ Plan Mode is a read-only environment for architecting robust solutions before
4
+ implementation. With Plan Mode, you can:
5
+
6
+ - **Research:** Explore the project in a read-only state to prevent accidental
7
+ changes.
8
+ - **Design:** Understand problems, evaluate trade-offs, and choose a solution.
9
+ - **Plan:** Align on an execution strategy before any code is modified.
10
+
11
+ Plan Mode is enabled by default. You can manage this setting using the
12
+ `/settings` command.
13
+
14
+ ## How to enter Plan Mode
15
+
16
+ Plan Mode integrates seamlessly into your workflow, letting you switch between
17
+ planning and execution as needed.
18
+
19
+ You can either configure Gemini CLI to start in Plan Mode by default or enter
20
+ Plan Mode manually during a session.
21
+
22
+ ### Launch in Plan Mode
23
+
24
+ To start Gemini CLI directly in Plan Mode by default:
25
+
26
+ 1. Use the `/settings` command.
27
+ 2. Set **Default Approval Mode** to `Plan`.
28
+
29
+ To launch Gemini CLI in Plan Mode once:
30
+
31
+ 1. Use `gemini --approval-mode=plan` when launching Gemini CLI.
32
+
33
+ ### Enter Plan Mode manually
34
+
35
+ To start Plan Mode while using Gemini CLI:
36
+
37
+ - **Keyboard shortcut:** Press `Shift+Tab` to cycle through approval modes
38
+ (`Default` -> `Auto-Edit` -> `Plan`). Plan Mode is automatically removed from
39
+ the rotation when Gemini CLI is actively processing or showing confirmation
40
+ dialogs.
41
+
42
+ - **Command:** Type `/plan [goal]` in the input box. The `[goal]` is optional;
43
+ for example, `/plan implement authentication` will switch to Plan Mode and
44
+ immediately submit the prompt to the model.
45
+
46
+ - **Natural Language:** Ask Gemini CLI to "start a plan for...". Gemini CLI
47
+ calls the
48
+ [`enter_plan_mode`](../tools/planning.md#1-enter_plan_mode-enterplanmode) tool
49
+ to switch modes. This tool is not available when Gemini CLI is in
50
+ [YOLO mode](../reference/configuration.md#command-line-arguments).
51
+
52
+ ## How to use Plan Mode
53
+
54
+ Plan Mode lets you collaborate with Gemini CLI to design a solution before
55
+ Gemini CLI takes action.
56
+
57
+ 1. **Provide a goal:** Start by describing what you want to achieve. Gemini CLI
58
+ will then enter Plan Mode (if it's not already) to research the task.
59
+ 2. **Discuss and agree on strategy:** As Gemini CLI analyzes your codebase, it
60
+ will discuss its findings and proposed strategy with you to ensure
61
+ alignment. It may ask you questions or present different implementation
62
+ options using [`ask_user`](../tools/ask-user.md). **Gemini CLI will stop and
63
+ wait for your confirmation** before drafting the formal plan. You should
64
+ reach an informal agreement on the approach before proceeding.
65
+ 3. **Review the plan:** Once you've agreed on the strategy, Gemini CLI creates
66
+ a detailed implementation plan as a Markdown file in your plans directory.
67
+
68
+ - **View:** You can open and read this file to understand the proposed
69
+ changes.
70
+ - **Edit:** Press `Ctrl+X` to open the plan directly in your configured
71
+ external editor.
72
+
73
+ 4. **Approve or iterate:** Gemini CLI will present the finalized plan for your
74
+ formal approval.
75
+ - **Approve:** If you're satisfied with the plan, approve it to start the
76
+ implementation immediately: **Yes, automatically accept edits** or **Yes,
77
+ manually accept edits**.
78
+ - **Iterate:** If the plan needs adjustments, provide feedback in the input
79
+ box or [edit the plan file directly](#collaborative-plan-editing). Gemini
80
+ CLI will refine the strategy and update the plan.
81
+ - **Cancel:** You can cancel your plan with `Esc`.
82
+
83
+ For more complex or specialized planning tasks, you can
84
+ [customize the planning workflow with skills](#custom-planning-with-skills).
85
+
86
+ ### Collaborative plan editing
87
+
88
+ You can collaborate with Gemini CLI by making direct changes or leaving comments
89
+ in the implementation plan. This is often faster and more precise than
90
+ describing complex changes in natural language.
91
+
92
+ 1. **Open the plan:** Press `Ctrl+X` when Gemini CLI presents a plan for
93
+ review.
94
+ 2. **Edit or comment:** The plan opens in your configured external editor (for
95
+ example, VS Code or Vim). You can:
96
+ - **Modify steps:** Directly reorder, delete, or rewrite implementation
97
+ steps.
98
+ - **Leave comments:** Add inline questions or feedback (for example, "Wait,
99
+ shouldn't we use the existing `Logger` class here?").
100
+ 3. **Save and close:** Save your changes and close the editor.
101
+ 4. **Review and refine:** Gemini CLI automatically detects the changes, reviews
102
+ your comments, and adjusts the implementation strategy. It then presents the
103
+ refined plan for your final approval.
104
+
105
+ ## How to exit Plan Mode
106
+
107
+ You can exit Plan Mode at any time, whether you have finalized a plan or want to
108
+ switch back to another mode.
109
+
110
+ - **Approve a plan:** When Gemini CLI presents a finalized plan, approving it
111
+ automatically exits Plan Mode and starts the implementation.
112
+ - **Keyboard shortcut:** Press `Shift+Tab` to cycle to the desired mode.
113
+ - **Natural language:** Ask Gemini CLI to "exit plan mode" or "stop planning."
114
+
115
+ ## Tool Restrictions
116
+
117
+ Plan Mode enforces strict safety policies to prevent accidental changes.
118
+
119
+ These are the only allowed tools:
120
+
121
+ - **FileSystem (Read):**
122
+ [`read_file`](../tools/file-system.md#2-read_file-readfile),
123
+ [`list_directory`](../tools/file-system.md#1-list_directory-readfolder),
124
+ [`glob`](../tools/file-system.md#4-glob-findfiles)
125
+ - **Search:** [`grep_search`](../tools/file-system.md#5-grep_search-searchtext),
126
+ [`google_web_search`](../tools/web-search.md),
127
+ [`web_fetch`](../tools/web-fetch.md) (requires explicit confirmation),
128
+ [`get_internal_docs`](../tools/internal-docs.md)
129
+ - **Research Subagents:**
130
+ [`codebase_investigator`](../core/subagents.md#codebase-investigator),
131
+ [`cli_help`](../core/subagents.md#cli-help-agent)
132
+ - **Interaction:** [`ask_user`](../tools/ask-user.md)
133
+ - **MCP tools (Read):** Read-only [MCP tools](../tools/mcp-server.md) (for
134
+ example, `github_read_issue`, `postgres_read_schema`) and core
135
+ [MCP resource tools](../tools/mcp-resources.md) (`list_mcp_resources`,
136
+ `read_mcp_resource`) are allowed.
137
+ - **Planning (Write):**
138
+ [`write_file`](../tools/file-system.md#3-write_file-writefile) and
139
+ [`replace`](../tools/file-system.md#6-replace-edit) only allowed for `.md`
140
+ files in the `~/.gemini/tmp/<project>/<session-id>/plans/` directory or your
141
+ [custom plans directory](#custom-plan-directory-and-policies).
142
+ - **Skills:** [`activate_skill`](../cli/skills.md) (allows loading specialized
143
+ instructions and resources in a read-only manner)
144
+
145
+ ## Customization and best practices
146
+
147
+ Plan Mode is secure by default, but you can adapt it to fit your specific
148
+ workflows. You can customize how Gemini CLI plans by using skills, adjusting
149
+ safety policies, changing where plans are stored, or adding hooks.
150
+
151
+ ### Custom planning with skills
152
+
153
+ You can use [Agent Skills](../cli/skills.md) to customize how Gemini CLI
154
+ approaches planning for specific types of tasks. When a skill is activated
155
+ during Plan Mode, its specialized instructions and procedural workflows will
156
+ guide the research, design, and planning phases.
157
+
158
+ For example:
159
+
160
+ - A **"Database Migration"** skill could ensure the plan includes data safety
161
+ checks and rollback strategies.
162
+ - A **"Security Audit"** skill could prompt Gemini CLI to look for specific
163
+ vulnerabilities during codebase exploration.
164
+ - A **"Frontend Design"** skill could guide Gemini CLI to use specific UI
165
+ components and accessibility standards in its proposal.
166
+
167
+ To use a skill in Plan Mode, you can explicitly ask Gemini CLI to "use the
168
+ `<skill-name>` skill to plan..." or Gemini CLI may autonomously activate it
169
+ based on the task description.
170
+
171
+ ### Custom policies
172
+
173
+ Plan Mode's default tool restrictions are managed by the
174
+ [policy engine](../reference/policy-engine.md) and defined in the built-in
175
+ [`plan.toml`] file. The built-in policy (Tier 1) enforces the read-only state,
176
+ but you can customize these rules by creating your own policies in your
177
+ `~/.gemini/policies/` directory (Tier 2).
178
+
179
+ #### Global vs. mode-specific rules
180
+
181
+ As described in the
182
+ [policy engine documentation](../reference/policy-engine.md#approval-modes), any
183
+ rule that does not explicitly specify `modes` is considered "always active" and
184
+ will apply to Plan Mode as well.
185
+
186
+ To maintain the integrity of Plan Mode as a safe research environment,
187
+ persistent tool approvals are context-aware. Approvals granted in modes like
188
+ Default or Auto-Edit do not apply to Plan Mode, ensuring that tools trusted for
189
+ implementation don't automatically execute while you're researching. However,
190
+ approvals granted while in Plan Mode are treated as intentional choices for
191
+ global trust and apply to all modes.
192
+
193
+ If you want to manually restrict a rule to other modes but _not_ to Plan Mode,
194
+ you must explicitly specify the target modes. For example, to allow `npm test`
195
+ in default and Auto-Edit modes but not in Plan Mode:
196
+
197
+ ```toml
198
+ [[rule]]
199
+ toolName = "run_shell_command"
200
+ commandPrefix = "npm test"
201
+ decision = "allow"
202
+ priority = 100
203
+ # By omitting "plan", this rule will not be active in Plan Mode.
204
+ modes = ["default", "autoEdit"]
205
+ ```
206
+
207
+ #### Example: Automatically approve read-only MCP tools
208
+
209
+ By default, read-only MCP tools require user confirmation in Plan Mode. You can
210
+ use `toolAnnotations` and the `mcpName` wildcard to customize this behavior for
211
+ your specific environment.
212
+
213
+ `~/.gemini/policies/mcp-read-only.toml`
214
+
215
+ ```toml
216
+ [[rule]]
217
+ toolName = "*"
218
+ mcpName = "*"
219
+ toolAnnotations = { readOnlyHint = true }
220
+ decision = "allow"
221
+ priority = 100
222
+ modes = ["plan"]
223
+ ```
224
+
225
+ For more information on how the policy engine works, see the
226
+ [policy engine](../reference/policy-engine.md) docs.
227
+
228
+ #### Example: Allow git commands in Plan Mode
229
+
230
+ This rule lets you check the repository status and see changes while in Plan
231
+ Mode.
232
+
233
+ `~/.gemini/policies/git-research.toml`
234
+
235
+ ```toml
236
+ [[rule]]
237
+ toolName = "run_shell_command"
238
+ commandPrefix = ["git status", "git diff"]
239
+ decision = "allow"
240
+ priority = 100
241
+ modes = ["plan"]
242
+ ```
243
+
244
+ #### Example: Enable custom subagents in Plan Mode
245
+
246
+ Built-in research [subagents](../core/subagents.md) like
247
+ [`codebase_investigator`](../core/subagents.md#codebase-investigator) and
248
+ [`cli_help`](../core/subagents.md#cli-help-agent) are enabled by default in Plan
249
+ Mode. You can enable additional
250
+ [custom subagents](../core/subagents.md#creating-custom-subagents) by adding a
251
+ rule to your policy.
252
+
253
+ `~/.gemini/policies/research-subagents.toml`
254
+
255
+ ```toml
256
+ [[rule]]
257
+ toolName = "my_custom_subagent"
258
+ decision = "allow"
259
+ priority = 100
260
+ modes = ["plan"]
261
+ ```
262
+
263
+ Tell Gemini CLI it can use these tools in your prompt, for example: _"You can
264
+ check ongoing changes in git."_
265
+
266
+ ### Custom plan directory and policies
267
+
268
+ By default, planning artifacts are stored in a managed temporary directory
269
+ outside your project: `~/.gemini/tmp/<project>/<session-id>/plans/`.
270
+
271
+ You can configure a custom directory for plans in your `settings.json`. For
272
+ example, to store plans in a `.gemini/plans` directory within your project:
273
+
274
+ ```json
275
+ {
276
+ "general": {
277
+ "plan": {
278
+ "directory": ".gemini/plans"
279
+ }
280
+ }
281
+ }
282
+ ```
283
+
284
+ To maintain the safety of Plan Mode, user-configured paths for the plans
285
+ directory are restricted to the project root. This ensures that custom planning
286
+ locations defined within a project's workspace cannot be used to escape and
287
+ overwrite sensitive files elsewhere. Any user-configured directory must reside
288
+ within the project boundary.
289
+
290
+ Using a custom directory requires updating your
291
+ [policy engine](../reference/policy-engine.md) configurations to allow
292
+ `write_file` and `replace` in that specific location. For example, to allow
293
+ writing to the `.gemini/plans` directory within your project, create a policy
294
+ file at `~/.gemini/policies/plan-custom-directory.toml`:
295
+
296
+ ```toml
297
+ [[rule]]
298
+ toolName = ["write_file", "replace"]
299
+ decision = "allow"
300
+ priority = 100
301
+ modes = ["plan"]
302
+ # Adjust the pattern to match your custom directory.
303
+ # This example matches any .md file in a .gemini/plans directory within the project.
304
+ argsPattern = "\"file_path\":\"[^\"]+[\\\\/]+\\.gemini[\\\\/]+plans[\\\\/]+[\\w-]+\\.md\""
305
+ ```
306
+
307
+ ### Using hooks with Plan Mode
308
+
309
+ You can use the [hook system](../hooks/writing-hooks.md) to automate parts of
310
+ the planning workflow or enforce additional checks when Gemini CLI transitions
311
+ into or out of Plan Mode.
312
+
313
+ Hooks such as `BeforeTool` or `AfterTool` can be configured to intercept the
314
+ `enter_plan_mode` and `exit_plan_mode` tool calls.
315
+
316
+ > [!WARNING] When hooks are triggered by **tool executions**, they do **not**
317
+ > run when you manually toggle Plan Mode using the `/plan` command or the
318
+ > `Shift+Tab` keyboard shortcut. If you need hooks to execute on mode changes,
319
+ > ensure the transition is initiated by the agent (for example, by asking "start
320
+ > a plan for...").
321
+
322
+ #### Example: Archive approved plans to GCS (`AfterTool`)
323
+
324
+ If your organizational policy requires a record of all execution plans, you can
325
+ use an `AfterTool` hook to securely copy the plan artifact to Google Cloud
326
+ Storage whenever Gemini CLI exits Plan Mode to start the implementation.
327
+
328
+ **`.gemini/hooks/archive-plan.sh`:**
329
+
330
+ ```bash
331
+ #!/usr/bin/env bash
332
+ # Extract the plan filename from the tool input JSON
333
+ plan_filename=$(jq -r '.tool_input.plan_filename // empty')
334
+
335
+ # Construct the absolute path using the GEMINI_PLANS_DIR environment variable
336
+ plan_path="$GEMINI_PLANS_DIR/$plan_filename"
337
+
338
+ if [ -f "$plan_path" ]; then
339
+ # Generate a unique filename using a timestamp
340
+ filename="$(date +%s)_$(basename "$plan_path")"
341
+
342
+ # Upload the plan to GCS in the background so it doesn't block the CLI
343
+ gsutil cp "$plan_path" "gs://my-audit-bucket/gemini-plans/$filename" > /dev/null 2>&1 &
344
+ fi
345
+
346
+ # AfterTool hooks should generally allow the flow to continue
347
+ echo '{"decision": "allow"}'
348
+ ```
349
+
350
+ To register this `AfterTool` hook, add it to your `settings.json`:
351
+
352
+ ```json
353
+ {
354
+ "hooks": {
355
+ "AfterTool": [
356
+ {
357
+ "matcher": "exit_plan_mode",
358
+ "hooks": [
359
+ {
360
+ "name": "archive-plan",
361
+ "type": "command",
362
+ "command": "~/.gemini/hooks/archive-plan.sh"
363
+ }
364
+ ]
365
+ }
366
+ ]
367
+ }
368
+ }
369
+ ```
370
+
371
+ ## Commands
372
+
373
+ - **`/plan copy`**: Copy the currently approved plan to your clipboard.
374
+
375
+ ## Planning workflows
376
+
377
+ Plan Mode provides building blocks for structured research and design. These are
378
+ implemented as [extensions](../extensions/index.md) using core planning tools
379
+ like [`enter_plan_mode`](../tools/planning.md#1-enter_plan_mode-enterplanmode),
380
+ [`exit_plan_mode`](../tools/planning.md#2-exit_plan_mode-exitplanmode), and
381
+ [`ask_user`](../tools/ask-user.md).
382
+
383
+ ### Built-in planning workflow
384
+
385
+ The built-in planner uses an adaptive workflow to analyze your project, consult
386
+ you on trade-offs via [`ask_user`](../tools/ask-user.md), and draft a plan for
387
+ your approval.
388
+
389
+ ### Custom planning workflows
390
+
391
+ You can install or create specialized planners to suit your workflow.
392
+
393
+ #### Conductor
394
+
395
+ [Conductor] is designed for spec-driven development. It organizes work into
396
+ "tracks" and stores persistent artifacts in your project's `conductor/`
397
+ directory:
398
+
399
+ - **Automate transitions:** Switches to read-only mode via
400
+ [`enter_plan_mode`](../tools/planning.md#1-enter_plan_mode-enterplanmode).
401
+ - **Streamline decisions:** Uses [`ask_user`](../tools/ask-user.md) for
402
+ architectural choices.
403
+ - **Maintain project context:** Stores artifacts in the project directory using
404
+ [custom plan directory and policies](#custom-plan-directory-and-policies).
405
+ - **Handoff execution:** Transitions to implementation via
406
+ [`exit_plan_mode`](../tools/planning.md#2-exit_plan_mode-exitplanmode).
407
+
408
+ #### Build your own
409
+
410
+ Since Plan Mode is built on modular building blocks, you can develop your own
411
+ custom planning workflow as an [extensions](../extensions/index.md). By
412
+ leveraging core tools and [custom policies](#custom-policies), you can define
413
+ how Gemini CLI researches and stores plans for your specific domain.
414
+
415
+ To build a custom planning workflow, you can use:
416
+
417
+ - **Tool usage:** Use core tools like
418
+ [`enter_plan_mode`](../tools/planning.md#1-enter_plan_mode-enterplanmode),
419
+ [`ask_user`](../tools/ask-user.md), and
420
+ [`exit_plan_mode`](../tools/planning.md#2-exit_plan_mode-exitplanmode) to
421
+ manage the research and design process.
422
+ - **Customization:** Set your own storage locations and policy rules using
423
+ [custom plan directories](#custom-plan-directory-and-policies) and
424
+ [custom policies](#custom-policies).
425
+
426
+ <!-- prettier-ignore -->
427
+ > [!TIP]
428
+ > Use [Conductor] as a reference when building your own custom
429
+ > planning workflow.
430
+
431
+ By using Plan Mode as its execution environment, your custom methodology can
432
+ enforce read-only safety during the design phase while benefiting from
433
+ high-reasoning model routing.
434
+
435
+ ## Automatic Model Routing
436
+
437
+ When using an [auto model](../reference/configuration.md#model), Gemini CLI
438
+ automatically optimizes [model routing](../cli/telemetry.md#model-routing) based
439
+ on the current phase of your task:
440
+
441
+ 1. **Planning Phase:** While in Plan Mode, the CLI routes requests to a
442
+ high-reasoning **Pro** model to ensure robust architectural decisions and
443
+ high-quality plans.
444
+ 2. **Implementation Phase:** Once a plan is approved and you exit Plan Mode,
445
+ the CLI detects the existence of the approved plan and automatically
446
+ switches to a high-speed **Flash** model. This provides a faster, more
447
+ responsive experience during the implementation of the plan.
448
+
449
+ If the high-reasoning model is unavailable or you don't have access to it,
450
+ Gemini CLI automatically and silently falls back to a faster model to ensure
451
+ your workflow isn't interrupted.
452
+
453
+ This behavior is enabled by default to provide the best balance of quality and
454
+ performance. You can disable this automatic switching in your settings:
455
+
456
+ ```json
457
+ {
458
+ "general": {
459
+ "plan": {
460
+ "modelRouting": false
461
+ }
462
+ }
463
+ }
464
+ ```
465
+
466
+ ## Cleanup
467
+
468
+ By default, Gemini CLI automatically cleans up old session data, including all
469
+ associated plan files and task trackers.
470
+
471
+ - **Default behavior:** Sessions (and their plans) are retained for **30 days**.
472
+ - **Configuration:** You can customize this behavior via the `/settings` command
473
+ (search for **Enable Session Cleanup** or **Keep chat history**) or in your
474
+ `settings.json` file. See
475
+ [session retention](../cli/session-management.md#session-retention) for more
476
+ details.
477
+
478
+ Manual deletion also removes all associated artifacts:
479
+
480
+ - **Command Line:** Use `gemini --delete-session <index|id>`.
481
+ - **Session Browser:** Press `/resume`, navigate to a session, and press `x`.
482
+
483
+ If you use a [custom plans directory](#custom-plan-directory-and-policies),
484
+ those files are not automatically deleted and must be managed manually.
485
+
486
+ ## Non-interactive execution
487
+
488
+ When running Gemini CLI in non-interactive environments (such as headless
489
+ scripts or CI/CD pipelines), Plan Mode optimizes for automated workflows:
490
+
491
+ - **Automatic transitions:** The policy engine automatically approves the
492
+ `enter_plan_mode` and `exit_plan_mode` tools without prompting for user
493
+ confirmation.
494
+ - **Automated implementation:** When exiting Plan Mode to execute the plan,
495
+ Gemini CLI automatically switches to
496
+ [YOLO mode](../reference/policy-engine.md#approval-modes) instead of the
497
+ standard Default mode. This allows the CLI to execute the implementation steps
498
+ automatically without hanging on interactive tool approvals.
499
+
500
+ **Example:**
501
+
502
+ ```bash
503
+ gemini --approval-mode plan -p "Analyze telemetry and suggest improvements"
504
+ ```
505
+
506
+ [`plan.toml`]:
507
+ https://github.com/google-gemini/gemini-cli/blob/main/packages/core/src/policy/policies/plan.toml
508
+ [Conductor]: https://github.com/gemini-cli-extensions/conductor
509
+ [open an issue]: https://github.com/google-gemini/gemini-cli/issues
docs/cli/rewind.md ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Rewind
2
+
3
+ The `/rewind` command lets you go back to a previous state in your conversation
4
+ and, optionally, revert any file changes made by the AI during those
5
+ interactions. This is a powerful tool for undoing mistakes, exploring different
6
+ approaches, or simply cleaning up your session history.
7
+
8
+ ## Usage
9
+
10
+ To use the rewind feature, simply type `/rewind` into the input prompt and press
11
+ **Enter**.
12
+
13
+ Alternatively, you can use the keyboard shortcut: **Press `Esc` twice**.
14
+
15
+ ## Interface
16
+
17
+ When you trigger a rewind, an interactive list of your previous interactions
18
+ appears.
19
+
20
+ 1. **Select interaction:** Use the **Up/Down arrow keys** to navigate through
21
+ the list. The most recent interactions are at the bottom.
22
+ 2. **Preview:** As you select an interaction, you'll see a preview of the user
23
+ prompt and, if applicable, the number of files changed during that step.
24
+ 3. **Confirm selection:** Press **Enter** on the interaction you want to rewind
25
+ back to.
26
+ 4. **Action selection:** After selecting an interaction, you'll be presented
27
+ with a confirmation dialog with up to three options:
28
+ - **Rewind conversation and revert code changes:** Reverts both the chat
29
+ history and the file modifications to the state before the selected
30
+ interaction.
31
+ - **Rewind conversation:** Only reverts the chat history. File changes are
32
+ kept.
33
+ - **Revert code changes:** Only reverts the file modifications. The chat
34
+ history is kept.
35
+ - **Do nothing (esc):** Cancels the rewind operation.
36
+
37
+ If no code changes were made since the selected point, the options related to
38
+ reverting code changes will be hidden.
39
+
40
+ ## Key considerations
41
+
42
+ - **Destructive action:** Rewinding is a destructive action for your current
43
+ session history and potentially your files. Use it with care.
44
+ - **Agent awareness:** When you rewind the conversation, the AI model loses all
45
+ memory of the interactions that were removed. If you only revert code changes,
46
+ you may need to inform the model that the files have changed.
47
+ - **Manual edits:** Rewinding only affects file changes made by the AI's edit
48
+ tools. It does **not** undo manual edits you've made or changes triggered by
49
+ the shell tool (`!`).
50
+ - **Compression:** Rewind works across chat compression points by reconstructing
51
+ the history from stored session data.
docs/cli/sandbox.md ADDED
@@ -0,0 +1,473 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Sandboxing in Gemini CLI
2
+
3
+ This document provides a guide to sandboxing in Gemini CLI, including
4
+ prerequisites, quickstart, and configuration.
5
+
6
+ ## Prerequisites
7
+
8
+ Before using sandboxing, you need to install and set up Gemini CLI:
9
+
10
+ ```bash
11
+ npm install -g @google/gemini-cli
12
+ ```
13
+
14
+ To verify the installation:
15
+
16
+ ```bash
17
+ gemini --version
18
+ ```
19
+
20
+ ## Overview of sandboxing
21
+
22
+ Sandboxing isolates potentially dangerous operations (such as shell commands or
23
+ file modifications) from your host system, providing a security barrier between
24
+ AI operations and your environment.
25
+
26
+ The benefits of sandboxing include:
27
+
28
+ - **Security**: Prevent accidental system damage or data loss.
29
+ - **Isolation**: Limit file system access to project directory.
30
+ - **Consistency**: Ensure reproducible environments across different systems.
31
+ - **Safety**: Reduce risk when working with untrusted code or experimental
32
+ commands.
33
+
34
+ ## Quickstart
35
+
36
+ You can enable sandboxing using a command flag, environment variable, or
37
+ configuration file.
38
+
39
+ ### Using the command flag
40
+
41
+ ```bash
42
+ gemini -s -p "analyze the code structure"
43
+ ```
44
+
45
+ ### Using an environment variable
46
+
47
+ **macOS/Linux**
48
+
49
+ ```bash
50
+ export GEMINI_SANDBOX=true
51
+ gemini -p "run the test suite"
52
+ ```
53
+
54
+ **Windows (PowerShell)**
55
+
56
+ ```powershell
57
+ $env:GEMINI_SANDBOX="true"
58
+ gemini -p "run the test suite"
59
+ ```
60
+
61
+ ### Configuring via settings.json
62
+
63
+ ```json
64
+ {
65
+ "tools": {
66
+ "sandbox": "docker"
67
+ }
68
+ }
69
+ ```
70
+
71
+ ## Configuration
72
+
73
+ Enable sandboxing using one of the following methods (in order of precedence):
74
+
75
+ 1. **Command flag**: `-s` or `--sandbox`
76
+ 2. **Environment variable**:
77
+ `GEMINI_SANDBOX=true|docker|podman|sandbox-exec|runsc|lxc`
78
+ 3. **Settings file**: `"sandbox": true` in the `tools` object of your
79
+ `settings.json` file (for example, `{"tools": {"sandbox": true}}`).
80
+
81
+ ## Sandboxing methods
82
+
83
+ Your ideal method of sandboxing may differ depending on your platform and your
84
+ preferred container solution.
85
+
86
+ ### 1. macOS Seatbelt (macOS only)
87
+
88
+ Lightweight, built-in sandboxing using `sandbox-exec`.
89
+
90
+ **Default profile**: `permissive-open` - denies operations by default; confines
91
+ writes to the project directory while allowing broad file reads and network
92
+ access.
93
+
94
+ Built-in profiles (set via `SEATBELT_PROFILE` env var):
95
+
96
+ - `permissive-open` (default): Write restrictions, network allowed
97
+ - `permissive-proxied`: Write restrictions, network via proxy
98
+ - `restrictive-open`: Strict restrictions, network allowed
99
+ - `restrictive-proxied`: Strict restrictions, network via proxy
100
+ - `strict-open`: Read and write restrictions, network allowed
101
+ - `strict-proxied`: Read and write restrictions, network via proxy
102
+
103
+ ### 2. Container-based (Docker/Podman)
104
+
105
+ Cross-platform sandboxing with complete process isolation using container
106
+ technology. By default, it uses the `ghcr.io/google/gemini-cli:latest` image.
107
+
108
+ **Prerequisites:**
109
+
110
+ - Docker or Podman must be installed and running on your system.
111
+
112
+ **How it works (Workspace directory):**
113
+
114
+ Inside the sandbox container, your current working directory is mounted at the
115
+ **exact same absolute path** as it is on your host machine. For example, if you
116
+ run the CLI from `/Users/you/project` on your host machine, the sandbox will
117
+ mount your local project folder and operate within `/Users/you/project` inside
118
+ the container. This allows the AI to seamlessly read and modify your project
119
+ files while remaining isolated from the rest of your system.
120
+
121
+ **Quick setup:**
122
+
123
+ To enable Docker sandboxing, run Gemini CLI with the sandbox flag and specify
124
+ Docker as the provider:
125
+
126
+ ```bash
127
+ # Using the environment variable (Recommended)
128
+ export GEMINI_SANDBOX=docker
129
+ gemini -p "build the project"
130
+
131
+ # Or configure it permanently in your settings.json
132
+ # {"tools": {"sandbox": "docker"}}
133
+ ```
134
+
135
+ **Customizing the Sandbox Image:**
136
+
137
+ If your project requires specific dependencies, you can specify a custom image
138
+ name or have Gemini CLI build one for you automatically. You can use any Docker
139
+ or Podman image as your sandbox, provided it has standard shell utilities (like
140
+ `bash`) available.
141
+
142
+ **Option A: Using an existing custom image (e.g., Artifact Registry)**
143
+
144
+ To configure a custom image that is hosted on a registry (or built locally),
145
+ update your `settings.json` to use an object for the sandbox configuration, or
146
+ set the `GEMINI_SANDBOX_IMAGE` environment variable.
147
+
148
+ _Example: Configuring via `settings.json`_
149
+
150
+ ```json
151
+ {
152
+ "tools": {
153
+ "sandbox": {
154
+ "command": "docker",
155
+ "image": "us-central1-docker.pkg.dev/my-project/my-repo/my-custom-sandbox:latest"
156
+ }
157
+ }
158
+ }
159
+ ```
160
+
161
+ _Example: Configuring via environment variable_
162
+
163
+ ```bash
164
+ export GEMINI_SANDBOX_IMAGE="us-central1-docker.pkg.dev/my-project/my-repo/my-custom-sandbox:latest"
165
+ ```
166
+
167
+ **Option B: Building a local custom image automatically**
168
+
169
+ If you prefer to define your environment as code, you can provide a Dockerfile
170
+ and Gemini CLI will build the image automatically.
171
+
172
+ 1. Create a `.gemini/sandbox.Dockerfile` in your project root.
173
+ 2. Ensure you have the `gh` CLI installed and authenticated (if you are using
174
+ the default `ghcr.io/google/gemini-cli` image as a base).
175
+ 3. Run your command with the `BUILD_SANDBOX` environment variable set:
176
+
177
+ ```bash
178
+ BUILD_SANDBOX=1 GEMINI_SANDBOX=docker gemini -p "run my custom build"
179
+ ```
180
+
181
+ ### 3. Windows Native Sandbox (Windows only)
182
+
183
+ ... **Troubleshooting and Side Effects:**
184
+
185
+ The Windows Native sandbox uses the `icacls` command to set a "Low Mandatory
186
+ Level" on files and directories it needs to write to.
187
+
188
+ - **Persistence**: These integrity level changes are persistent on the
189
+ filesystem. Even after the sandbox session ends, files created or modified by
190
+ the sandbox will retain their "Low" integrity level.
191
+ - **Manual Reset**: If you need to reset the integrity level of a file or
192
+ directory, you can use:
193
+ ```powershell
194
+ icacls "C:\path\to\dir" /setintegritylevel Medium
195
+ ```
196
+ - **System Folders**: The sandbox manager automatically skips setting integrity
197
+ levels on system folders (like `C:\Windows`) for safety.
198
+
199
+ ### 4. gVisor / runsc (Linux only)
200
+
201
+ Strongest isolation available: runs containers inside a user-space kernel via
202
+ [gVisor](https://github.com/google/gvisor). gVisor intercepts all container
203
+ system calls and handles them in a sandboxed kernel written in Go, providing a
204
+ strong security barrier between AI operations and the host OS.
205
+
206
+ **Prerequisites:**
207
+
208
+ - Linux (gVisor supports Linux only)
209
+ - Docker installed and running
210
+ - gVisor/runsc runtime configured
211
+
212
+ When you set `sandbox: "runsc"`, Gemini CLI runs
213
+ `docker run --runtime=runsc ...` to execute containers with gVisor isolation.
214
+ runsc is not auto-detected; you must specify it explicitly (e.g.
215
+ `GEMINI_SANDBOX=runsc` or `sandbox: "runsc"`).
216
+
217
+ To set up runsc:
218
+
219
+ 1. Install the runsc binary.
220
+ 2. Configure the Docker daemon to use the runsc runtime.
221
+ 3. Verify the installation.
222
+
223
+ ### 5. LXC/LXD (Linux only, experimental)
224
+
225
+ Full-system container sandboxing using LXC/LXD. Unlike Docker/Podman, LXC
226
+ containers run a complete Linux system with `systemd`, `snapd`, and other system
227
+ services. This is ideal for tools that don't work in standard Docker containers,
228
+ such as Snapcraft and Rockcraft.
229
+
230
+ **Prerequisites**:
231
+
232
+ - Linux only.
233
+ - LXC/LXD must be installed (`snap install lxd` or `apt install lxd`).
234
+ - A container must be created and running before starting Gemini CLI. Gemini
235
+ does **not** create the container automatically.
236
+
237
+ **Quick setup**:
238
+
239
+ ```bash
240
+ # Initialize LXD (first time only)
241
+ lxd init --auto
242
+
243
+ # Create and start an Ubuntu container
244
+ lxc launch ubuntu:24.04 gemini-sandbox
245
+
246
+ # Enable LXC sandboxing
247
+ export GEMINI_SANDBOX=lxc
248
+ gemini -p "build the project"
249
+ ```
250
+
251
+ **Custom container name**:
252
+
253
+ ```bash
254
+ export GEMINI_SANDBOX=lxc
255
+ export GEMINI_SANDBOX_IMAGE=my-snapcraft-container
256
+ gemini -p "build the snap"
257
+ ```
258
+
259
+ **Limitations**:
260
+
261
+ - Linux only (LXC is not available on macOS or Windows).
262
+ - The container must already exist and be running.
263
+ - The workspace directory is bind-mounted into the container at the same
264
+ absolute path — the path must be writable inside the container.
265
+ - Used with tools like Snapcraft or Rockcraft that require a full system.
266
+
267
+ ## Tool sandboxing
268
+
269
+ Tool-level sandboxing provides granular isolation for individual tool executions
270
+ (like `shell_exec` and `write_file`) instead of sandboxing the entire Gemini CLI
271
+ process.
272
+
273
+ This approach offers better integration with your local environment for non-tool
274
+ tasks (like UI rendering and configuration loading) while still providing
275
+ security for tool-driven operations.
276
+
277
+ ### How to turn off tool sandboxing
278
+
279
+ If you experience issues with tool sandboxing or prefer full-process isolation,
280
+ you can disable it by setting `security.toolSandboxing` to `false` in your
281
+ `settings.json` file.
282
+
283
+ ```json
284
+ {
285
+ "security": {
286
+ "toolSandboxing": false
287
+ }
288
+ }
289
+ ```
290
+
291
+ <!-- prettier-ignore -->
292
+ > [!NOTE]
293
+ > Changing the `security.toolSandboxing` setting requires a restart of Gemini
294
+ > CLI to take effect.
295
+
296
+ ## Sandbox expansion
297
+
298
+ Sandbox expansion is a dynamic permission system that lets Gemini CLI request
299
+ additional permissions for a command when needed.
300
+
301
+ When a sandboxed command fails due to permission restrictions (like restricted
302
+ file paths or network access), or when a command is proactively identified as
303
+ requiring extra permissions (like `npm install`), Gemini CLI will present you
304
+ with a "Sandbox Expansion Request."
305
+
306
+ ### How sandbox expansion works
307
+
308
+ 1. **Detection**: Gemini CLI detects a sandbox denial or proactively identifies
309
+ a command that requires extra permissions.
310
+ 2. **Request**: A modal dialog is shown, explaining which additional
311
+ permissions (e.g., specific directories or network access) are required.
312
+ 3. **Approval**: If you approve the expansion, the command is executed with the
313
+ extended permissions for that specific run.
314
+
315
+ This mechanism ensures you don't have to manually re-run commands with more
316
+ permissive sandbox settings, while still maintaining control over what the AI
317
+ can access.
318
+
319
+ ### Including files outside the workspace
320
+
321
+ By default, the sandbox only has access to the current project workspace. If you
322
+ need the sandbox to have permission to operate on certain files or directories
323
+ from the local file system outside of the project workspace, you can mount them
324
+ using the `SANDBOX_MOUNTS` environment variable.
325
+
326
+ Provide a comma-separated list of mount definitions in the format
327
+ `from:to:opts`. If `to` is omitted, it defaults to the same path as `from`. If
328
+ `opts` is omitted, it defaults to `ro` (read-only). Note that the `from` path
329
+ must be an absolute path.
330
+
331
+ **Example**:
332
+
333
+ ```bash
334
+ export SANDBOX_MOUNTS="/path/on/host:/path/in/container:rw,/another/path:ro"
335
+ ```
336
+
337
+ ## Running inside a Docker container
338
+
339
+ If you are running Gemini CLI itself from within an official or custom Docker
340
+ container and want to enable sandboxing, you must share the host's Docker socket
341
+ and ensure your workspace paths align.
342
+
343
+ 1. **Mount the Docker socket**: Map `/var/run/docker.sock` so the CLI can spawn
344
+ sibling sandbox containers via the host's Docker daemon.
345
+ 2. **Align workspace paths**: The path to your workspace inside the container
346
+ must exactly match the absolute path on the host. Because the sandbox
347
+ container is spawned by the host's Docker daemon, it resolves volume mounts
348
+ against the host file system.
349
+
350
+ **Example**:
351
+
352
+ ```bash
353
+ docker run -it \
354
+ -v /var/run/docker.sock:/var/run/docker.sock \
355
+ -v /absolute/path/on/host/project:/absolute/path/on/host/project \
356
+ -w /absolute/path/on/host/project \
357
+ -e GEMINI_SANDBOX=docker \
358
+ ghcr.io/google/gemini-cli:latest
359
+ ```
360
+
361
+ ## Advanced settings
362
+
363
+ ### Custom sandbox flags
364
+
365
+ For container-based sandboxing, you can inject custom flags into the `docker` or
366
+ `podman` command using the `SANDBOX_FLAGS` environment variable. This is useful
367
+ for advanced configurations, such as disabling security features for specific
368
+ use cases.
369
+
370
+ **Example (Podman)**:
371
+
372
+ To disable SELinux labeling for volume mounts, you can set the following:
373
+
374
+ **macOS/Linux**
375
+
376
+ ```bash
377
+ export SANDBOX_FLAGS="--security-opt label=disable"
378
+ ```
379
+
380
+ **Windows (PowerShell)**
381
+
382
+ ```powershell
383
+ $env:SANDBOX_FLAGS="--security-opt label=disable"
384
+ ```
385
+
386
+ Multiple flags can be provided as a space-separated string:
387
+
388
+ **macOS/Linux**
389
+
390
+ ```bash
391
+ export SANDBOX_FLAGS="--flag1 --flag2=value"
392
+ ```
393
+
394
+ **Windows (PowerShell)**
395
+
396
+ ```powershell
397
+ $env:SANDBOX_FLAGS="--flag1 --flag2=value"
398
+ ```
399
+
400
+ ### Linux UID/GID handling
401
+
402
+ The sandbox automatically handles user permissions on Linux. Override these
403
+ permissions with:
404
+
405
+ **macOS/Linux**
406
+
407
+ ```bash
408
+ export SANDBOX_SET_UID_GID=true # Force host UID/GID
409
+ export SANDBOX_SET_UID_GID=false # Disable UID/GID mapping
410
+ ```
411
+
412
+ **Windows (PowerShell)**
413
+
414
+ ```powershell
415
+ $env:SANDBOX_SET_UID_GID="true" # Force host UID/GID
416
+ $env:SANDBOX_SET_UID_GID="false" # Disable UID/GID mapping
417
+ ```
418
+
419
+ ## Troubleshooting
420
+
421
+ ### Common issues
422
+
423
+ **"Operation not permitted"**
424
+
425
+ - Operation requires access outside sandbox.
426
+ - Try more permissive profile or add mount points.
427
+
428
+ **Missing commands**
429
+
430
+ - Add to a custom Dockerfile. Automatic `BUILD_SANDBOX` builds are only
431
+ available when running Gemini CLI from source; npm installs need a prebuilt
432
+ image instead.
433
+ - Install via `sandbox.bashrc`.
434
+
435
+ **Network issues**
436
+
437
+ - Check sandbox profile allows network.
438
+ - Verify proxy configuration.
439
+
440
+ ### Debug mode
441
+
442
+ ```bash
443
+ DEBUG=1 gemini -s -p "debug command"
444
+ ```
445
+
446
+ <!-- prettier-ignore -->
447
+ > [!NOTE]
448
+ > If you have `DEBUG=true` in a project's `.env` file, it won't affect
449
+ > gemini-cli due to automatic exclusion. Use `.gemini/.env` files for
450
+ > gemini-cli specific debug settings.
451
+
452
+ ### Inspect sandbox
453
+
454
+ ```bash
455
+ # Check environment
456
+ gemini -s -p "run shell command: env | grep SANDBOX"
457
+
458
+ # List mounts
459
+ gemini -s -p "run shell command: mount | grep workspace"
460
+ ```
461
+
462
+ ## Security notes
463
+
464
+ - Sandboxing reduces but doesn't eliminate all risks.
465
+ - Use the most restrictive profile that allows your work.
466
+ - Container overhead is minimal after first build.
467
+ - GUI applications may not work in sandboxes.
468
+
469
+ ## Related documentation
470
+
471
+ - [Configuration](../reference/configuration.md): Full configuration options.
472
+ - [Commands](../reference/commands.md): Available commands.
473
+ - [Troubleshooting](../resources/troubleshooting.md): General troubleshooting.
docs/cli/session-management.md ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Session management
2
+
3
+ Session management saves your conversation history so you can resume your work
4
+ where you left off. Use these features to review past interactions, manage
5
+ history across different projects, and configure how long data is retained.
6
+
7
+ ## Automatic saving
8
+
9
+ Your session history is recorded automatically as you interact with the model.
10
+ This background process ensures your work is preserved even if you interrupt a
11
+ session.
12
+
13
+ - **What is saved:** The complete conversation history, including:
14
+ - Your prompts and the model's responses.
15
+ - All tool executions (inputs and outputs).
16
+ - Token usage statistics (input, output, cached, etc.).
17
+ - Assistant thoughts and reasoning summaries (when available).
18
+ - **Location:** Sessions are stored in `~/.gemini/tmp/<project_hash>/chats/`,
19
+ where `<project_hash>` is a unique identifier based on your project's root
20
+ directory.
21
+ - **Scope:** Sessions are project-specific. Switching directories to a different
22
+ project switches to that project's session history.
23
+
24
+ ## Resuming sessions
25
+
26
+ You can resume a previous session to continue the conversation with all prior
27
+ context restored. Resuming is supported both through command-line flags and an
28
+ interactive browser.
29
+
30
+ ### From the command line
31
+
32
+ When starting Gemini CLI, use the `--resume` (or `-r`) flag to load existing
33
+ sessions.
34
+
35
+ - **Resume latest:**
36
+
37
+ ```bash
38
+ gemini --resume
39
+ ```
40
+
41
+ This immediately loads the most recent session.
42
+
43
+ - **Resume by index:** List available sessions first (see
44
+ [Listing sessions](#listing-sessions)), then use the index number:
45
+
46
+ ```bash
47
+ gemini --resume 1
48
+ ```
49
+
50
+ - **Resume by ID:** You can also provide the full session UUID:
51
+ ```bash
52
+ gemini --resume a1b2c3d4-e5f6-7890-abcd-ef1234567890
53
+ ```
54
+
55
+ ### From the interactive interface
56
+
57
+ While the CLI is running, use the `/resume` slash command to open the **Session
58
+ Browser**:
59
+
60
+ ```text
61
+ /resume
62
+ ```
63
+
64
+ When typing `/resume` (or `/chat`) in slash completion, commands are grouped
65
+ under titled separators:
66
+
67
+ - `-- auto --` (session browser)
68
+ - `list` is selectable and opens the session browser
69
+ - `-- checkpoints --` (manual tagged checkpoint commands)
70
+
71
+ Unique prefixes such as `/resum` and `/cha` resolve to the same grouped menu.
72
+
73
+ The Session Browser provides an interactive interface where you can perform the
74
+ following actions:
75
+
76
+ - **Browse:** Scroll through a list of your past sessions.
77
+ - **Preview:** See details like the session date, message count, and the first
78
+ user prompt.
79
+ - **Search:** Press `/` to enter search mode, then type to filter sessions by ID
80
+ or content.
81
+ - **Select:** Press **Enter** to resume the selected session.
82
+ - **Esc:** Press **Esc** to exit the Session Browser.
83
+
84
+ ### Manual chat checkpoints
85
+
86
+ For named branch points inside a session, use chat checkpoints:
87
+
88
+ ```text
89
+ /resume save decision-point
90
+ /resume list
91
+ /resume resume decision-point
92
+ ```
93
+
94
+ Compatibility aliases:
95
+
96
+ - `/chat ...` works for the same commands.
97
+ - `/resume checkpoints ...` also remains supported during migration.
98
+
99
+ ## Parallel sessions with Git worktrees
100
+
101
+ When working on multiple tasks at once, you can use
102
+ [Git worktrees](./git-worktrees.md) to give each Gemini session its own copy of
103
+ the codebase. This prevents changes in one session from colliding with another.
104
+
105
+ ## Managing sessions
106
+
107
+ You can list and delete sessions to keep your history organized and manage disk
108
+ space.
109
+
110
+ ### Listing sessions
111
+
112
+ To see a list of all available sessions for the current project from the command
113
+ line, use the `--list-sessions` flag:
114
+
115
+ ```bash
116
+ gemini --list-sessions
117
+ ```
118
+
119
+ Output example:
120
+
121
+ ```text
122
+ Available sessions for this project (3):
123
+
124
+ 1. Fix bug in auth (2 days ago) [a1b2c3d4]
125
+ 2. Refactor database schema (5 hours ago) [e5f67890]
126
+ 3. Update documentation (Just now) [abcd1234]
127
+ ```
128
+
129
+ ### Deleting sessions
130
+
131
+ You can remove old or unwanted sessions to free up space or declutter your
132
+ history.
133
+
134
+ **From the command line:** Use the `--delete-session` flag with an index or ID:
135
+
136
+ ```bash
137
+ gemini --delete-session 2
138
+ ```
139
+
140
+ **From the Session Browser:**
141
+
142
+ 1. Open the browser with `/resume`.
143
+ 2. Navigate to the session you want to remove.
144
+ 3. Press **x**.
145
+
146
+ ## Configuration
147
+
148
+ You can configure how Gemini CLI manages your session history in your
149
+ `settings.json` file. These settings let you control retention policies and
150
+ session lengths.
151
+
152
+ ### Session retention
153
+
154
+ By default, Gemini CLI automatically cleans up old session data to prevent your
155
+ history from growing indefinitely. When a session is deleted, Gemini CLI also
156
+ removes all associated data, including implementation plans, task trackers, tool
157
+ outputs, and activity logs.
158
+
159
+ The default policy is to **retain sessions for 30 days**.
160
+
161
+ #### Configuration
162
+
163
+ You can customize these policies using the `/settings` command or by manually
164
+ editing your `settings.json` file:
165
+
166
+ ```json
167
+ {
168
+ "general": {
169
+ "sessionRetention": {
170
+ "enabled": true,
171
+ "maxAge": "30d",
172
+ "maxCount": 50
173
+ }
174
+ }
175
+ }
176
+ ```
177
+
178
+ - **`enabled`**: (boolean) Master switch for session cleanup. Defaults to
179
+ `true`.
180
+ - **`maxAge`**: (string) Duration to keep sessions (for example, "24h", "7d",
181
+ "4w"). Sessions older than this are deleted. Defaults to `"30d"`.
182
+ - **`maxCount`**: (number) Maximum number of sessions to retain. The oldest
183
+ sessions exceeding this count are deleted. Defaults to undefined (unlimited).
184
+ - **`minRetention`**: (string) Minimum retention period (safety limit). Defaults
185
+ to `"1d"`. Sessions newer than this period are never deleted by automatic
186
+ cleanup.
187
+
188
+ ### Session limits
189
+
190
+ You can limit the length of individual sessions to prevent context windows from
191
+ becoming too large and expensive.
192
+
193
+ ```json
194
+ {
195
+ "model": {
196
+ "maxSessionTurns": 100
197
+ }
198
+ }
199
+ ```
200
+
201
+ - **`maxSessionTurns`**: (number) The maximum number of turns (user and model
202
+ exchanges) allowed in a single session. Set to `-1` for unlimited (default).
203
+
204
+ **Behavior when limit is reached:**
205
+
206
+ - **Interactive mode:** The CLI shows an informational message and stops
207
+ sending requests to the model. You must manually start a new session.
208
+ - **Non-interactive mode:** The CLI exits with an error.
209
+
210
+ ## Next steps
211
+
212
+ - Explore the [Memory tool](../tools/memory.md) to save persistent information
213
+ across sessions.
214
+ - Learn how to [Checkpoint](./checkpointing.md) your session state.
215
+ - Check out the [CLI reference](./cli-reference.md) for all command-line flags.
docs/cli/settings.md ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Gemini CLI settings (`/settings` command)
2
+
3
+ Control your Gemini CLI experience with the `/settings` command. The `/settings`
4
+ command opens a dialog to view and edit all your Gemini CLI settings, including
5
+ your UI experience, keybindings, and accessibility features.
6
+
7
+ Your Gemini CLI settings are stored in a `settings.json` file. In addition to
8
+ using the `/settings` command, you can also edit them in one of the following
9
+ locations:
10
+
11
+ - **User settings**: `~/.gemini/settings.json`
12
+ - **Workspace settings**: `your-project/.gemini/settings.json`
13
+
14
+ <!-- prettier-ignore -->
15
+ > [!IMPORTANT]
16
+ > Workspace settings override user settings.
17
+
18
+ ## Settings reference
19
+
20
+ Here is a list of all the available settings, grouped by category and ordered as
21
+ they appear in the UI.
22
+
23
+ <!-- SETTINGS-AUTOGEN:START -->
24
+
25
+ ### General
26
+
27
+ | UI Label | Setting | Description | Default |
28
+ | ----------------------------- | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
29
+ | Vim Mode | `general.vimMode` | Enable Vim keybindings | `false` |
30
+ | Default Approval Mode | `general.defaultApprovalMode` | The default approval mode for tool execution. 'default' prompts for approval, 'auto_edit' auto-approves edit tools, and 'plan' is read-only mode. YOLO mode (auto-approve all actions) can only be enabled via command line (--yolo or --approval-mode=yolo). | `"default"` |
31
+ | Enable Auto Update | `general.enableAutoUpdate` | Enable automatic updates. | `true` |
32
+ | Enable Terminal Notifications | `general.enableNotifications` | Enable terminal run-event notifications for action-required prompts and session completion. | `false` |
33
+ | Terminal Notification Method | `general.notificationMethod` | How to send terminal notifications. | `"auto"` |
34
+ | Enable Plan Mode | `general.plan.enabled` | Enable Plan Mode for read-only safety during planning. | `true` |
35
+ | Plan Directory | `general.plan.directory` | The directory where planning artifacts are stored. If not specified, defaults to the system temporary directory. A custom directory requires a policy to allow write access in Plan Mode. | `undefined` |
36
+ | Plan Model Routing | `general.plan.modelRouting` | Automatically switch between Pro and Flash models based on Plan Mode status. Uses Pro for the planning phase and Flash for the implementation phase. | `true` |
37
+ | Retry Fetch Errors | `general.retryFetchErrors` | Retry on "exception TypeError: fetch failed sending request" errors. | `true` |
38
+ | Max Chat Model Attempts | `general.maxAttempts` | Maximum number of attempts for requests to the main chat model. Cannot exceed 10. | `10` |
39
+ | Debug Keystroke Logging | `general.debugKeystrokeLogging` | Enable debug logging of keystrokes to the console. | `false` |
40
+ | Enable Session Cleanup | `general.sessionRetention.enabled` | Enable automatic session cleanup | `true` |
41
+ | Keep chat history | `general.sessionRetention.maxAge` | Automatically delete chats older than this time period (e.g., "30d", "7d", "24h", "1w") | `"30d"` |
42
+ | Topic & Update Narration | `general.topicUpdateNarration` | Enable the Topic & Update communication model for reduced chattiness and structured progress reporting. | `true` |
43
+ | Log RAG Snippets | `general.logRagSnippets` | Log full Code Customization (RAG) retrieved snippets to a local file for debugging. | `false` |
44
+
45
+ ### Output
46
+
47
+ | UI Label | Setting | Description | Default |
48
+ | ------------- | --------------- | ------------------------------------------------------ | -------- |
49
+ | Output Format | `output.format` | The format of the CLI output. Can be `text` or `json`. | `"text"` |
50
+
51
+ ### UI
52
+
53
+ | UI Label | Setting | Description | Default |
54
+ | ------------------------------------ | -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
55
+ | Auto Theme Switching | `ui.autoThemeSwitching` | Automatically switch between default light and dark themes based on terminal background color. | `true` |
56
+ | Terminal Background Polling Interval | `ui.terminalBackgroundPollingInterval` | Interval in seconds to poll the terminal background color. | `60` |
57
+ | Hide Window Title | `ui.hideWindowTitle` | Hide the window title bar | `false` |
58
+ | Inline Thinking | `ui.inlineThinkingMode` | Display model thinking inline: off or full. | `"off"` |
59
+ | Show Thoughts in Title | `ui.showStatusInTitle` | Show Gemini CLI model thoughts in the terminal window title during the working phase | `false` |
60
+ | Dynamic Window Title | `ui.dynamicWindowTitle` | Update the terminal window title with current status icons (Ready: ◇, Action Required: ✋, Working: ✦) | `true` |
61
+ | Show Home Directory Warning | `ui.showHomeDirectoryWarning` | Show a warning when running Gemini CLI in the home directory. | `true` |
62
+ | Show Compatibility Warnings | `ui.showCompatibilityWarnings` | Show warnings about terminal or OS compatibility issues. | `true` |
63
+ | Hide Tips | `ui.hideTips` | Hide helpful tips in the UI | `false` |
64
+ | Escape Pasted @ Symbols | `ui.escapePastedAtSymbols` | When enabled, @ symbols in pasted text are escaped to prevent unintended @path expansion. | `false` |
65
+ | Show Shortcuts Hint | `ui.showShortcutsHint` | Show the "? for shortcuts" hint above the input. | `true` |
66
+ | Compact Tool Output | `ui.compactToolOutput` | Display tool outputs (like directory listings and file reads) in a compact, structured format. | `true` |
67
+ | Hide Banner | `ui.hideBanner` | Hide the application banner | `false` |
68
+ | Hide Context Summary | `ui.hideContextSummary` | Hide the context summary (GEMINI.md, MCP servers) above the input. | `false` |
69
+ | Hide CWD | `ui.footer.hideCWD` | Hide the current working directory in the footer. | `false` |
70
+ | Hide Sandbox Status | `ui.footer.hideSandboxStatus` | Hide the sandbox status indicator in the footer. | `false` |
71
+ | Hide Model Info | `ui.footer.hideModelInfo` | Hide the model name and context usage in the footer. | `false` |
72
+ | Hide Context Window Percentage | `ui.footer.hideContextPercentage` | Hides the context window usage percentage. | `true` |
73
+ | Hide Footer | `ui.hideFooter` | Hide the footer from the UI | `false` |
74
+ | Show Memory Usage | `ui.showMemoryUsage` | Display memory usage information in the UI | `false` |
75
+ | Show Line Numbers | `ui.showLineNumbers` | Show line numbers in the chat. | `true` |
76
+ | Show Citations | `ui.showCitations` | Show citations for generated text in the chat. | `false` |
77
+ | Show Model Info In Chat | `ui.showModelInfoInChat` | Show the model name in the chat for each model turn. | `false` |
78
+ | Show User Identity | `ui.showUserIdentity` | Show the signed-in user's identity (e.g. email) in the UI. | `true` |
79
+ | Use Alternate Screen Buffer | `ui.useAlternateBuffer` | Use an alternate screen buffer for the UI, preserving shell history. | `false` |
80
+ | Render Process | `ui.renderProcess` | Enable Ink render process for the UI. | `true` |
81
+ | Terminal Buffer | `ui.terminalBuffer` | Use the new terminal buffer architecture for rendering. | `false` |
82
+ | Use Background Color | `ui.useBackgroundColor` | Whether to use background colors in the UI. | `true` |
83
+ | Incremental Rendering | `ui.incrementalRendering` | Enable incremental rendering for the UI. This option will reduce flickering but may cause rendering artifacts. Only supported when useAlternateBuffer is enabled. | `true` |
84
+ | Show Spinner | `ui.showSpinner` | Show the spinner during operations. | `true` |
85
+ | Loading Phrases | `ui.loadingPhrases` | What to show while the model is working: tips, witty comments, all, or off. | `"off"` |
86
+ | Error Verbosity | `ui.errorVerbosity` | Controls whether recoverable errors are hidden (low) or fully shown (full). | `"low"` |
87
+ | Screen Reader Mode | `ui.accessibility.screenReader` | Render output in plain-text to be more screen reader accessible | `false` |
88
+
89
+ ### IDE
90
+
91
+ | UI Label | Setting | Description | Default |
92
+ | -------- | ------------- | ---------------------------- | ------- |
93
+ | IDE Mode | `ide.enabled` | Enable IDE integration mode. | `false` |
94
+
95
+ ### Billing
96
+
97
+ | UI Label | Setting | Description | Default |
98
+ | ---------------- | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
99
+ | Overage Strategy | `billing.overageStrategy` | How to handle quota exhaustion when AI credits are available. 'ask' prompts each time, 'always' automatically uses credits, 'never' disables credit usage. | `"ask"` |
100
+
101
+ ### Model
102
+
103
+ | UI Label | Setting | Description | Default |
104
+ | ----------------------------- | ---------------------------- | -------------------------------------------------------------------------------------- | ----------- |
105
+ | Model | `model.name` | The Gemini model to use for conversations. | `undefined` |
106
+ | Max Session Turns | `model.maxSessionTurns` | Maximum number of user/model/tool turns to keep in a session. -1 means unlimited. | `-1` |
107
+ | Context Compression Threshold | `model.compressionThreshold` | The fraction of context usage at which to trigger context compression (e.g. 0.2, 0.3). | `0.5` |
108
+ | Disable Loop Detection | `model.disableLoopDetection` | Disable automatic detection and prevention of infinite loops. | `false` |
109
+ | Skip Next Speaker Check | `model.skipNextSpeakerCheck` | Skip the next speaker check. | `true` |
110
+
111
+ ### Agents
112
+
113
+ | UI Label | Setting | Description | Default |
114
+ | ------------------------- | ---------------------------------------- | --------------------------------------------------------------------------------------------- | ------- |
115
+ | Confirm Sensitive Actions | `agents.browser.confirmSensitiveActions` | Require manual confirmation for sensitive browser actions (e.g., fill_form, evaluate_script). | `false` |
116
+ | Block File Uploads | `agents.browser.blockFileUploads` | Hard-block file upload requests from the browser agent. | `false` |
117
+
118
+ ### Context
119
+
120
+ | UI Label | Setting | Description | Default |
121
+ | ------------------------------------ | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
122
+ | Memory Discovery Max Dirs | `context.discoveryMaxDirs` | Maximum number of directories to search for memory. | `200` |
123
+ | Load Memory From Include Directories | `context.loadMemoryFromIncludeDirectories` | Controls how /memory reload loads GEMINI.md files. When true, include directories are scanned; when false, only the current directory is used. | `false` |
124
+ | Respect .gitignore | `context.fileFiltering.respectGitIgnore` | Respect .gitignore files when searching. | `true` |
125
+ | Respect .geminiignore | `context.fileFiltering.respectGeminiIgnore` | Respect .geminiignore files when searching. | `true` |
126
+ | Enable Recursive File Search | `context.fileFiltering.enableRecursiveFileSearch` | Enable recursive file search functionality when completing @ references in the prompt. | `true` |
127
+ | Enable Fuzzy Search | `context.fileFiltering.enableFuzzySearch` | Enable fuzzy search when searching for files. | `true` |
128
+ | Custom Ignore File Paths | `context.fileFiltering.customIgnoreFilePaths` | Additional ignore file paths to respect. These files take precedence over .geminiignore and .gitignore. Files earlier in the array take precedence over files later in the array, e.g. the first file takes precedence over the second one. | `[]` |
129
+
130
+ ### Tools
131
+
132
+ | UI Label | Setting | Description | Default |
133
+ | -------------------------------- | ------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
134
+ | Sandbox Allowed Paths | `tools.sandboxAllowedPaths` | List of additional paths that the sandbox is allowed to access. | `[]` |
135
+ | Sandbox Network Access | `tools.sandboxNetworkAccess` | Whether the sandbox is allowed to access the network. | `false` |
136
+ | Enable Interactive Shell | `tools.shell.enableInteractiveShell` | Use node-pty for an interactive shell experience. Fallback to child_process still applies. | `true` |
137
+ | Show Color | `tools.shell.showColor` | Show color in shell output. | `true` |
138
+ | Use Ripgrep | `tools.useRipgrep` | Use ripgrep for file content search instead of the fallback implementation. Provides faster search performance. | `true` |
139
+ | Tool Output Truncation Threshold | `tools.truncateToolOutputThreshold` | Maximum characters to show when truncating large tool outputs. Set to 0 or negative to disable truncation. | `40000` |
140
+ | Disable LLM Correction | `tools.disableLLMCorrection` | Disable LLM-based error correction for edit tools. When enabled, tools will fail immediately if exact string matches are not found, instead of attempting to self-correct. | `true` |
141
+
142
+ ### Security
143
+
144
+ | UI Label | Setting | Description | Default |
145
+ | ------------------------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------- |
146
+ | Tool Sandboxing | `security.toolSandboxing` | Tool-level sandboxing. Isolates individual tools instead of the entire CLI process. | `false` |
147
+ | Disable YOLO Mode | `security.disableYoloMode` | Disable YOLO mode, even if enabled by a flag. | `false` |
148
+ | Disable Always Allow | `security.disableAlwaysAllow` | Disable "Always allow" options in tool confirmation dialogs. | `false` |
149
+ | Allow Permanent Tool Approval | `security.enablePermanentToolApproval` | Enable the "Allow for all future sessions" option in tool confirmation dialogs. | `false` |
150
+ | Auto-add to Policy by Default | `security.autoAddToPolicyByDefault` | When enabled, the "Allow for all future sessions" option becomes the default choice for low-risk tools in trusted workspaces. | `false` |
151
+ | Blocks extensions from Git | `security.blockGitExtensions` | Blocks installing and loading extensions from Git. | `false` |
152
+ | Extension Source Regex Allowlist | `security.allowedExtensions` | List of Regex patterns for allowed extensions. If nonempty, only extensions that match the patterns in this list are allowed. Overrides the blockGitExtensions setting. | `[]` |
153
+ | Folder Trust | `security.folderTrust.enabled` | Setting to track whether Folder trust is enabled. | `true` |
154
+ | Enable Environment Variable Redaction | `security.environmentVariableRedaction.enabled` | Enable redaction of environment variables that may contain secrets. | `false` |
155
+ | Enable Context-Aware Security | `security.enableConseca` | Enable the context-aware security checker. This feature uses an LLM to dynamically generate and enforce security policies for tool use based on your prompt, providing an additional layer of protection against unintended actions. | `false` |
156
+
157
+ ### Advanced
158
+
159
+ | UI Label | Setting | Description | Default |
160
+ | --------------------------------- | ------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
161
+ | Auto Configure Max Old Space Size | `advanced.autoConfigureMemory` | Automatically configure Node.js memory limits. Note: Because memory is allocated during the initial process boot, this setting is only read from the global user settings file and ignores workspace-level overrides. | `true` |
162
+ | Ignore Local .env | `advanced.ignoreLocalEnv` | Whether to ignore generic .env files in the project directory. | `false` |
163
+
164
+ ### Experimental
165
+
166
+ | UI Label | Setting | Description | Default |
167
+ | ---------------------------------------------------- | ----------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- |
168
+ | Gemma Models | `experimental.gemma` | Enable access to Gemma 4 models via Gemini API. | `true` |
169
+ | Voice Mode | `experimental.voiceMode` | Enable experimental voice dictation and commands (/voice, /voice model). | `false` |
170
+ | Voice Activation Mode | `experimental.voice.activationMode` | How to trigger voice recording with the Space key. | `"push-to-talk"` |
171
+ | Voice Transcription Backend | `experimental.voice.backend` | The backend to use for voice transcription. Note: When using the Gemini Live backend, voice recordings are sent to Google Cloud for transcription. | `"gemini-live"` |
172
+ | Whisper Model | `experimental.voice.whisperModel` | The Whisper model to use for local transcription. | `"ggml-base.en.bin"` |
173
+ | Voice Stop Grace Period (ms) | `experimental.voice.stopGracePeriodMs` | How long to wait for final transcription after stopping recording. | `4000` |
174
+ | Enable Git Worktrees | `experimental.worktrees` | Enable automated Git worktree management for parallel work. | `false` |
175
+ | Use OSC 52 Paste | `experimental.useOSC52Paste` | Use OSC 52 for pasting. This may be more robust than the default system when using remote terminal sessions (if your terminal is configured to allow it). | `false` |
176
+ | Use OSC 52 Copy | `experimental.useOSC52Copy` | Use OSC 52 for copying. This may be more robust than the default system when using remote terminal sessions (if your terminal is configured to allow it). | `false` |
177
+ | Model Steering | `experimental.modelSteering` | Enable model steering (user hints) to guide the model during tool execution. | `false` |
178
+ | Direct Web Fetch | `experimental.directWebFetch` | Enable web fetch behavior that bypasses LLM summarization. | `false` |
179
+ | Enable Gemma Model Router | `experimental.gemmaModelRouter.enabled` | Enable the Gemma Model Router (experimental). Requires a local endpoint serving Gemma via the Gemini API using LiteRT-LM shim. | `false` |
180
+ | Auto-start LiteRT Server | `experimental.gemmaModelRouter.autoStartServer` | Automatically start the LiteRT-LM server when Gemini CLI starts and the Gemma router is enabled. | `false` |
181
+ | Auto Memory | `experimental.autoMemory` | Automatically extract memory patches and skills from past sessions in the background. Every change is written as a unified diff `.patch` file under `<projectMemoryDir>/.inbox/<kind>/` and held for review in /memory inbox; nothing is applied until you approve it. | `false` |
182
+ | Use the generalist profile to manage agent contexts. | `experimental.generalistProfile` | Suitable for general coding and software development tasks. | `false` |
183
+ | Enable Context Management | `experimental.contextManagement` | Enable logic for context management. | `false` |
184
+
185
+ ### Skills
186
+
187
+ | UI Label | Setting | Description | Default |
188
+ | ------------------- | ---------------- | -------------------- | ------- |
189
+ | Enable Agent Skills | `skills.enabled` | Enable Agent Skills. | `true` |
190
+
191
+ ### HooksConfig
192
+
193
+ | UI Label | Setting | Description | Default |
194
+ | ------------------ | --------------------------- | -------------------------------------------------------------------------------- | ------- |
195
+ | Enable Hooks | `hooksConfig.enabled` | Canonical toggle for the hooks system. When disabled, no hooks will be executed. | `true` |
196
+ | Hook Notifications | `hooksConfig.notifications` | Show visual indicators when hooks are executing. | `true` |
197
+
198
+ <!-- SETTINGS-AUTOGEN:END -->
docs/cli/skills-best-practices.md ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Agent Skill best practices
2
+
3
+ Create high-quality, reliable Agent Skills by following these established design
4
+ principles and patterns.
5
+
6
+ ## Design for discovery
7
+
8
+ The most important part of a skill is its `description`. This is the only
9
+ information the model has before activation.
10
+
11
+ - **Be specific**: Use keywords that are likely to appear in user prompts (for
12
+ example, "audit," "security," "refactor," "migration").
13
+ - **Define the trigger**: Clearly state _when_ the skill should be used (for
14
+ example, "Use this skill when the user asks to review a PR for performance
15
+ regressions").
16
+ - **Avoid overlap**: Ensure your skill descriptions are distinct from one
17
+ another and from the general capabilities of the model.
18
+
19
+ ## Progressive disclosure
20
+
21
+ The "context window" is a shared resource. Use a three-level loading system to
22
+ manage context efficiently.
23
+
24
+ 1. **Metadata (name + description)**: Always in context (~100 words).
25
+ 2. **`SKILL.md` body**: Loaded only after the skill triggers (<5k words).
26
+ 3. **Bundled resources**: Loaded only as needed by the model.
27
+
28
+ **Best practice**: Keep the `SKILL.md` body focused on core procedural
29
+ instructions. Move detailed reference material, schemas, and examples into
30
+ separate files in a `references/` directory.
31
+
32
+ ## Degrees of freedom
33
+
34
+ Match the level of instruction specificity to the task's fragility.
35
+
36
+ - **High freedom (text-based instructions)**: Use when multiple approaches are
37
+ valid or decisions depend heavily on context.
38
+ - **Medium freedom (pseudocode or scripts with parameters)**: Use when a
39
+ preferred pattern exists but some variation is acceptable.
40
+ - **Low freedom (specific scripts, few parameters)**: Use when operations are
41
+ fragile and error-prone, or a specific sequence MUST be followed.
42
+
43
+ ## Bundle resources effectively
44
+
45
+ Leverage the skill's ability to include scripts and assets to extend the agent's
46
+ capabilities.
47
+
48
+ - **Use scripts for deterministic tasks**: If a task can be automated with a
49
+ script (for example, running a linter, fetching data from an API), bundle it
50
+ in the `scripts/` folder.
51
+ - **Agentic ergonomics**: Ensure scripts output LLM-friendly stdout. Suppress
52
+ verbose tracebacks and provide clear, concise success/failure messages.
53
+ - **Provide templates**: Include common file headers or boilerplate code in the
54
+ `assets/` folder to ensure the agent produces consistent output.
55
+
56
+ ## Anatomy of a great skill
57
+
58
+ A well-structured skill directory organizes its resources into specialized
59
+ sub-folders.
60
+
61
+ ```text
62
+ my-skill/
63
+ ├── SKILL.md (Required) Core instructions and metadata
64
+ ├── scripts/ (Optional) Executable logic (Node.js, Python, etc.)
65
+ ├── references/ (Optional) Documentation to be loaded as needed
66
+ └── assets/ (Optional) Templates and non-executable resources
67
+ ```
68
+
69
+ ## Security and privacy
70
+
71
+ Design your skills with security in mind to protect your workspace and data.
72
+
73
+ - **Avoid hardcoded secrets**: Never include API keys or passwords in your
74
+ skill's scripts or documentation.
75
+ - **Review third-party skills**: Inspect the `SKILL.md` and scripts of any skill
76
+ before installing it from an untrusted source.
77
+ - **Limit scope**: Design skills to be as focused as possible to minimize the
78
+ potential impact of errors.
docs/cli/skills.md ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Agent Skills
2
+
3
+ Agent Skills let you extend Gemini CLI with specialized expertise, procedural
4
+ workflows, and task-specific resources. Based on the
5
+ [Agent Skills](https://agentskills.io) open standard, a "skill" is a
6
+ self-contained directory that packages instructions and assets into a
7
+ discoverable capability.
8
+
9
+ Unlike general context files ([GEMINI.md](./gemini-md.md)), which provide
10
+ persistent workspace-wide background, Skills represent **on-demand expertise**.
11
+ This lets Gemini CLI maintain a vast library of specialized capabilities—such as
12
+ security auditing, cloud deployments, or codebase migrations—without cluttering
13
+ the model's immediate context window.
14
+
15
+ ## How it works
16
+
17
+ The lifecycle of an Agent Skill involves discovery, activation, and conditional
18
+ resource access.
19
+
20
+ 1. **Discovery**: At the start of a session, Gemini CLI scans the discovery
21
+ tiers and injects the name and description of all enabled skills into the
22
+ system prompt.
23
+ 2. **Activation**: When Gemini identifies a task matching a skill's
24
+ description, it calls the `activate_skill` tool.
25
+ 3. **Consent**: You will see a confirmation prompt in the UI detailing the
26
+ skill's name, purpose, and the directory path it will gain access to.
27
+ 4. **Injection**: Upon your approval:
28
+ - The `SKILL.md` body and folder structure is added to the conversation
29
+ history.
30
+ - The skill's directory is added to the agent's allowed file paths, granting
31
+ it permission to read any bundled assets.
32
+ 5. **Execution**: The model proceeds with the specialized expertise active. It
33
+ is instructed to prioritize the skill's procedural guidance within reason.
34
+
35
+ ## Discovery tiers
36
+
37
+ Gemini CLI discovers skills from several locations, following a specific order
38
+ of precedence (lowest to highest):
39
+
40
+ 1. **Built-in skills**: Standard skills included with Gemini CLI that provide
41
+ foundational capabilities.
42
+ 2. **Extension skills**: Skills bundled within installed
43
+ [extensions](../extensions/index.md).
44
+ 3. **User skills**: Located in `~/.gemini/skills/` or the `~/.agents/skills/`
45
+ alias.
46
+ 4. **Workspace skills**: Located in `.gemini/skills/` or the `.agents/skills/`
47
+ alias. Workspace skills are shared with your team via version control.
48
+
49
+ ### Precedence and aliases
50
+
51
+ If multiple skills share the same name, the version from the higher-precedence
52
+ location is used. Within the same tier (user or workspace), the
53
+ `.agents/skills/` alias takes precedence over the `.gemini/skills/` directory.
54
+
55
+ The `.agents/skills/` alias provides an interoperable path for managing
56
+ agent-specific expertise that remains compatible across different AI tools.
57
+
58
+ ## Key benefits
59
+
60
+ Agent Skills provide several advantages for managing specialized knowledge and
61
+ complex workflows.
62
+
63
+ - **Shared expertise**: Package complex workflows (like a specific team's PR
64
+ review process) into a folder that anyone can use.
65
+ - **Repeatable workflows**: Ensure complex multi-step tasks are performed
66
+ consistently by providing a procedural framework.
67
+ - **Resource bundling**: Include scripts, templates, or example data alongside
68
+ instructions so the agent has everything it needs.
69
+ - **Progressive disclosure**: Only skill metadata (name and description) is
70
+ loaded initially. Detailed instructions and resources are only disclosed when
71
+ the model explicitly activates the skill, saving context tokens.
72
+
73
+ <!-- prettier-ignore -->
74
+ > [!NOTE]
75
+ > `/skills disable` and `/skills enable` default to the `user` scope. Use
76
+ > `--scope workspace` to manage workspace-specific settings.
77
+
78
+ To see all available skills in your current session, use the `/skills list`
79
+ command.
80
+
81
+ ## Managing skills
82
+
83
+ You can manage Agent Skills through interactive session commands or directly
84
+ from your terminal.
85
+
86
+ ### In an interactive session
87
+
88
+ Use the `/skills` slash command to view and manage available expertise:
89
+
90
+ - `/skills list [all] [nodesc]`: Shows discovered skills. Use `all` to include
91
+ built-in skills and `nodesc` to hide descriptions.
92
+ - `/skills link <path> [--scope user|workspace]`: Links skills from a local
93
+ directory.
94
+ - `/skills disable <name>`: Prevents a specific skill from being used.
95
+ - `/skills enable <name>`: Re-enables a disabled skill.
96
+ - `/skills reload` (or `/skills refresh`): Refreshes the list of discovered
97
+ skills from all tiers.
98
+
99
+ ### From the terminal
100
+
101
+ The `gemini skills` command provides management utilities:
102
+
103
+ ```bash
104
+ # List all discovered skills. Use --all to include built-in skills.
105
+ gemini skills list --all
106
+
107
+ # Install a skill from a Git repository or local directory.
108
+ # Use --consent to skip the security confirmation prompt.
109
+ gemini skills install https://github.com/user/repo.git --consent
110
+
111
+ # Uninstall a skill.
112
+ gemini skills uninstall my-skill --scope workspace
113
+ ```
114
+
115
+ #### Command options
116
+
117
+ The skill management commands support several global and command-specific
118
+ options.
119
+
120
+ - `--scope`: Either `user` (global, default) or `workspace` (local to the
121
+ project).
122
+ - `--path`: The sub-directory within a Git repository containing the skill.
123
+ - `--consent`: Acknowledge security risks and skip the interactive confirmation
124
+ during installation.
125
+
126
+ For more details on CLI commands, see the
127
+ [CLI reference](./cli-reference.md#skills-management).
128
+
129
+ ## Next steps
130
+
131
+ Explore these resources to refine your skills and understand the framework
132
+ better.
133
+
134
+ - [Get started with Agent Skills](./tutorials/skills-getting-started.md): A
135
+ quick walkthrough of triggering and using skills.
136
+ - [Creating Agent Skills](./creating-skills.md): Create your first skill and
137
+ bundle custom logic.
138
+ - [Using Agent Skills](./using-agent-skills.md): Learn how to leverage built-in
139
+ and custom skills.
140
+ - [Best practices](./skills-best-practices.md): Learn strategies for building
141
+ effective skills.
docs/cli/system-prompt.md ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # System Prompt Override (GEMINI_SYSTEM_MD)
2
+
3
+ The core system instructions that guide Gemini CLI can be completely replaced
4
+ with your own Markdown file. This feature is controlled via the
5
+ `GEMINI_SYSTEM_MD` environment variable.
6
+
7
+ ## Overview
8
+
9
+ The `GEMINI_SYSTEM_MD` variable instructs the CLI to use an external Markdown
10
+ file for its system prompt, completely overriding the built-in default. This is
11
+ a full replacement, not a merge. If you use a custom file, none of the original
12
+ core instructions will apply unless you include them yourself.
13
+
14
+ This feature is intended for advanced users who need to enforce strict,
15
+ project-specific behavior or create a customized persona.
16
+
17
+ <!-- prettier-ignore -->
18
+ > [!TIP]
19
+ > You can export the current default system prompt to a file first, review
20
+ > it, and then selectively modify or replace it (see
21
+ > [“Export the default prompt”](#export-the-default-prompt-recommended)).
22
+
23
+ ## How to enable
24
+
25
+ You can set the environment variable temporarily in your shell, or persist it
26
+ via a `.gemini/.env` file. See
27
+ [Persisting Environment Variables](../get-started/authentication.mdx#persisting-environment-variables).
28
+
29
+ - Use the project default path (`.gemini/system.md`):
30
+
31
+ - `GEMINI_SYSTEM_MD=true` or `GEMINI_SYSTEM_MD=1`
32
+ - The CLI reads `./.gemini/system.md` (relative to your current project
33
+ directory).
34
+
35
+ - Use a custom file path:
36
+
37
+ - `GEMINI_SYSTEM_MD=/absolute/path/to/my-system.md`
38
+ - Relative paths are supported and resolved from the current working
39
+ directory.
40
+ - Tilde expansion is supported (for example, `~/my-system.md`).
41
+
42
+ - Disable the override (use built‑in prompt):
43
+ - `GEMINI_SYSTEM_MD=false` or `GEMINI_SYSTEM_MD=0` or unset the variable.
44
+
45
+ If the override is enabled but the target file does not exist, the CLI will
46
+ error with: `missing system prompt file '<path>'`.
47
+
48
+ ## Quick examples
49
+
50
+ - One‑off session using a project file:
51
+ - `GEMINI_SYSTEM_MD=1 gemini`
52
+ - Persist for a project using `.gemini/.env`:
53
+ - Create `.gemini/system.md`, then add to `.gemini/.env`:
54
+ - `GEMINI_SYSTEM_MD=1`
55
+ - Use a custom file under your home directory:
56
+ - `GEMINI_SYSTEM_MD=~/prompts/system.md gemini`
57
+
58
+ ## UI indicator
59
+
60
+ When `GEMINI_SYSTEM_MD` is active, the CLI shows a `|⌐■_■|` indicator in the UI
61
+ to signal custom system‑prompt mode.
62
+
63
+ ## Variable Substitution
64
+
65
+ When using a custom system prompt file, you can use the following variables to
66
+ dynamically include built-in content:
67
+
68
+ - `${AgentSkills}`: Injects a complete section (including header) of all
69
+ available agent skills.
70
+ - `${SubAgents}`: Injects a complete section (including header) of available
71
+ sub-agents.
72
+ - `${AvailableTools}`: Injects a bulleted list of all currently enabled tool
73
+ names.
74
+ - Tool Name Variables: Injects the actual name of a tool using the pattern:
75
+ `${toolName}_ToolName` (for example, `${write_file_ToolName}`,
76
+ `${run_shell_command_ToolName}`).
77
+
78
+ This pattern is generated dynamically for all available tools.
79
+
80
+ ### Example
81
+
82
+ ```markdown
83
+ # Custom System Prompt
84
+
85
+ You are a helpful assistant. ${AgentSkills}
86
+ ${SubAgents}
87
+
88
+ ## Tooling
89
+
90
+ The following tools are available to you: ${AvailableTools}
91
+
92
+ You can use ${write_file_ToolName} to save logs.
93
+ ```
94
+
95
+ ## Export the default prompt (recommended)
96
+
97
+ Before overriding, export the current default prompt so you can review required
98
+ safety and workflow rules.
99
+
100
+ - Write the built‑in prompt to the project default path:
101
+ - `GEMINI_WRITE_SYSTEM_MD=1 gemini`
102
+ - Or write to a custom path:
103
+ - `GEMINI_WRITE_SYSTEM_MD=~/prompts/DEFAULT_SYSTEM.md gemini`
104
+
105
+ This creates the file and writes the current built‑in system prompt to it.
106
+
107
+ ## Best practices: system.md vs GEMINI.md
108
+
109
+ - system.md (firmware):
110
+ - Non‑negotiable operational rules: safety, tool‑use protocols, approvals, and
111
+ mechanics that keep the CLI reliable.
112
+ - Stable across tasks and projects (or per project when needed).
113
+ - GEMINI.md (strategy):
114
+ - Persona, goals, methodologies, and project/domain context.
115
+ - Evolves per task; relies on system.md for safe execution.
116
+
117
+ Keep system.md minimal but complete for safety and tool operation. Keep
118
+ GEMINI.md focused on high‑level guidance and project specifics.
119
+
120
+ ## Troubleshooting
121
+
122
+ - Error: `missing system prompt file '…'`
123
+ - Ensure the referenced path exists and is readable.
124
+ - For `GEMINI_SYSTEM_MD=1|true`, create `./.gemini/system.md` in your project.
125
+ - Override not taking effect
126
+ - Confirm the variable is loaded (use `.gemini/.env` or export in your shell).
127
+ - Paths are resolved from the current working directory; try an absolute path.
128
+ - Restore defaults
129
+ - Unset `GEMINI_SYSTEM_MD` or set it to `0`/`false`.
docs/cli/telemetry.md ADDED
@@ -0,0 +1,1277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Observability with OpenTelemetry
2
+
3
+ Observability is the key to turning experimental AI into reliable software.
4
+ Gemini CLI provides built-in support for OpenTelemetry, transforming every agent
5
+ interaction into a rich stream of logs, metrics, and traces. This three-pillar
6
+ approach gives you the high-fidelity visibility needed to understand agent
7
+ behavior, optimize performance, and ensure reliability across your entire
8
+ workflow.
9
+
10
+ Whether you are debugging a complex tool interaction locally or monitoring
11
+ enterprise-wide usage in the cloud, Gemini CLI's observability system provides
12
+ the actionable intelligence needed to move from "black box" AI to predictable,
13
+ high-performance systems.
14
+
15
+ ## OpenTelemetry integration
16
+
17
+ Gemini CLI integrates with **[OpenTelemetry]**, a vendor-neutral,
18
+ industry-standard observability framework.
19
+
20
+ The observability system provides:
21
+
22
+ - Universal compatibility: Export to any OpenTelemetry backend (Google Cloud,
23
+ Jaeger, Prometheus, Datadog, etc.).
24
+ - Standardized data: Use consistent formats and collection methods across your
25
+ toolchain.
26
+ - Future-proof integration: Connect with existing and future observability
27
+ infrastructure.
28
+ - No vendor lock-in: Switch between backends without changing your
29
+ instrumentation.
30
+
31
+ [OpenTelemetry]: https://opentelemetry.io/
32
+
33
+ ## Configuration
34
+
35
+ You control telemetry behavior through the `.gemini/settings.json` file.
36
+ Environment variables can override these settings.
37
+
38
+ | Setting | Environment Variable | Description | Values | Default |
39
+ | -------------- | --------------------------------- | --------------------------------------------------- | ----------------- | ----------------------- |
40
+ | `enabled` | `GEMINI_TELEMETRY_ENABLED` | Enable or disable telemetry | `true`/`false` | `false` |
41
+ | `traces` | `GEMINI_TELEMETRY_TRACES_ENABLED` | Enable detailed attribute tracing | `true`/`false` | `false` |
42
+ | `target` | `GEMINI_TELEMETRY_TARGET` | Where to send telemetry data | `"gcp"`/`"local"` | `"local"` |
43
+ | `otlpEndpoint` | `GEMINI_TELEMETRY_OTLP_ENDPOINT` | OTLP collector endpoint | URL string | `http://localhost:4317` |
44
+ | `otlpProtocol` | `GEMINI_TELEMETRY_OTLP_PROTOCOL` | OTLP transport protocol | `"grpc"`/`"http"` | `"grpc"` |
45
+ | `outfile` | `GEMINI_TELEMETRY_OUTFILE` | Save telemetry to file (overrides `otlpEndpoint`) | file path | - |
46
+ | `logPrompts` | `GEMINI_TELEMETRY_LOG_PROMPTS` | Include prompts in telemetry logs | `true`/`false` | `true` |
47
+ | `useCollector` | `GEMINI_TELEMETRY_USE_COLLECTOR` | Use external OTLP collector (advanced) | `true`/`false` | `false` |
48
+ | `useCliAuth` | `GEMINI_TELEMETRY_USE_CLI_AUTH` | Use CLI credentials for telemetry (GCP target only) | `true`/`false` | `false` |
49
+ | - | `GEMINI_CLI_SURFACE` | Optional custom label for traffic reporting | string | - |
50
+
51
+ **Note on boolean environment variables:** For boolean settings like `enabled`,
52
+ setting the environment variable to `true` or `1` enables the feature.
53
+
54
+ For detailed configuration information, see the
55
+ [Configuration guide](../reference/configuration.md).
56
+
57
+ ## Google Cloud telemetry
58
+
59
+ You can export telemetry data directly to Google Cloud Trace, Cloud Monitoring,
60
+ and Cloud Logging.
61
+
62
+ ### Prerequisites
63
+
64
+ You must complete several setup steps before enabling Google Cloud telemetry.
65
+
66
+ 1. Set your Google Cloud project ID:
67
+
68
+ - To send telemetry to a separate project:
69
+
70
+ **macOS/Linux**
71
+
72
+ ```bash
73
+ export OTLP_GOOGLE_CLOUD_PROJECT="your-telemetry-project-id"
74
+ ```
75
+
76
+ **Windows (PowerShell)**
77
+
78
+ ```powershell
79
+ $env:OTLP_GOOGLE_CLOUD_PROJECT="your-telemetry-project-id"
80
+ ```
81
+
82
+ - To send telemetry to the same project as inference:
83
+
84
+ **macOS/Linux**
85
+
86
+ ```bash
87
+ export GOOGLE_CLOUD_PROJECT="your-project-id"
88
+ ```
89
+
90
+ **Windows (PowerShell)**
91
+
92
+ ```powershell
93
+ $env:GOOGLE_CLOUD_PROJECT="your-project-id"
94
+ ```
95
+
96
+ 2. Authenticate with Google Cloud using one of these methods:
97
+
98
+ - **Method A: Application Default Credentials (ADC)**: Use this method for
99
+ service accounts or standard `gcloud` authentication.
100
+
101
+ - For user accounts:
102
+ ```bash
103
+ gcloud auth application-default login
104
+ ```
105
+ - For service accounts:
106
+
107
+ **macOS/Linux**
108
+
109
+ ```bash
110
+ export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/service-account.json"
111
+ ```
112
+
113
+ **Windows (PowerShell)**
114
+
115
+ ```powershell
116
+ $env:GOOGLE_APPLICATION_CREDENTIALS="C:\path\to\your\service-account.json"
117
+ ```
118
+
119
+ * **Method B: CLI Auth** (Direct export only): Simplest method for local
120
+ users. Gemini CLI uses the same OAuth credentials you used for login. To
121
+ enable this, set `useCliAuth: true` in your `.gemini/settings.json`:
122
+
123
+ ```json
124
+ {
125
+ "telemetry": {
126
+ "enabled": true,
127
+ "target": "gcp",
128
+ "useCliAuth": true
129
+ }
130
+ }
131
+ ```
132
+
133
+ <!-- prettier-ignore -->
134
+ > [!NOTE]
135
+ > This setting requires **Direct export** (in-process exporters)
136
+ > and cannot be used when `useCollector` is `true`. If both are enabled,
137
+ > telemetry will be disabled.
138
+
139
+ 3. Ensure your account or service account has these IAM roles:
140
+
141
+ - Cloud Trace Agent
142
+ - Monitoring Metric Writer
143
+ - Logs Writer
144
+
145
+ 4. Enable the required Google Cloud APIs:
146
+ ```bash
147
+ gcloud services enable \
148
+ cloudtrace.googleapis.com \
149
+ monitoring.googleapis.com \
150
+ logging.googleapis.com \
151
+ --project="$OTLP_GOOGLE_CLOUD_PROJECT"
152
+ ```
153
+
154
+ ### Direct export
155
+
156
+ We recommend using direct export to send telemetry directly to Google Cloud
157
+ services.
158
+
159
+ 1. Enable telemetry in `.gemini/settings.json`:
160
+ ```json
161
+ {
162
+ "telemetry": {
163
+ "enabled": true,
164
+ "target": "gcp"
165
+ }
166
+ }
167
+ ```
168
+ 2. Run Gemini CLI and send prompts.
169
+ 3. View logs, metrics, and traces in the Google Cloud Console. See
170
+ [View Google Cloud telemetry](#view-google-cloud-telemetry) for details.
171
+
172
+ ### View Google Cloud telemetry
173
+
174
+ After you enable telemetry and run Gemini CLI, you can view your data in the
175
+ Google Cloud Console.
176
+
177
+ - **Logs:** [Logs Explorer](https://console.cloud.google.com/logs/)
178
+ - **Metrics:**
179
+ [Metrics Explorer](https://console.cloud.google.com/monitoring/metrics-explorer)
180
+ - **Traces:** [Trace Explorer](https://console.cloud.google.com/traces/list)
181
+
182
+ For detailed information on how to use these tools, see the following official
183
+ Google Cloud documentation:
184
+
185
+ - [View and analyze logs with Logs Explorer](https://cloud.google.com/logging/docs/view/logs-explorer-interface)
186
+ - [Create charts with Metrics Explorer](https://cloud.google.com/monitoring/charts/metrics-explorer)
187
+ - [Find and explore traces](https://cloud.google.com/trace/docs/finding-traces)
188
+
189
+ #### Monitoring dashboards
190
+
191
+ Gemini CLI provides a pre-configured
192
+ [Google Cloud Monitoring](https://cloud.google.com/monitoring) dashboard to
193
+ visualize your telemetry.
194
+
195
+ Find this dashboard under **Google Cloud Monitoring Dashboard Templates** as
196
+ "**Gemini CLI Monitoring**".
197
+
198
+ ![Gemini CLI Monitoring Dashboard Overview](/docs/assets/monitoring-dashboard-overview.png)
199
+
200
+ ![Gemini CLI Monitoring Dashboard Metrics](/docs/assets/monitoring-dashboard-metrics.png)
201
+
202
+ ![Gemini CLI Monitoring Dashboard Logs](/docs/assets/monitoring-dashboard-logs.png)
203
+
204
+ To learn more, see
205
+ [Instant insights: Gemini CLI’s pre-configured monitoring dashboards](https://cloud.google.com/blog/topics/developers-practitioners/instant-insights-gemini-clis-new-pre-configured-monitoring-dashboards/).
206
+
207
+ ## Local telemetry
208
+
209
+ You can capture telemetry data locally for development and debugging. We
210
+ recommend using file-based output for local development.
211
+
212
+ 1. Enable telemetry in `.gemini/settings.json`:
213
+ ```json
214
+ {
215
+ "telemetry": {
216
+ "enabled": true,
217
+ "target": "local",
218
+ "outfile": ".gemini/telemetry.log"
219
+ }
220
+ }
221
+ ```
222
+ 2. Run Gemini CLI and send prompts.
223
+ 3. View logs and metrics in `.gemini/telemetry.log`.
224
+
225
+ For advanced local telemetry setups (such as Jaeger or Genkit), see the
226
+ [Local development guide](../local-development.md#viewing-traces).
227
+
228
+ ## Client identification
229
+
230
+ Gemini CLI includes identifiers in its `User-Agent` header to help you
231
+ differentiate and report on API traffic from different environments (for
232
+ example, identifying calls from Gemini Code Assist versus a standard terminal).
233
+
234
+ ### Automatic identification
235
+
236
+ Most integrated environments are identified automatically without additional
237
+ configuration. The identifier is included as a prefix to the `User-Agent` and as
238
+ a "surface" tag in the parenthetical metadata.
239
+
240
+ | Environment | User-Agent Prefix | Surface Tag |
241
+ | :---------------------------------- | :--------------------------- | :---------- |
242
+ | **Gemini Code Assist (Agent Mode)** | `GeminiCLI-a2a-server` | `vscode` |
243
+ | **Zed (via ACP)** | `GeminiCLI-acp-zed` | `zed` |
244
+ | **XCode (via ACP)** | `GeminiCLI-acp-xcode` | `xcode` |
245
+ | **IntelliJ IDEA (via ACP)** | `GeminiCLI-acp-intellijidea` | `jetbrains` |
246
+ | **Standard Terminal** | `GeminiCLI` | `terminal` |
247
+
248
+ **Example User-Agent:**
249
+ `GeminiCLI-a2a-server/0.34.0/gemini-pro (linux; x64; vscode)`
250
+
251
+ ### Custom identification
252
+
253
+ You can provide a custom identifier for your own scripts or automation by
254
+ setting the `GEMINI_CLI_SURFACE` environment variable. This is useful for
255
+ tracking specific internal tools or distribution channels in your GCP logs.
256
+
257
+ **macOS/Linux**
258
+
259
+ ```bash
260
+ export GEMINI_CLI_SURFACE="my-custom-tool"
261
+ ```
262
+
263
+ **Windows (PowerShell)**
264
+
265
+ ```powershell
266
+ $env:GEMINI_CLI_SURFACE="my-custom-tool"
267
+ ```
268
+
269
+ When set, the value appears at the end of the `User-Agent` parenthetical:
270
+ `GeminiCLI/0.34.0/gemini-pro (linux; x64; my-custom-tool)`
271
+
272
+ ## Logs, metrics, and traces
273
+
274
+ This section describes the structure of logs, metrics, and traces generated by
275
+ Gemini CLI.
276
+
277
+ Gemini CLI includes `session.id`, `installation.id`, `active_approval_mode`, and
278
+ `user.email` (when authenticated) as common attributes on all data.
279
+
280
+ ### Logs
281
+
282
+ Logs provide timestamped records of specific events. Gemini CLI logs events
283
+ across several categories.
284
+
285
+ #### Sessions
286
+
287
+ Session logs capture startup configuration and prompt submissions.
288
+
289
+ ##### `gemini_cli.config`
290
+
291
+ Emitted at startup with the CLI configuration.
292
+
293
+ <details>
294
+ <summary>Attributes</summary>
295
+
296
+ - `model` (string)
297
+ - `embedding_model` (string)
298
+ - `sandbox_enabled` (boolean)
299
+ - `core_tools_enabled` (string)
300
+ - `approval_mode` (string)
301
+ - `api_key_enabled` (boolean)
302
+ - `vertex_ai_enabled` (boolean)
303
+ - `log_user_prompts_enabled` (boolean)
304
+ - `file_filtering_respect_git_ignore` (boolean)
305
+ - `debug_mode` (boolean)
306
+ - `mcp_servers` (string)
307
+ - `mcp_servers_count` (int)
308
+ - `mcp_tools` (string)
309
+ - `mcp_tools_count` (int)
310
+ - `output_format` (string)
311
+ - `extensions` (string)
312
+ - `extension_ids` (string)
313
+ - `extensions_count` (int)
314
+ - `auth_type` (string)
315
+ - `worktree_active` (boolean)
316
+ - `github_workflow_name` (string, optional)
317
+ - `github_repository_hash` (string, optional)
318
+ - `github_event_name` (string, optional)
319
+ - `github_pr_number` (string, optional)
320
+ - `github_issue_number` (string, optional)
321
+ - `github_custom_tracking_id` (string, optional)
322
+
323
+ </details>
324
+
325
+ ##### `gemini_cli.user_prompt`
326
+
327
+ Emitted when you submit a prompt.
328
+
329
+ <details>
330
+ <summary>Attributes</summary>
331
+
332
+ - `prompt_length` (int)
333
+ - `prompt_id` (string)
334
+ - `prompt` (string; excluded if `telemetry.logPrompts` is `false`)
335
+ - `auth_type` (string)
336
+
337
+ </details>
338
+
339
+ #### Approval mode
340
+
341
+ These logs track changes to and usage of different approval modes.
342
+
343
+ ##### Lifecycle
344
+
345
+ ##### `approval_mode_switch`
346
+
347
+ Logs when you change the approval mode.
348
+
349
+ <details>
350
+ <summary>Attributes</summary>
351
+
352
+ - `from_mode` (string)
353
+ - `to_mode` (string)
354
+
355
+ </details>
356
+
357
+ ##### `approval_mode_duration`
358
+
359
+ Records time spent in an approval mode.
360
+
361
+ <details>
362
+ <summary>Attributes</summary>
363
+
364
+ - `mode` (string)
365
+ - `duration_ms` (int)
366
+
367
+ </details>
368
+
369
+ ##### Execution
370
+
371
+ ##### `plan_execution`
372
+
373
+ Logs when you execute a plan and switch from plan mode to active execution.
374
+
375
+ <details>
376
+ <summary>Attributes</summary>
377
+
378
+ - `approval_mode` (string)
379
+
380
+ </details>
381
+
382
+ #### Tools
383
+
384
+ Tool logs capture executions, truncation, and edit behavior.
385
+
386
+ ##### `gemini_cli.tool_call`
387
+
388
+ Emitted for each tool (function) call.
389
+
390
+ <details>
391
+ <summary>Attributes</summary>
392
+
393
+ - `function_name` (string)
394
+ - `function_args` (string)
395
+ - `duration_ms` (int)
396
+ - `success` (boolean)
397
+ - `decision` (string: "accept", "reject", "auto_accept", or "modify")
398
+ - `error` (string, optional)
399
+ - `error_type` (string, optional)
400
+ - `prompt_id` (string)
401
+ - `tool_type` (string: "native" or "mcp")
402
+ - `mcp_server_name` (string, optional)
403
+ - `extension_name` (string, optional)
404
+ - `extension_id` (string, optional)
405
+ - `content_length` (int, optional)
406
+ - `start_time` (number, optional)
407
+ - `end_time` (number, optional)
408
+ - `metadata` (object, optional), which may include:
409
+ - `model_added_lines` (number)
410
+ - `model_removed_lines` (number)
411
+ - `user_added_lines` (number)
412
+ - `user_removed_lines` (number)
413
+ - `ask_user` (object)
414
+
415
+ </details>
416
+
417
+ ##### `gemini_cli.tool_output_truncated`
418
+
419
+ Logs when tool output is truncated.
420
+
421
+ <details>
422
+ <summary>Attributes</summary>
423
+
424
+ - `tool_name` (string)
425
+ - `original_content_length` (int)
426
+ - `truncated_content_length` (int)
427
+ - `threshold` (int)
428
+ - `lines` (int)
429
+ - `prompt_id` (string)
430
+
431
+ </details>
432
+
433
+ ##### `gemini_cli.edit_strategy`
434
+
435
+ Records the chosen edit strategy.
436
+
437
+ <details>
438
+ <summary>Attributes</summary>
439
+
440
+ - `strategy` (string)
441
+
442
+ </details>
443
+
444
+ ##### `gemini_cli.edit_correction`
445
+
446
+ Records the result of an edit correction.
447
+
448
+ <details>
449
+ <summary>Attributes</summary>
450
+
451
+ - `correction` (string: "success" or "failure")
452
+
453
+ </details>
454
+
455
+ ##### `gen_ai.client.inference.operation.details`
456
+
457
+ Provides detailed GenAI operation data aligned with OpenTelemetry conventions.
458
+
459
+ <details>
460
+ <summary>Attributes</summary>
461
+
462
+ - `gen_ai.request.model` (string)
463
+ - `gen_ai.provider.name` (string)
464
+ - `gen_ai.operation.name` (string)
465
+ - `gen_ai.input.messages` (json string)
466
+ - `gen_ai.output.messages` (json string)
467
+ - `gen_ai.response.finish_reasons` (array of strings)
468
+ - `gen_ai.usage.input_tokens` (int)
469
+ - `gen_ai.usage.output_tokens` (int)
470
+ - `gen_ai.request.temperature` (float)
471
+ - `gen_ai.request.top_p` (float)
472
+ - `gen_ai.request.top_k` (int)
473
+ - `gen_ai.request.max_tokens` (int)
474
+ - `gen_ai.system_instructions` (json string)
475
+ - `server.address` (string)
476
+ - `server.port` (int)
477
+
478
+ </details>
479
+
480
+ #### Files
481
+
482
+ File logs track operations performed by tools.
483
+
484
+ ##### `gemini_cli.file_operation`
485
+
486
+ Emitted for each file creation, read, or update.
487
+
488
+ <details>
489
+ <summary>Attributes</summary>
490
+
491
+ - `tool_name` (string)
492
+ - `operation` (string: "create", "read", or "update")
493
+ - `lines` (int, optional)
494
+ - `mimetype` (string, optional)
495
+ - `extension` (string, optional)
496
+ - `programming_language` (string, optional)
497
+
498
+ </details>
499
+
500
+ #### API
501
+
502
+ API logs capture requests, responses, and errors from Gemini API.
503
+
504
+ ##### `gemini_cli.api_request`
505
+
506
+ Request sent to Gemini API.
507
+
508
+ <details>
509
+ <summary>Attributes</summary>
510
+
511
+ - `model` (string)
512
+ - `prompt_id` (string)
513
+ - `role` (string: "user", "model", or "system")
514
+ - `request_text` (string, optional)
515
+
516
+ </details>
517
+
518
+ ##### `gemini_cli.api_response`
519
+
520
+ Response received from Gemini API.
521
+
522
+ <details>
523
+ <summary>Attributes</summary>
524
+
525
+ - `model` (string)
526
+ - `status_code` (int or string)
527
+ - `duration_ms` (int)
528
+ - `input_token_count` (int)
529
+ - `output_token_count` (int)
530
+ - `cached_content_token_count` (int)
531
+ - `thoughts_token_count` (int)
532
+ - `tool_token_count` (int)
533
+ - `total_token_count` (int)
534
+ - `prompt_id` (string)
535
+ - `auth_type` (string)
536
+ - `finish_reasons` (array of strings)
537
+ - `response_text` (string, optional)
538
+
539
+ </details>
540
+
541
+ ##### `gemini_cli.api_error`
542
+
543
+ Logs when an API request fails.
544
+
545
+ <details>
546
+ <summary>Attributes</summary>
547
+
548
+ - `error.message` (string)
549
+ - `model_name` (string)
550
+ - `duration` (int)
551
+ - `prompt_id` (string)
552
+ - `auth_type` (string)
553
+ - `error_type` (string, optional)
554
+ - `status_code` (int or string, optional)
555
+ - `role` (string, optional)
556
+
557
+ </details>
558
+
559
+ ##### `gemini_cli.malformed_json_response`
560
+
561
+ Logs when a JSON response cannot be parsed.
562
+
563
+ <details>
564
+ <summary>Attributes</summary>
565
+
566
+ - `model` (string)
567
+
568
+ </details>
569
+
570
+ #### Model routing
571
+
572
+ These logs track how Gemini CLI selects and routes requests to models.
573
+
574
+ ##### `gemini_cli.slash_command`
575
+
576
+ Logs slash command execution.
577
+
578
+ <details>
579
+ <summary>Attributes</summary>
580
+
581
+ - `command` (string)
582
+ - `subcommand` (string, optional)
583
+ - `status` (string: "success" or "error")
584
+
585
+ </details>
586
+
587
+ ##### `gemini_cli.slash_command.model`
588
+
589
+ Logs model selection via slash command.
590
+
591
+ <details>
592
+ <summary>Attributes</summary>
593
+
594
+ - `model_name` (string)
595
+
596
+ </details>
597
+
598
+ ##### `gemini_cli.model_routing`
599
+
600
+ Records model router decisions and reasoning.
601
+
602
+ <details>
603
+ <summary>Attributes</summary>
604
+
605
+ - `decision_model` (string)
606
+ - `decision_source` (string)
607
+ - `routing_latency_ms` (int)
608
+ - `reasoning` (string, optional)
609
+ - `failed` (boolean)
610
+ - `error_message` (string, optional)
611
+ - `approval_mode` (string)
612
+
613
+ </details>
614
+
615
+ #### Chat and streaming
616
+
617
+ These logs track chat context compression and streaming chunk errors.
618
+
619
+ ##### `gemini_cli.chat_compression`
620
+
621
+ Logs chat context compression events.
622
+
623
+ <details>
624
+ <summary>Attributes</summary>
625
+
626
+ - `tokens_before` (int)
627
+ - `tokens_after` (int)
628
+
629
+ </details>
630
+
631
+ ##### `gemini_cli.chat.invalid_chunk`
632
+
633
+ Logs invalid chunks received in a stream.
634
+
635
+ <details>
636
+ <summary>Attributes</summary>
637
+
638
+ - `error_message` (string, optional)
639
+
640
+ </details>
641
+
642
+ ##### `gemini_cli.chat.content_retry`
643
+
644
+ Logs retries due to content errors.
645
+
646
+ <details>
647
+ <summary>Attributes</summary>
648
+
649
+ - `attempt_number` (int)
650
+ - `error_type` (string)
651
+ - `retry_delay_ms` (int)
652
+ - `model` (string)
653
+
654
+ </details>
655
+
656
+ ##### `gemini_cli.chat.content_retry_failure`
657
+
658
+ Logs when all content retries fail.
659
+
660
+ <details>
661
+ <summary>Attributes</summary>
662
+
663
+ - `total_attempts` (int)
664
+ - `final_error_type` (string)
665
+ - `total_duration_ms` (int, optional)
666
+ - `model` (string)
667
+
668
+ </details>
669
+
670
+ ##### `gemini_cli.conversation_finished`
671
+
672
+ Logs when a conversation session ends.
673
+
674
+ <details>
675
+ <summary>Attributes</summary>
676
+
677
+ - `approvalMode` (string)
678
+ - `turnCount` (int)
679
+
680
+ </details>
681
+
682
+ #### Resilience
683
+
684
+ Resilience logs record fallback mechanisms and recovery attempts.
685
+
686
+ ##### `gemini_cli.flash_fallback`
687
+
688
+ Logs switch to a flash model fallback.
689
+
690
+ <details>
691
+ <summary>Attributes</summary>
692
+
693
+ - `auth_type` (string)
694
+
695
+ </details>
696
+
697
+ ##### `gemini_cli.ripgrep_fallback`
698
+
699
+ Logs fallback to standard grep.
700
+
701
+ <details>
702
+ <summary>Attributes</summary>
703
+
704
+ - `error` (string, optional)
705
+
706
+ </details>
707
+
708
+ ##### `gemini_cli.web_fetch_fallback_attempt`
709
+
710
+ Logs web-fetch fallback attempts.
711
+
712
+ <details>
713
+ <summary>Attributes</summary>
714
+
715
+ - `reason` (string: "private_ip" or "primary_failed")
716
+
717
+ </details>
718
+
719
+ ##### `gemini_cli.agent.recovery_attempt`
720
+
721
+ Logs attempts to recover from agent errors.
722
+
723
+ <details>
724
+ <summary>Attributes</summary>
725
+
726
+ - `agent_name` (string)
727
+ - `attempt_number` (int)
728
+ - `success` (boolean)
729
+ - `error_type` (string, optional)
730
+
731
+ </details>
732
+
733
+ #### Extensions
734
+
735
+ Extension logs track lifecycle events and settings changes.
736
+
737
+ ##### `gemini_cli.extension_install`
738
+
739
+ Logs when you install an extension.
740
+
741
+ <details>
742
+ <summary>Attributes</summary>
743
+
744
+ - `extension_name` (string)
745
+ - `extension_version` (string)
746
+ - `extension_source` (string)
747
+ - `status` (string)
748
+
749
+ </details>
750
+
751
+ ##### `gemini_cli.extension_uninstall`
752
+
753
+ Logs when you uninstall an extension.
754
+
755
+ <details>
756
+ <summary>Attributes</summary>
757
+
758
+ - `extension_name` (string)
759
+ - `status` (string)
760
+
761
+ </details>
762
+
763
+ ##### `gemini_cli.extension_enable`
764
+
765
+ Logs when you enable an extension.
766
+
767
+ <details>
768
+ <summary>Attributes</summary>
769
+
770
+ - `extension_name` (string)
771
+ - `setting_scope` (string)
772
+
773
+ </details>
774
+
775
+ ##### `gemini_cli.extension_disable`
776
+
777
+ Logs when you disable an extension.
778
+
779
+ <details>
780
+ <summary>Attributes</summary>
781
+
782
+ - `extension_name` (string)
783
+ - `setting_scope` (string)
784
+
785
+ </details>
786
+
787
+ #### Agent runs
788
+
789
+ Agent logs track the lifecycle of agent executions.
790
+
791
+ ##### `gemini_cli.agent.start`
792
+
793
+ Logs when an agent run begins.
794
+
795
+ <details>
796
+ <summary>Attributes</summary>
797
+
798
+ - `agent_id` (string)
799
+ - `agent_name` (string)
800
+
801
+ </details>
802
+
803
+ ##### `gemini_cli.agent.finish`
804
+
805
+ Logs when an agent run completes.
806
+
807
+ <details>
808
+ <summary>Attributes</summary>
809
+
810
+ - `agent_id` (string)
811
+ - `agent_name` (string)
812
+ - `duration_ms` (int)
813
+ - `turn_count` (int)
814
+ - `terminate_reason` (string)
815
+
816
+ </details>
817
+
818
+ #### IDE
819
+
820
+ IDE logs capture connectivity events for the IDE companion.
821
+
822
+ ##### `gemini_cli.ide_connection`
823
+
824
+ Logs IDE companion connections.
825
+
826
+ <details>
827
+ <summary>Attributes</summary>
828
+
829
+ - `connection_type` (string)
830
+
831
+ </details>
832
+
833
+ #### UI
834
+
835
+ UI logs track terminal rendering issues.
836
+
837
+ ##### `kitty_sequence_overflow`
838
+
839
+ Logs terminal control sequence overflows.
840
+
841
+ <details>
842
+ <summary>Attributes</summary>
843
+
844
+ - `sequence_length` (int)
845
+ - `truncated_sequence` (string)
846
+
847
+ </details>
848
+
849
+ #### Miscellaneous
850
+
851
+ ##### `gemini_cli.rewind`
852
+
853
+ Logs when the conversation state is rewound.
854
+
855
+ <details>
856
+ <summary>Attributes</summary>
857
+
858
+ - `outcome` (string)
859
+
860
+ </details>
861
+
862
+ ##### `gemini_cli.conseca.verdict`
863
+
864
+ Logs security verdicts from ConSeca.
865
+
866
+ <details>
867
+ <summary>Attributes</summary>
868
+
869
+ - `verdict` (string)
870
+ - `decision` (string: "accept", "reject", or "modify")
871
+ - `reason` (string, optional)
872
+ - `tool_name` (string, optional)
873
+
874
+ </details>
875
+
876
+ ##### `gemini_cli.hook_call`
877
+
878
+ Logs execution of lifecycle hooks.
879
+
880
+ <details>
881
+ <summary>Attributes</summary>
882
+
883
+ - `hook_name` (string)
884
+ - `hook_type` (string)
885
+ - `duration_ms` (int)
886
+ - `success` (boolean)
887
+
888
+ </details>
889
+
890
+ ##### `gemini_cli.tool_output_masking`
891
+
892
+ Logs when tool output is masked for privacy.
893
+
894
+ <details>
895
+ <summary>Attributes</summary>
896
+
897
+ - `tokens_before` (int)
898
+ - `tokens_after` (int)
899
+ - `masked_count` (int)
900
+ - `total_prunable_tokens` (int)
901
+
902
+ </details>
903
+
904
+ ##### `gemini_cli.keychain.availability`
905
+
906
+ Logs keychain availability checks.
907
+
908
+ <details>
909
+ <summary>Attributes</summary>
910
+
911
+ - `available` (boolean)
912
+
913
+ ##### `gemini_cli.startup_stats`
914
+
915
+ Logs detailed startup performance statistics.
916
+
917
+ <details>
918
+ <summary>Attributes</summary>
919
+
920
+ - `phases` (json array of startup phases)
921
+ - `os_platform` (string)
922
+ - `os_release` (string)
923
+ - `is_docker` (boolean)
924
+
925
+ </details>
926
+
927
+ </details>
928
+
929
+ ### Metrics
930
+
931
+ Metrics provide numerical measurements of behavior over time.
932
+
933
+ #### Custom metrics
934
+
935
+ Gemini CLI exports several custom metrics.
936
+
937
+ ##### Sessions
938
+
939
+ ##### `gemini_cli.session.count`
940
+
941
+ Incremented once per CLI startup.
942
+
943
+ ##### Onboarding
944
+
945
+ Tracks onboarding flow from authentication to the user
946
+
947
+ - `gemini_cli.onboarding.start` (Counter, Int): Incremented when the
948
+ authentication flow begins.
949
+
950
+ - `gemini_cli.onboarding.success` (Counter, Int): Incremented when the user
951
+ onboarding flow completes successfully.
952
+ <details>
953
+ <summary>Attributes (Success)</summary>
954
+
955
+ - `user_tier` (string)
956
+
957
+ ##### Tools
958
+
959
+ ##### `gemini_cli.tool.call.count`
960
+
961
+ Counts tool calls.
962
+
963
+ <details>
964
+ <summary>Attributes</summary>
965
+
966
+ - `function_name` (string)
967
+ - `success` (boolean)
968
+ - `decision` (string: "accept", "reject", "modify", or "auto_accept")
969
+ - `tool_type` (string: "mcp" or "native")
970
+
971
+ </details>
972
+
973
+ ##### `gemini_cli.tool.call.latency`
974
+
975
+ Measures tool call latency (in ms).
976
+
977
+ <details>
978
+ <summary>Attributes</summary>
979
+
980
+ - `function_name` (string)
981
+
982
+ </details>
983
+
984
+ ##### API
985
+
986
+ ##### `gemini_cli.api.request.count`
987
+
988
+ Counts all API requests.
989
+
990
+ <details>
991
+ <summary>Attributes</summary>
992
+
993
+ - `model` (string)
994
+ - `status_code` (int or string)
995
+ - `error_type` (string, optional)
996
+
997
+ </details>
998
+
999
+ ##### `gemini_cli.api.request.latency`
1000
+
1001
+ Measures API request latency (in ms).
1002
+
1003
+ <details>
1004
+ <summary>Attributes</summary>
1005
+
1006
+ - `model` (string)
1007
+
1008
+ </details>
1009
+
1010
+ ##### Token usage
1011
+
1012
+ ##### `gemini_cli.token.usage`
1013
+
1014
+ Counts input, output, thought, cache, and tool tokens.
1015
+
1016
+ <details>
1017
+ <summary>Attributes</summary>
1018
+
1019
+ - `model` (string)
1020
+ - `type` (string: "input", "output", "thought", "cache", or "tool")
1021
+
1022
+ </details>
1023
+
1024
+ ##### Files
1025
+
1026
+ ##### `gemini_cli.file.operation.count`
1027
+
1028
+ Counts file operations.
1029
+
1030
+ <details>
1031
+ <summary>Attributes</summary>
1032
+
1033
+ - `operation` (string: "create", "read", or "update")
1034
+ - `lines` (int, optional)
1035
+ - `mimetype` (string, optional)
1036
+ - `extension` (string, optional)
1037
+ - `programming_language` (string, optional)
1038
+
1039
+ </details>
1040
+
1041
+ ##### `gemini_cli.lines.changed`
1042
+
1043
+ Counts added or removed lines.
1044
+
1045
+ <details>
1046
+ <summary>Attributes</summary>
1047
+
1048
+ - `function_name` (string, optional)
1049
+ - `type` (string: "added" or "removed")
1050
+
1051
+ </details>
1052
+
1053
+ ##### Chat and streaming
1054
+
1055
+ ##### `gemini_cli.chat_compression`
1056
+
1057
+ Counts compression operations.
1058
+
1059
+ <details>
1060
+ <summary>Attributes</summary>
1061
+
1062
+ - `tokens_before` (int)
1063
+ - `tokens_after` (int)
1064
+
1065
+ </details>
1066
+
1067
+ ##### `gemini_cli.chat.invalid_chunk.count`
1068
+
1069
+ Counts invalid stream chunks.
1070
+
1071
+ ##### `gemini_cli.chat.content_retry.count`
1072
+
1073
+ Counts content error retries.
1074
+
1075
+ ##### `gemini_cli.chat.content_retry_failure.count`
1076
+
1077
+ Counts requests where all retries failed.
1078
+
1079
+ ##### Model routing
1080
+
1081
+ ##### `gemini_cli.slash_command.model.call_count`
1082
+
1083
+ Counts model selections.
1084
+
1085
+ <details>
1086
+ <summary>Attributes</summary>
1087
+
1088
+ - `slash_command.model.model_name` (string)
1089
+
1090
+ </details>
1091
+
1092
+ ##### `gemini_cli.model_routing.latency`
1093
+
1094
+ Measures routing decision latency.
1095
+
1096
+ <details>
1097
+ <summary>Attributes</summary>
1098
+
1099
+ - `routing.decision_model` (string)
1100
+ - `routing.decision_source` (string)
1101
+ - `routing.approval_mode` (string)
1102
+
1103
+ </details>
1104
+
1105
+ ##### `gemini_cli.model_routing.failure.count`
1106
+
1107
+ Counts routing failures.
1108
+
1109
+ <details>
1110
+ <summary>Attributes</summary>
1111
+
1112
+ - `routing.decision_source` (string)
1113
+ - `routing.error_message` (string)
1114
+ - `routing.approval_mode` (string)
1115
+
1116
+ </details>
1117
+
1118
+ ##### Agent runs
1119
+
1120
+ ##### `gemini_cli.agent.run.count`
1121
+
1122
+ Counts agent runs.
1123
+
1124
+ <details>
1125
+ <summary>Attributes</summary>
1126
+
1127
+ - `agent_name` (string)
1128
+ - `terminate_reason` (string)
1129
+
1130
+ </details>
1131
+
1132
+ ##### `gemini_cli.agent.duration`
1133
+
1134
+ Measures agent run duration.
1135
+
1136
+ <details>
1137
+ <summary>Attributes</summary>
1138
+
1139
+ - `agent_name` (string)
1140
+
1141
+ </details>
1142
+
1143
+ ##### `gemini_cli.agent.turns`
1144
+
1145
+ Counts turns per agent run.
1146
+
1147
+ <details>
1148
+ <summary>Attributes</summary>
1149
+
1150
+ - `agent_name` (string)
1151
+
1152
+ </details>
1153
+
1154
+ ##### Approval mode
1155
+
1156
+ ##### `gemini_cli.plan.execution.count`
1157
+
1158
+ Counts plan executions.
1159
+
1160
+ <details>
1161
+ <summary>Attributes</summary>
1162
+
1163
+ - `approval_mode` (string)
1164
+
1165
+ </details>
1166
+
1167
+ ##### UI
1168
+
1169
+ ##### `gemini_cli.ui.flicker.count`
1170
+
1171
+ Counts terminal flicker events.
1172
+
1173
+ ##### Performance
1174
+
1175
+ Gemini CLI provides detailed performance metrics for advanced monitoring.
1176
+
1177
+ ##### `gemini_cli.startup.duration`
1178
+
1179
+ Measures startup time by phase.
1180
+
1181
+ <details>
1182
+ <summary>Attributes</summary>
1183
+
1184
+ - `phase` (string)
1185
+ - `details` (map, optional)
1186
+
1187
+ </details>
1188
+
1189
+ ##### `gemini_cli.memory.usage`
1190
+
1191
+ Measures heap and RSS memory.
1192
+
1193
+ <details>
1194
+ <summary>Attributes</summary>
1195
+
1196
+ - `memory_type` (string: "heap_used", "heap_total", "external", "rss")
1197
+ - `component` (string, optional)
1198
+
1199
+ </details>
1200
+
1201
+ ##### `gemini_cli.cpu.usage`
1202
+
1203
+ Measures CPU usage percentage.
1204
+
1205
+ <details>
1206
+ <summary>Attributes</summary>
1207
+
1208
+ - `component` (string, optional)
1209
+
1210
+ </details>
1211
+
1212
+ ##### `gemini_cli.tool.queue.depth`
1213
+
1214
+ Measures tool execution queue depth.
1215
+
1216
+ ##### `gemini_cli.tool.execution.breakdown`
1217
+
1218
+ Breaks down tool time by phase.
1219
+
1220
+ <details>
1221
+ <summary>Attributes</summary>
1222
+
1223
+ - `function_name` (string)
1224
+ - `phase` (string: "validation", "preparation", "execution",
1225
+ "result_processing")
1226
+
1227
+ </details>
1228
+
1229
+ #### GenAI semantic convention
1230
+
1231
+ These metrics follow standard [OpenTelemetry GenAI semantic conventions].
1232
+
1233
+ - `gen_ai.client.token.usage`: Counts tokens used per operation.
1234
+ - `gen_ai.client.operation.duration`: Measures operation duration in seconds.
1235
+
1236
+ [OpenTelemetry GenAI semantic conventions]:
1237
+ https://github.com/open-telemetry/semantic-conventions/blob/main/docs/gen-ai/gen-ai-metrics.md
1238
+
1239
+ ### Traces
1240
+
1241
+ Traces provide an "under-the-hood" view of agent and backend operations. Use
1242
+ traces to debug tool interactions and optimize performance.
1243
+
1244
+ <!-- prettier-ignore -->
1245
+ > [!NOTE]
1246
+ > Detailed trace attributes (like full prompts and tool outputs) are disabled by default
1247
+ > to minimize overhead. You must explicitly set `telemetry.traces` to `true` (or set
1248
+ > `GEMINI_TELEMETRY_TRACES_ENABLED=true`) to capture them.
1249
+
1250
+ Every trace captures rich metadata via standard span attributes.
1251
+
1252
+ <details open>
1253
+ <summary>Standard span attributes</summary>
1254
+
1255
+ - `gen_ai.operation.name`: High-level operation (for example, `tool_call`,
1256
+ `llm_call`, `user_prompt`, `system_prompt`, `agent_call`, or
1257
+ `schedule_tool_calls`).
1258
+ - `gen_ai.agent.name`: Set to `gemini-cli`.
1259
+ - `gen_ai.agent.description`: The service agent description.
1260
+ - `gen_ai.input.messages`: Input data or metadata.
1261
+ - `gen_ai.output.messages`: Output data or results.
1262
+ - `gen_ai.request.model`: Request model name.
1263
+ - `gen_ai.response.model`: Response model name.
1264
+ - `gen_ai.prompt.name`: The prompt name.
1265
+ - `gen_ai.tool.name`: Executed tool name.
1266
+ - `gen_ai.tool.call_id`: Unique ID for the tool call.
1267
+ - `gen_ai.tool.description`: Tool description.
1268
+ - `gen_ai.tool.definitions`: Tool definitions in JSON format.
1269
+ - `gen_ai.usage.input_tokens`: Number of input tokens.
1270
+ - `gen_ai.usage.output_tokens`: Number of output tokens.
1271
+ - `gen_ai.system_instructions`: System instructions in JSON format.
1272
+ - `gen_ai.conversation.id`: The CLI session ID.
1273
+
1274
+ </details>
1275
+
1276
+ For more details on semantic conventions for events, see the
1277
+ [OpenTelemetry documentation](https://github.com/open-telemetry/semantic-conventions/blob/8b4f210f43136e57c1f6f47292eb6d38e3bf30bb/docs/gen-ai/gen-ai-events.md).
docs/cli/themes.md ADDED
@@ -0,0 +1,288 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Themes
2
+
3
+ Gemini CLI supports a variety of themes to customize its color scheme and
4
+ appearance. You can change the theme to suit your preferences via the `/theme`
5
+ command or `"theme":` configuration setting.
6
+
7
+ ## Available themes
8
+
9
+ Gemini CLI comes with a selection of pre-defined themes, which you can list
10
+ using the `/theme` command within Gemini CLI:
11
+
12
+ - **Dark themes:**
13
+ - `ANSI`
14
+ - `Atom One`
15
+ - `Ayu`
16
+ - `Default`
17
+ - `Dracula`
18
+ - `GitHub`
19
+ - `Holiday`
20
+ - `Shades Of Purple`
21
+ - `Solarized Dark`
22
+ - `Tokyo Night`
23
+ - **Light themes:**
24
+ - `ANSI Light`
25
+ - `Ayu Light`
26
+ - `Default Light`
27
+ - `GitHub Light`
28
+ - `Google Code`
29
+ - `Solarized Light`
30
+ - `Xcode`
31
+
32
+ ### Changing themes
33
+
34
+ 1. Enter `/theme` into Gemini CLI.
35
+ 2. A dialog or selection prompt appears, listing the available themes.
36
+ 3. Using the arrow keys, select a theme. Some interfaces might offer a live
37
+ preview or highlight as you select.
38
+ 4. Confirm your selection to apply the theme.
39
+
40
+ <!-- prettier-ignore -->
41
+ > [!NOTE]
42
+ > If a theme is defined in your `settings.json` file (either by name or
43
+ > by a file path), you must remove the `"theme"` setting from the file before
44
+ > you can change the theme using the `/theme` command.
45
+
46
+ ### Theme persistence
47
+
48
+ Selected themes are saved in Gemini CLI's
49
+ [configuration](../reference/configuration.md) so your preference is remembered
50
+ across sessions.
51
+
52
+ ---
53
+
54
+ ## Custom color themes
55
+
56
+ Gemini CLI lets you create your own custom color themes by specifying them in
57
+ your `settings.json` file. This gives you full control over the color palette
58
+ used in the CLI.
59
+
60
+ ### How to define a custom theme
61
+
62
+ Add a `customThemes` block to your user, project, or system `settings.json`
63
+ file. Each custom theme is defined as an object with a unique name and a set of
64
+ nested configuration objects. For example:
65
+
66
+ ```json
67
+ {
68
+ "ui": {
69
+ "customThemes": {
70
+ "MyCustomTheme": {
71
+ "name": "MyCustomTheme",
72
+ "type": "custom",
73
+ "background": {
74
+ "primary": "#181818"
75
+ },
76
+ "text": {
77
+ "primary": "#f0f0f0",
78
+ "secondary": "#a0a0a0"
79
+ }
80
+ }
81
+ }
82
+ }
83
+ }
84
+ ```
85
+
86
+ **Configuration objects:**
87
+
88
+ - **`text`**: Defines text colors.
89
+ - `primary`: The default text color.
90
+ - `secondary`: Used for less prominent text.
91
+ - `link`: Color for URLs and links.
92
+ - `accent`: Used for highlights and emphasis.
93
+ - `response`: Precedence over `primary` for rendering model responses.
94
+ - **`background`**: Defines background colors.
95
+ - `primary`: The main background color of the UI.
96
+ - `diff.added`: Background for added lines in diffs.
97
+ - `diff.removed`: Background for removed lines in diffs.
98
+ - **`border`**: Defines border colors.
99
+ - `default`: The standard border color.
100
+ - `focused`: Border color when an element is focused.
101
+ - **`status`**: Colors for status indicators.
102
+ - `success`: Used for successful operations.
103
+ - `warning`: Used for warnings.
104
+ - `error`: Used for errors.
105
+ - **`ui`**: Other UI elements.
106
+ - `comment`: Color for code comments.
107
+ - `symbol`: Color for code symbols and operators.
108
+ - `gradient`: An array of colors used for gradient effects.
109
+
110
+ **Required properties:**
111
+
112
+ - `name` (must match the key in the `customThemes` object and be a string)
113
+ - `type` (must be the string `"custom"`)
114
+
115
+ While all sub-properties are technically optional, we recommend providing at
116
+ least `background.primary`, `text.primary`, `text.secondary`, and the various
117
+ accent colors via `text.link`, `text.accent`, and `status` to ensure a cohesive
118
+ UI.
119
+
120
+ You can use either hex codes (for example, `#FF0000`) **or** standard CSS color
121
+ names (for example, `coral`, `teal`, `blue`) for any color value. See
122
+ [CSS color names](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#color_keywords)
123
+ for a full list of supported names.
124
+
125
+ You can define multiple custom themes by adding more entries to the
126
+ `customThemes` object.
127
+
128
+ ### Loading themes from a file
129
+
130
+ In addition to defining custom themes in `settings.json`, you can also load a
131
+ theme directly from a JSON file by specifying the file path in your
132
+ `settings.json`. This is useful for sharing themes or keeping them separate from
133
+ your main configuration.
134
+
135
+ To load a theme from a file, set the `theme` property in your `settings.json` to
136
+ the path of your theme file:
137
+
138
+ ```json
139
+ {
140
+ "ui": {
141
+ "theme": "/path/to/your/theme.json"
142
+ }
143
+ }
144
+ ```
145
+
146
+ The theme file must be a valid JSON file that follows the same structure as a
147
+ custom theme defined in `settings.json`.
148
+
149
+ **Example `my-theme.json`:**
150
+
151
+ ```json
152
+ {
153
+ "name": "Gruvbox Dark",
154
+ "type": "custom",
155
+ "background": {
156
+ "primary": "#282828",
157
+ "diff": {
158
+ "added": "#2b3312",
159
+ "removed": "#341212"
160
+ }
161
+ },
162
+ "text": {
163
+ "primary": "#ebdbb2",
164
+ "secondary": "#a89984",
165
+ "link": "#83a598",
166
+ "accent": "#d3869b"
167
+ },
168
+ "border": {
169
+ "default": "#3c3836",
170
+ "focused": "#458588"
171
+ },
172
+ "status": {
173
+ "success": "#b8bb26",
174
+ "warning": "#fabd2f",
175
+ "error": "#fb4934"
176
+ },
177
+ "ui": {
178
+ "comment": "#928374",
179
+ "symbol": "#8ec07c",
180
+ "gradient": ["#cc241d", "#d65d0e", "#d79921"]
181
+ }
182
+ }
183
+ ```
184
+
185
+ <!-- prettier-ignore -->
186
+ > [!WARNING]
187
+ > For your safety, Gemini CLI will only load theme files that
188
+ > are located within your home directory. If you attempt to load a theme from
189
+ > outside your home directory, a warning will be displayed and the theme will
190
+ > not be loaded. This is to prevent loading potentially malicious theme files
191
+ > from untrusted sources.
192
+
193
+ ### Example custom theme
194
+
195
+ <img src="/docs/assets/theme-custom.png" alt="Custom theme example" width="600" />
196
+
197
+ ### Using your custom theme
198
+
199
+ - Select your custom theme using the `/theme` command in Gemini CLI. Your custom
200
+ theme will appear in the theme selection dialog.
201
+ - Or, set it as the default by adding `"theme": "MyCustomTheme"` to the `ui`
202
+ object in your `settings.json`.
203
+ - Custom themes can be set at the user, project, or system level, and follow the
204
+ same [configuration precedence](../reference/configuration.md) as other
205
+ settings.
206
+
207
+ ### Themes from extensions
208
+
209
+ [Extensions](../extensions/reference.md#themes) can also provide custom themes.
210
+ Once an extension is installed and enabled, its themes are automatically added
211
+ to the selection list in the `/theme` command.
212
+
213
+ Themes from extensions appear with the extension name in parentheses to help you
214
+ identify their source, for example: `shades-of-green (green-extension)`.
215
+
216
+ ---
217
+
218
+ ## Dark themes
219
+
220
+ ### ANSI
221
+
222
+ <img src="/docs/assets/theme-ansi-dark.png" alt="ANSI theme" width="600">
223
+
224
+ ### Atom One
225
+
226
+ <img src="/docs/assets/theme-atom-one-dark.png" alt="Atom One theme" width="600">
227
+
228
+ ### Ayu
229
+
230
+ <img src="/docs/assets/theme-ayu-dark.png" alt="Ayu theme" width="600">
231
+
232
+ ### Default
233
+
234
+ <img src="/docs/assets/theme-default-dark.png" alt="Default theme" width="600">
235
+
236
+ ### Dracula
237
+
238
+ <img src="/docs/assets/theme-dracula-dark.png" alt="Dracula theme" width="600">
239
+
240
+ ### GitHub
241
+
242
+ <img src="/docs/assets/theme-github-dark.png" alt="GitHub theme" width="600">
243
+
244
+ ### Holiday
245
+
246
+ <img src="/docs/assets/theme-holiday-dark.png" alt="Holiday theme" width="600">
247
+
248
+ ### Shades Of Purple
249
+
250
+ <img src="/docs/assets/theme-shades-of-purple-dark.png" alt="Shades Of Purple theme" width="600">
251
+
252
+ ### Solarized Dark
253
+
254
+ <img src="/docs/assets/theme-solarized-dark.png" alt="Solarized Dark theme" width="600">
255
+
256
+ ### Tokyo Night
257
+
258
+ <img src="/docs/assets/theme-tokyonight-dark.png" alt="Tokyo Night theme" width="600">
259
+
260
+ ## Light themes
261
+
262
+ ### ANSI Light
263
+
264
+ <img src="/docs/assets/theme-ansi-light.png" alt="ANSI Light theme" width="600">
265
+
266
+ ### Ayu Light
267
+
268
+ <img src="/docs/assets/theme-ayu-light.png" alt="Ayu Light theme" width="600">
269
+
270
+ ### Default Light
271
+
272
+ <img src="/docs/assets/theme-default-light.png" alt="Default Light theme" width="600">
273
+
274
+ ### GitHub Light
275
+
276
+ <img src="/docs/assets/theme-github-light.png" alt="GitHub Light theme" width="600">
277
+
278
+ ### Google Code
279
+
280
+ <img src="/docs/assets/theme-google-light.png" alt="Google Code theme" width="600">
281
+
282
+ ### Solarized Light
283
+
284
+ <img src="/docs/assets/theme-solarized-light.png" alt="Solarized Light theme" width="600">
285
+
286
+ ### Xcode
287
+
288
+ <img src="/docs/assets/theme-xcode-light.png" alt="Xcode Light theme" width="600">
docs/cli/token-caching.md ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Token caching and cost optimization
2
+
3
+ Gemini CLI automatically optimizes API costs through token caching when using
4
+ API key authentication (Gemini API key or Vertex AI). This feature reuses
5
+ previous system instructions and context to reduce the number of tokens
6
+ processed in subsequent requests.
7
+
8
+ **Token caching is available for:**
9
+
10
+ - API key users (Gemini API key)
11
+ - Vertex AI users (with project and location setup)
12
+
13
+ **Token caching is not available for:**
14
+
15
+ - OAuth users (Google Personal/Enterprise accounts) - the Code Assist API does
16
+ not support cached content creation at this time
17
+
18
+ You can view your token usage and cached token savings using the `/stats`
19
+ command. When cached tokens are available, they will be displayed in the stats
20
+ output.
docs/cli/trusted-folders.md ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Trusted Folders
2
+
3
+ The Trusted Folders feature is a security setting that gives you control over
4
+ which projects can use the full capabilities of Gemini CLI. It prevents
5
+ potentially malicious code from running by asking you to approve a folder before
6
+ the CLI loads any project-specific configurations from it.
7
+
8
+ ## Enabling the feature
9
+
10
+ The Trusted Folders feature is **disabled by default**. To use it, you must
11
+ first enable it in your settings.
12
+
13
+ Add the following to your user `settings.json` file:
14
+
15
+ ```json
16
+ {
17
+ "security": {
18
+ "folderTrust": {
19
+ "enabled": true
20
+ }
21
+ }
22
+ }
23
+ ```
24
+
25
+ ## How it works: The trust dialog
26
+
27
+ Once the feature is enabled, the first time you run Gemini CLI from a folder, a
28
+ dialog will automatically appear, prompting you to make a choice:
29
+
30
+ - **Trust folder**: Grants full trust to the current folder (for example,
31
+ `my-project`).
32
+ - **Trust parent folder**: Grants trust to the parent directory (for example,
33
+ `safe-projects`), which automatically trusts all of its subdirectories as
34
+ well. This is useful if you keep all your safe projects in one place.
35
+ - **Don't trust**: Marks the folder as untrusted. The CLI will operate in a
36
+ restricted "safe mode."
37
+
38
+ Your choice is saved in a central file (`~/.gemini/trustedFolders.json`), so you
39
+ will only be asked once per folder.
40
+
41
+ ## Understanding folder contents: The discovery phase
42
+
43
+ Before you make a choice, Gemini CLI performs a **discovery phase** to scan the
44
+ folder for potential configurations. This information is displayed in the trust
45
+ dialog to help you make an informed decision.
46
+
47
+ The discovery UI lists the following categories of items found in the project:
48
+
49
+ - **Commands**: Custom `.toml` command definitions that add new functionality.
50
+ - **MCP Servers**: Configured Model Context Protocol servers that the CLI will
51
+ attempt to connect to.
52
+ - **Hooks**: System or custom hooks that can intercept and modify CLI behavior.
53
+ - **Skills**: Local agent skills that provide specialized capabilities.
54
+ - **Setting overrides**: Any project-specific configurations that override your
55
+ global user settings.
56
+
57
+ ### Security warnings and errors
58
+
59
+ The trust dialog also highlights critical information that requires your
60
+ attention:
61
+
62
+ - **Security Warnings**: The CLI will explicitly flag potentially dangerous
63
+ settings, such as auto-approving certain tools or disabling the security
64
+ sandbox.
65
+ - **Discovery Errors**: If the CLI encounters issues while scanning the folder
66
+ (for example, a malformed `settings.json` file), these errors will be
67
+ displayed prominently.
68
+
69
+ By reviewing these details, you can ensure that you only grant trust to projects
70
+ that you know are safe.
71
+
72
+ ## Why trust matters: The impact of an untrusted workspace
73
+
74
+ When a folder is **untrusted**, Gemini CLI runs in a restricted "safe mode" to
75
+ protect you. In this mode, the following features are disabled:
76
+
77
+ 1. **Workspace settings are ignored**: The CLI will **not** load the
78
+ `.gemini/settings.json` file from the project. This prevents the loading of
79
+ custom tools and other potentially dangerous configurations.
80
+
81
+ 2. **Environment variables are ignored**: The CLI will **not** load any `.env`
82
+ files from the project.
83
+
84
+ 3. **Extension management is restricted**: You **cannot install, update, or
85
+ uninstall** extensions.
86
+
87
+ 4. **Tool auto-acceptance is disabled**: You will always be prompted before any
88
+ tool is run, even if you have auto-acceptance enabled globally.
89
+
90
+ 5. **Automatic memory loading is disabled**: The CLI will not automatically
91
+ load files into context from directories specified in local settings.
92
+
93
+ 6. **MCP servers do not connect**: The CLI will not attempt to connect to any
94
+ [Model Context Protocol (MCP)](../tools/mcp-server.md) servers.
95
+
96
+ 7. **Custom commands are not loaded**: The CLI will not load any custom
97
+ commands from .toml files, including both project-specific and global user
98
+ commands.
99
+
100
+ Granting trust to a folder unlocks the full functionality of Gemini CLI for that
101
+ workspace.
102
+
103
+ ## Headless and automated environments
104
+
105
+ When running Gemini CLI in a headless environment (for example, a CI/CD
106
+ pipeline) where interactive prompts are not possible, the trust dialog cannot be
107
+ displayed. If the folder is untrusted and the Folder Trust feature is enabled,
108
+ the CLI will throw a `FatalUntrustedWorkspaceError` and exit.
109
+
110
+ To proceed in these environments, you can bypass the trust check using one of
111
+ the following methods:
112
+
113
+ - **Command-line flag:** Run the CLI with the `--skip-trust` flag.
114
+ - **Environment variable:** Set the `GEMINI_CLI_TRUST_WORKSPACE=true`
115
+ environment variable.
116
+
117
+ These methods will trust the current workspace for the duration of the session
118
+ without prompting.
119
+
120
+ For detailed instructions on managing folder trust within CI/CD workflows,
121
+ review the
122
+ [Gemini CLI trust guidance for GitHub Actions](https://github.com/google-github-actions/run-gemini-cli/blob/main/docs/trust-guidance.md).
123
+
124
+ ## Overriding the trust file location
125
+
126
+ By default, trust settings are saved to `~/.gemini/trustedFolders.json`. If you
127
+ need to store this file in a different location, you can set the
128
+ `GEMINI_CLI_TRUSTED_FOLDERS_PATH` environment variable to the desired absolute
129
+ file path.
130
+
131
+ ## Managing your trust settings
132
+
133
+ If you need to change a decision or see all your settings, you have a couple of
134
+ options:
135
+
136
+ - **Change the current folder's trust**: Run the `/permissions` command from
137
+ within the CLI. This will bring up the same interactive dialog, allowing you
138
+ to change the trust level for the current folder.
139
+
140
+ - **View all trust rules**: To see a complete list of all your trusted and
141
+ untrusted folder rules, you can inspect the contents of the
142
+ `~/.gemini/trustedFolders.json` file in your home directory.
143
+
144
+ ## The trust check process (advanced)
145
+
146
+ For advanced users, it's helpful to know the exact order of operations for how
147
+ trust is determined:
148
+
149
+ 1. **IDE trust signal**: If you are using the
150
+ [IDE Integration](../ide-integration/index.md), the CLI first asks the IDE
151
+ if the workspace is trusted. The IDE's response takes highest priority.
152
+
153
+ 2. **Local trust file**: If the IDE is not connected, the CLI checks the
154
+ central `~/.gemini/trustedFolders.json` file.
docs/cli/using-agent-skills.md ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Managing Agent Skills
2
+
3
+ Agent Skills provide Gemini CLI with specialized expertise on demand. This guide
4
+ covers advanced management techniques, including using slash commands, terminal
5
+ utilities, and understanding discovery tiers.
6
+
7
+ ## Discovery tiers
8
+
9
+ Gemini CLI discovers skills from several locations, following a specific order
10
+ of precedence (lowest to highest):
11
+
12
+ 1. **Built-in Skills**: Included with Gemini CLI and always available.
13
+ 2. **Extension Skills**: Bundled within [extensions](../extensions/index.md).
14
+ 3. **User Skills**: Located in `~/.gemini/skills/` or the `~/.agents/skills/`
15
+ alias. These are available across all your projects.
16
+ 4. **Workspace Skills**: Located in `.gemini/skills/` or the `.agents/skills/`
17
+ alias within your current directory. These are project-specific.
18
+
19
+ > **Tip:** If multiple skills share the same name, the version from the
20
+ > higher-precedence location is used.
21
+
22
+ ## In-session management
23
+
24
+ Use the `/skills` slash command during an interactive session to manage your
25
+ available expertise.
26
+
27
+ - **List skills**: `/skills list` (shows discovered skills).
28
+ - Use `/skills list all` to include internal built-in skills.
29
+ - Use `/skills list nodesc` to hide descriptions.
30
+ - **Reload skills**: `/skills reload` (or `/skills refresh`) to scan for new or
31
+ modified skills without restarting the CLI.
32
+ - **Toggle status**:
33
+ - `/skills disable <name>`: Prevents a skill from being triggered.
34
+ - `/skills enable <name>`: Re-enables a disabled skill.
35
+ - **Link local skills**: `/skills link <path> [--scope user|workspace]` to
36
+ immediately use a skill you are developing.
37
+
38
+ ## Terminal utilities
39
+
40
+ The `gemini skills` command provides management utilities directly from your
41
+ system shell.
42
+
43
+ ### Install a skill
44
+
45
+ To install a skill from a remote repository or a local `.skill` package:
46
+
47
+ ```bash
48
+ gemini skills install https://github.com/user/my-awesome-skill
49
+ ```
50
+
51
+ By default, this installs to your **user profile**. Use `--scope workspace` to
52
+ install it only for the current project.
53
+
54
+ ### Link for development
55
+
56
+ If you are developing a skill, use the `link` command to create a reference to
57
+ your local directory:
58
+
59
+ ```bash
60
+ gemini skills link ./path/to/my-skill
61
+ ```
62
+
63
+ ### Uninstall a skill
64
+
65
+ To completely remove an installed or linked skill:
66
+
67
+ ```bash
68
+ gemini skills uninstall <name>
69
+ ```
70
+
71
+ ## Security and consent
72
+
73
+ Agent Skills can execute scripts and access your files. To protect your
74
+ environment:
75
+
76
+ 1. **Installation consent**: When installing from a remote URL, you will be
77
+ asked to confirm the source.
78
+ 2. **Activation consent**: Every time a skill is triggered during a session,
79
+ the agent must ask for permission to activate it and gain access to its
80
+ resources.
81
+
82
+ ## Next steps
83
+
84
+ - [Get started with Agent Skills](./tutorials/skills-getting-started.md): A
85
+ walkthrough for creating your first skill.
86
+ - [Creating Agent Skills](./creating-skills.md): Detailed guide on bundling
87
+ scripts and assets.
88
+ - [Skill best practices](./skills-best-practices.md): Strategies for building
89
+ reliable expertise.
docs/core/gemma-setup.md ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # `gemini gemma` — Automated Local Model Routing Setup
2
+
3
+ Local model routing uses a local Gemma 3 1B model running on your machine to
4
+ classify and route user requests. It routes simple requests (like file reads) to
5
+ Gemini Flash and complex requests (like architecture discussions) to Gemini Pro.
6
+
7
+ <!-- prettier-ignore -->
8
+ > [!NOTE]
9
+ > This is an experimental feature currently under active development.
10
+
11
+ ## What is this?
12
+
13
+ This feature saves cloud API costs by using local inference for task
14
+ classification instead of a cloud-based classifier. It adds a few milliseconds
15
+ of local latency but can significantly reduce the overall token usage for hosted
16
+ models.
17
+
18
+ ## Quick start
19
+
20
+ ```bash
21
+ # One command does everything: downloads runtime, pulls model, configures settings, starts server
22
+ gemini gemma setup
23
+ ```
24
+
25
+ You'll be prompted to accept the Gemma Terms of Use. The model is ~1 GB.
26
+
27
+ After setup, **just use the CLI normally** — routing happens automatically on
28
+ every request.
29
+
30
+ ## Commands
31
+
32
+ | Command | What it does |
33
+ | --------------------- | -------------------------------------------------------------- |
34
+ | `gemini gemma setup` | Full install (binary + model + settings + server start) |
35
+ | `gemini gemma status` | Health check — shows what's installed and running |
36
+ | `gemini gemma start` | Start the LiteRT server (auto-starts on CLI launch by default) |
37
+ | `gemini gemma stop` | Stop the LiteRT server |
38
+ | `gemini gemma logs` | Tail the server logs to see routing requests live |
39
+ | `/gemma` | In-session status check (type it inside the CLI) |
40
+
41
+ ## Verifying it works
42
+
43
+ 1. Run `gemini gemma status` — all checks should show green
44
+ 2. Open two terminals:
45
+ - Terminal 1: `gemini gemma logs` (watch for incoming requests)
46
+ - Terminal 2: use the CLI normally
47
+ 3. You should see classification requests appear in the logs as you interact
48
+ with the CLI
49
+ 4. The `/gemma` slash command inside a session shows a quick status panel
50
+
51
+ ## Setup flags
52
+
53
+ ```bash
54
+ gemini gemma setup --port 8080 # custom port
55
+ gemini gemma setup --no-start # don't start server after install
56
+ gemini gemma setup --force # re-download everything
57
+ gemini gemma setup --skip-model # binary only, skip the 1GB model download
58
+ ```
59
+
60
+ ## How it works under the hood
61
+
62
+ - Local Gemma classifies each request as "simple" or "complex" (~100ms)
63
+ - Simple → Flash, Complex → Pro
64
+ - If the local server is down, the CLI silently falls back to the cloud
65
+ classifier — no errors, no disruption
66
+
67
+ ## Disabling
68
+
69
+ Set `enabled: false` in settings or just run `gemini gemma stop` to turn off the
70
+ server:
71
+
72
+ ```json
73
+ { "experimental": { "gemmaModelRouter": { "enabled": false } } }
74
+ ```
75
+
76
+ ## Advanced setup
77
+
78
+ If you are in an environment where the `gemini gemma setup` command cannot
79
+ automatically download binaries (for example, behind a strict corporate
80
+ firewall), you can perform the setup manually.
81
+
82
+ For more information, see the
83
+ [Manual Local Model Routing Setup guide](./local-model-routing.md).
docs/core/index.md ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Gemini CLI core
2
+
3
+ Gemini CLI's core package (`packages/core`) is the backend portion of Gemini
4
+ CLI, handling communication with the Gemini API, managing tools, and processing
5
+ requests sent from `packages/cli`. For a general overview of Gemini CLI, see the
6
+ [main documentation page](../index.md).
7
+
8
+ ## Navigating this section
9
+
10
+ - **[Sub-agents](./subagents.md):** Learn how to create and use specialized
11
+ sub-agents for complex tasks.
12
+ - **[Core tools reference](../reference/tools.md):** Information on how tools
13
+ are defined, registered, and used by the core.
14
+ - **[Memory Import Processor](../reference/memport.md):** Documentation for the
15
+ modular GEMINI.md import feature using @file.md syntax.
16
+ - **[Policy Engine](../reference/policy-engine.md):** Use the Policy Engine for
17
+ fine-grained control over tool execution.
18
+ - **[Local Model Routing (experimental)](./gemma-setup.md):** Learn how to
19
+ enable use of a local Gemma model for model routing decisions using the
20
+ automated setup command.
21
+
22
+ ## Role of the core
23
+
24
+ While the `packages/cli` portion of Gemini CLI provides the user interface,
25
+ `packages/core` is responsible for:
26
+
27
+ - **Gemini API interaction:** Securely communicating with the Google Gemini API,
28
+ sending user prompts, and receiving model responses.
29
+ - **Prompt engineering:** Constructing effective prompts for the Gemini model,
30
+ potentially incorporating conversation history, tool definitions, and
31
+ instructional context from `GEMINI.md` files.
32
+ - **Tool management & orchestration:**
33
+ - Registering available tools (for example, file system tools, shell command
34
+ execution).
35
+ - Interpreting tool use requests from the Gemini model.
36
+ - Executing the requested tools with the provided arguments.
37
+ - Returning tool execution results to the Gemini model for further processing.
38
+ - **Session and state management:** Keeping track of the conversation state,
39
+ including history and any relevant context required for coherent interactions.
40
+ - **Configuration:** Managing core-specific configurations, such as API key
41
+ access, model selection, and tool settings.
42
+
43
+ ## Security considerations
44
+
45
+ The core plays a vital role in security:
46
+
47
+ - **API key management:** It handles the `GEMINI_API_KEY` and ensures it's used
48
+ securely when communicating with the Gemini API.
49
+ - **Tool execution:** When tools interact with the local system (for example,
50
+ `run_shell_command`), the core (and its underlying tool implementations) must
51
+ do so with appropriate caution, often involving sandboxing mechanisms to
52
+ prevent unintended modifications.
53
+
54
+ ## Chat history compression
55
+
56
+ To ensure that long conversations don't exceed the token limits of the Gemini
57
+ model, the core includes a chat history compression feature.
58
+
59
+ When a conversation approaches the token limit for the configured model, the
60
+ core automatically compresses the conversation history before sending it to the
61
+ model. This compression is designed to be lossless in terms of the information
62
+ conveyed, but it reduces the overall number of tokens used.
63
+
64
+ You can find the token limits for each model in the
65
+ [Google AI documentation](https://ai.google.dev/gemini-api/docs/models).
66
+
67
+ ## Model fallback
68
+
69
+ Gemini CLI includes a model fallback mechanism to ensure that you can continue
70
+ to use the CLI even if the default "pro" model is rate-limited.
71
+
72
+ If you are using the default "pro" model and the CLI detects that you are being
73
+ rate-limited, it automatically switches to the "flash" model for the current
74
+ session. This lets you continue working without interruption.
75
+
76
+ Internal utility calls that use `gemini-2.5-flash-lite` (for example, prompt
77
+ completion and classification) silently fall back to `gemini-2.5-flash` and
78
+ `gemini-2.5-pro` when quota is exhausted, without changing the configured model.
79
+
80
+ ## File discovery service
81
+
82
+ The file discovery service is responsible for finding files in the project that
83
+ are relevant to the current context. It is used by the `@` command and other
84
+ tools that need to access files.
85
+
86
+ ## Memory discovery service
87
+
88
+ The memory discovery service is responsible for finding and loading the
89
+ `GEMINI.md` files that provide context to the model. It searches for these files
90
+ in a hierarchical manner, starting from the current working directory and moving
91
+ up to the project root and the user's home directory. It also searches in
92
+ subdirectories.
93
+
94
+ This lets you have global, project-level, and component-level context files,
95
+ which are all combined to provide the model with the most relevant information.
96
+
97
+ You can use the [`/memory` command](../reference/commands.md) to `show`, `add`,
98
+ and `refresh` the content of loaded `GEMINI.md` files.
99
+
100
+ ## Citations
101
+
102
+ When Gemini finds it is reciting text from a source it appends the citation to
103
+ the output. It is enabled by default but can be disabled with the
104
+ ui.showCitations setting.
105
+
106
+ - When proposing an edit the citations display before giving the user the option
107
+ to accept.
108
+ - Citations are always shown at the end of the model’s turn.
109
+ - We deduplicate citations and display them in alphabetical order.
docs/core/local-model-routing.md ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Manual Local Model Routing Setup (experimental)
2
+
3
+ Gemini CLI supports using a local model for
4
+ [routing decisions](../cli/model-routing.md). When configured, Gemini CLI will
5
+ use a locally-running **Gemma** model to make routing decisions (instead of
6
+ sending routing decisions to a hosted model).
7
+
8
+ <!-- prettier-ignore -->
9
+ > [!NOTE]
10
+ > This is an experimental feature currently under active development.
11
+
12
+ <!-- prettier-ignore -->
13
+ > [!IMPORTANT]
14
+ > **Recommended:** We now provide a fully automated setup command. We recommend
15
+ > using the [`gemini gemma` Setup Guide](./gemma-setup.md) instead of following
16
+ > these manual steps.
17
+
18
+ This feature can help reduce costs associated with hosted model usage while
19
+ offering similar routing decision latency and quality.
20
+
21
+ ## Manual Setup
22
+
23
+ Using a Gemma model for routing decisions requires that an implementation of a
24
+ Gemma model be running locally on your machine, served behind an HTTP endpoint
25
+ and accessed via the Gemini API. If you cannot use the `gemini gemma setup`
26
+ command, follow these manual steps:
27
+
28
+ ### Download the LiteRT-LM runtime
29
+
30
+ The [LiteRT-LM](https://github.com/google-ai-edge/LiteRT-LM) runtime offers
31
+ pre-built binaries for locally-serving models. Download the binary appropriate
32
+ for your system.
33
+
34
+ #### Windows
35
+
36
+ 1. Download
37
+ [lit.windows_x86_64.exe](https://github.com/google-ai-edge/LiteRT-LM/releases/download/v0.9.0-alpha03/lit.windows_x86_64.exe).
38
+ 2. Using GPU on Windows requires the DirectXShaderCompiler. Download the
39
+ [dxc zip from the latest release](https://github.com/microsoft/DirectXShaderCompiler/releases/download/v1.8.2505.1/dxc_2025_07_14.zip).
40
+ Unzip the archive and from the architecture-appropriate `bin\` directory, and
41
+ copy the `dxil.dll` and `dxcompiler.dll` into the same location as you saved
42
+ `lit.windows_x86_64.exe`.
43
+ 3. (Optional) Test starting the runtime:
44
+ `.\lit.windows_x86_64.exe serve --verbose`
45
+
46
+ #### Linux
47
+
48
+ 1. Download
49
+ [lit.linux_x86_64](https://github.com/google-ai-edge/LiteRT-LM/releases/download/v0.9.0-alpha03/lit.linux_x86_64).
50
+ 2. Ensure the binary is executable: `chmod a+x lit.linux_x86_64`
51
+ 3. (Optional) Test starting the runtime: `./lit.linux_x86_64 serve --verbose`
52
+
53
+ #### MacOS
54
+
55
+ 1. Download
56
+ [lit-macos-arm64](https://github.com/google-ai-edge/LiteRT-LM/releases/download/v0.9.0-alpha03/lit.macos_arm64).
57
+ 2. Ensure the binary is executable: `chmod a+x lit.macos_arm64`
58
+ 3. (Optional) Test starting the runtime: `./lit.macos_arm64 serve --verbose`
59
+
60
+ > **Note**: MacOS can be configured to only allows binaries from "App Store &
61
+ > Known Developers". If you encounter an error message when attempting to run
62
+ > the binary, you will need to allow the application. One option is to visit
63
+ > `System Settings -> Privacy & Security`, scroll to `Security`, and click
64
+ > `"Allow Anyway"` for `"lit.macos_arm64"`. Another option is to run
65
+ > `xattr -d com.apple.quarantine lit.macos_arm64` from the commandline.
66
+
67
+ ### Download the Gemma Model
68
+
69
+ Before using Gemma, you will need to download the model (and agree to the Terms
70
+ of Service).
71
+
72
+ This can be done via the LiteRT-LM runtime.
73
+
74
+ #### Windows
75
+
76
+ ```bash
77
+ $ .\lit.windows_x86_64.exe pull gemma3-1b-gpu-custom
78
+
79
+ [Legal] The model you are about to download is governed by
80
+ the Gemma Terms of Use and Prohibited Use Policy. Please review these terms and ensure you agree before continuing.
81
+
82
+ Full Terms: https://ai.google.dev/gemma/terms
83
+ Prohibited Use Policy: https://ai.google.dev/gemma/prohibited_use_policy
84
+
85
+ Do you accept these terms? (Y/N): Y
86
+
87
+ Terms accepted.
88
+ Downloading model 'gemma3-1b-gpu-custom' ...
89
+ Downloading... 968.6 MB
90
+ Download complete.
91
+ ```
92
+
93
+ #### Linux
94
+
95
+ ```bash
96
+ $ ./lit.linux_x86_64 pull gemma3-1b-gpu-custom
97
+
98
+ [Legal] The model you are about to download is governed by
99
+ the Gemma Terms of Use and Prohibited Use Policy. Please review these terms and ensure you agree before continuing.
100
+
101
+ Full Terms: https://ai.google.dev/gemma/terms
102
+ Prohibited Use Policy: https://ai.google.dev/gemma/prohibited_use_policy
103
+
104
+ Do you accept these terms? (Y/N): Y
105
+
106
+ Terms accepted.
107
+ Downloading model 'gemma3-1b-gpu-custom' ...
108
+ Downloading... 968.6 MB
109
+ Download complete.
110
+ ```
111
+
112
+ #### MacOS
113
+
114
+ ```bash
115
+ $ ./lit.lit.macos_arm64 pull gemma3-1b-gpu-custom
116
+
117
+ [Legal] The model you are about to download is governed by
118
+ the Gemma Terms of Use and Prohibited Use Policy. Review these terms and ensure you agree before continuing.
119
+
120
+ Full Terms: https://ai.google.dev/gemma/terms
121
+ Prohibited Use Policy: https://ai.google.dev/gemma/prohibited_use_policy
122
+
123
+ Do you accept these terms? (Y/N): Y
124
+
125
+ Terms accepted.
126
+ Downloading model 'gemma3-1b-gpu-custom' ...
127
+ Downloading... 968.6 MB
128
+ Download complete.
129
+ ```
130
+
131
+ ### Start LiteRT-LM Runtime
132
+
133
+ Using the command appropriate to your system, start the LiteRT-LM runtime.
134
+ Configure the port that you want to use for your Gemma model. For the purposes
135
+ of this document, we will use port `9379`.
136
+
137
+ Example command for MacOS: `./lit.macos_arm64 serve --port=9379 --verbose`
138
+
139
+ ### (Optional) Verify Model Serving
140
+
141
+ Send a quick prompt to the model via HTTP to validate successful model serving.
142
+ This will cause the runtime to download the model and run it once.
143
+
144
+ You should see a short joke in the server output as an indicator of success.
145
+
146
+ #### Windows
147
+
148
+ ```
149
+ # Run this in PowerShell to send a request to the server
150
+
151
+ $uri = "http://localhost:9379/v1beta/models/gemma3-1b-gpu-custom:generateContent"
152
+ $body = @{contents = @( @{
153
+ role = "user"
154
+ parts = @( @{ text = "Tell me a joke." } )
155
+ })} | ConvertTo-Json -Depth 10
156
+
157
+ Invoke-RestMethod -Uri $uri -Method Post -Body $body -ContentType "application/json"
158
+ ```
159
+
160
+ #### Linux/MacOS
161
+
162
+ ```bash
163
+ $ curl "http://localhost:9379/v1beta/models/gemma3-1b-gpu-custom:generateContent" \
164
+ -H 'Content-Type: application/json' \
165
+ -X POST \
166
+ -d '{"contents":[{"role":"user","parts":[{"text":"Tell me a joke."}]}]}'
167
+ ```
168
+
169
+ ## Configuration
170
+
171
+ To use a local Gemma model for routing, you must explicitly enable it in your
172
+ `settings.json`:
173
+
174
+ ```json
175
+ {
176
+ "experimental": {
177
+ "gemmaModelRouter": {
178
+ "enabled": true,
179
+ "classifier": {
180
+ "host": "http://localhost:9379",
181
+ "model": "gemma3-1b-gpu-custom"
182
+ }
183
+ }
184
+ }
185
+ }
186
+ ```
187
+
188
+ > Use the port you started your LiteRT-LM runtime on in the setup steps.
189
+
190
+ ### Configuration schema
191
+
192
+ | Field | Type | Required | Description |
193
+ | :----------------- | :------ | :------- | :----------------------------------------------------------------------------------------- |
194
+ | `enabled` | boolean | Yes | Must be `true` to enable the feature. |
195
+ | `classifier` | object | Yes | The configuration for the local model endpoint. It includes the host and model specifiers. |
196
+ | `classifier.host` | string | Yes | The URL to the local model server. Should be `http://localhost:<port>`. |
197
+ | `classifier.model` | string | Yes | The model name to use for decisions. Must be `"gemma3-1b-gpu-custom"`. |
198
+
199
+ > **Note: You will need to restart after configuration changes for local model
200
+ > routing to take effect.**
docs/core/remote-agents.md ADDED
@@ -0,0 +1,457 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Remote Subagents
2
+
3
+ Gemini CLI supports connecting to remote subagents using the Agent-to-Agent
4
+ (A2A) protocol. This allows Gemini CLI to interact with other agents, expanding
5
+ its capabilities by delegating tasks to remote services.
6
+
7
+ Gemini CLI can connect to any compliant A2A agent. You can find samples of A2A
8
+ agents in the following repositories:
9
+
10
+ - [ADK Samples (Python)](https://github.com/google/adk-samples/tree/main/python)
11
+ - [ADK Python Contributing Samples](https://github.com/google/adk-python/tree/main/contributing/samples)
12
+
13
+ ## Proxy support
14
+
15
+ Gemini CLI routes traffic to remote agents through an HTTP/HTTPS proxy if one is
16
+ configured. It uses the `general.proxy` setting in your `settings.json` file or
17
+ standard environment variables (`HTTP_PROXY`, `HTTPS_PROXY`).
18
+
19
+ ```json
20
+ {
21
+ "general": {
22
+ "proxy": "http://my-proxy:8080"
23
+ }
24
+ }
25
+ ```
26
+
27
+ ## Defining remote subagents
28
+
29
+ Remote subagents are defined as Markdown files (`.md`) with YAML frontmatter.
30
+ You can place them in:
31
+
32
+ 1. **Project-level:** `.gemini/agents/*.md` (Shared with your team)
33
+ 2. **User-level:** `~/.gemini/agents/*.md` (Personal agents)
34
+
35
+ ### Configuration schema
36
+
37
+ | Field | Type | Required | Description |
38
+ | :---------------- | :----- | :------- | :------------------------------------------------------------------------------------------------------------- |
39
+ | `kind` | string | Yes | Must be `remote`. |
40
+ | `name` | string | Yes | A unique name for the agent. Must be a valid slug (lowercase letters, numbers, hyphens, and underscores only). |
41
+ | `agent_card_url` | string | Yes\* | The URL to the agent's A2A card endpoint. Required if `agent_card_json` is not provided. |
42
+ | `agent_card_json` | string | Yes\* | The inline JSON string of the agent's A2A card. Required if `agent_card_url` is not provided. |
43
+ | `auth` | object | No | Authentication configuration. See [Authentication](#authentication). |
44
+
45
+ ### Single-subagent example
46
+
47
+ ```markdown
48
+ ---
49
+ kind: remote
50
+ name: my-remote-agent
51
+ agent_card_url: https://example.com/agent-card
52
+ ---
53
+ ```
54
+
55
+ ### Multi-subagent example
56
+
57
+ The loader explicitly supports multiple remote subagents defined in a single
58
+ Markdown file.
59
+
60
+ ```markdown
61
+ ---
62
+ - kind: remote
63
+ name: remote-1
64
+ agent_card_url: https://example.com/1
65
+ - kind: remote
66
+ name: remote-2
67
+ agent_card_url: https://example.com/2
68
+ ---
69
+ ```
70
+
71
+ <!-- prettier-ignore -->
72
+ > [!NOTE] Mixed local and remote agents, or multiple local agents, are not
73
+ > supported in a single file; the list format is currently remote-only.
74
+
75
+ ### Inline Agent Card JSON
76
+
77
+ <details>
78
+ <summary>View formatting options for JSON strings</summary>
79
+
80
+ If you don't have an endpoint serving the agent card, you can provide the A2A
81
+ card directly as a JSON string using `agent_card_json`.
82
+
83
+ When providing a JSON string in YAML, you must properly format it as a string
84
+ scalar. You can use single quotes, a block scalar, or double quotes (which
85
+ require escaping internal double quotes).
86
+
87
+ #### Using single quotes
88
+
89
+ Single quotes allow you to embed unescaped double quotes inside the JSON string.
90
+ This format is useful for shorter, single-line JSON strings.
91
+
92
+ ```markdown
93
+ ---
94
+ kind: remote
95
+ name: single-quotes-agent
96
+ agent_card_json:
97
+ '{ "protocolVersion": "0.3.0", "name": "Example Agent", "version": "1.0.0",
98
+ "url": "dummy-url" }'
99
+ ---
100
+ ```
101
+
102
+ #### Using a block scalar
103
+
104
+ The literal block scalar (`|`) preserves line breaks and is highly recommended
105
+ for multiline JSON strings as it avoids quote escaping entirely. The following
106
+ is a complete, valid Agent Card configuration using dummy values.
107
+
108
+ ```markdown
109
+ ---
110
+ kind: remote
111
+ name: block-scalar-agent
112
+ agent_card_json: |
113
+ {
114
+ "protocolVersion": "0.3.0",
115
+ "name": "Example Agent Name",
116
+ "description": "An example agent description for documentation purposes.",
117
+ "version": "1.0.0",
118
+ "url": "dummy-url",
119
+ "preferredTransport": "HTTP+JSON",
120
+ "capabilities": {
121
+ "streaming": true,
122
+ "extendedAgentCard": false
123
+ },
124
+ "defaultInputModes": [
125
+ "text/plain"
126
+ ],
127
+ "defaultOutputModes": [
128
+ "application/json"
129
+ ],
130
+ "skills": [
131
+ {
132
+ "id": "ExampleSkill",
133
+ "name": "Example Skill Assistant",
134
+ "description": "A description of what this example skill does.",
135
+ "tags": [
136
+ "example-tag"
137
+ ],
138
+ "examples": [
139
+ "Show me an example."
140
+ ]
141
+ }
142
+ ]
143
+ }
144
+ ---
145
+ ```
146
+
147
+ #### Using double quotes
148
+
149
+ Double quotes are also supported, but any internal double quotes in your JSON
150
+ must be escaped with a backslash.
151
+
152
+ ```markdown
153
+ ---
154
+ kind: remote
155
+ name: double-quotes-agent
156
+ agent_card_json:
157
+ '{ "protocolVersion": "0.3.0", "name": "Example Agent", "version": "1.0.0",
158
+ "url": "dummy-url" }'
159
+ ---
160
+ ```
161
+
162
+ </details>
163
+
164
+ ## Authentication
165
+
166
+ Many remote agents require authentication. Gemini CLI supports several
167
+ authentication methods aligned with the
168
+ [A2A security specification](https://a2a-protocol.org/latest/specification/#451-securityscheme).
169
+ Add an `auth` block to your agent's frontmatter to configure credentials.
170
+
171
+ ### Supported auth types
172
+
173
+ Gemini CLI supports the following authentication types:
174
+
175
+ | Type | Description |
176
+ | :------------------- | :--------------------------------------------------------------------------------------------- |
177
+ | `apiKey` | Send a static API key as an HTTP header. |
178
+ | `http` | HTTP authentication (Bearer token, Basic credentials, or any IANA-registered scheme). |
179
+ | `google-credentials` | Google Application Default Credentials (ADC). Automatically selects access or identity tokens. |
180
+ | `oauth` | OAuth 2.0 Authorization Code flow with PKCE. Opens a browser for interactive sign-in. |
181
+
182
+ ### Dynamic values
183
+
184
+ For `apiKey` and `http` auth types, secret values (`key`, `token`, `username`,
185
+ `password`, `value`) support dynamic resolution:
186
+
187
+ | Format | Description | Example |
188
+ | :---------- | :-------------------------------------------------- | :------------------------- |
189
+ | `$ENV_VAR` | Read from an environment variable. | `$MY_API_KEY` |
190
+ | `!command` | Execute a shell command and use the trimmed output. | `!gcloud auth print-token` |
191
+ | literal | Use the string as-is. | `sk-abc123` |
192
+ | `$$` / `!!` | Escape prefix. `$$FOO` becomes the literal `$FOO`. | `$$NOT_AN_ENV_VAR` |
193
+
194
+ > **Security tip:** Prefer `$ENV_VAR` or `!command` over embedding secrets
195
+ > directly in agent files, especially for project-level agents checked into
196
+ > version control.
197
+
198
+ ### API key (`apiKey`)
199
+
200
+ Sends an API key as an HTTP header on every request.
201
+
202
+ | Field | Type | Required | Description |
203
+ | :----- | :----- | :------- | :---------------------------------------------------- |
204
+ | `type` | string | Yes | Must be `apiKey`. |
205
+ | `key` | string | Yes | The API key value. Supports dynamic values. |
206
+ | `name` | string | No | Header name to send the key in. Default: `X-API-Key`. |
207
+
208
+ ```yaml
209
+ ---
210
+ kind: remote
211
+ name: my-agent
212
+ agent_card_url: https://example.com/agent-card
213
+ auth:
214
+ type: apiKey
215
+ key: $MY_API_KEY
216
+ ---
217
+ ```
218
+
219
+ ### HTTP authentication (`http`)
220
+
221
+ Supports Bearer tokens, Basic auth, and arbitrary IANA-registered HTTP
222
+ authentication schemes.
223
+
224
+ #### Bearer token
225
+
226
+ Use the following fields to configure a Bearer token:
227
+
228
+ | Field | Type | Required | Description |
229
+ | :------- | :----- | :------- | :----------------------------------------- |
230
+ | `type` | string | Yes | Must be `http`. |
231
+ | `scheme` | string | Yes | Must be `Bearer`. |
232
+ | `token` | string | Yes | The bearer token. Supports dynamic values. |
233
+
234
+ ```yaml
235
+ auth:
236
+ type: http
237
+ scheme: Bearer
238
+ token: $MY_BEARER_TOKEN
239
+ ```
240
+
241
+ #### Basic authentication
242
+
243
+ Use the following fields to configure Basic authentication:
244
+
245
+ | Field | Type | Required | Description |
246
+ | :--------- | :----- | :------- | :------------------------------------- |
247
+ | `type` | string | Yes | Must be `http`. |
248
+ | `scheme` | string | Yes | Must be `Basic`. |
249
+ | `username` | string | Yes | The username. Supports dynamic values. |
250
+ | `password` | string | Yes | The password. Supports dynamic values. |
251
+
252
+ ```yaml
253
+ auth:
254
+ type: http
255
+ scheme: Basic
256
+ username: $MY_USERNAME
257
+ password: $MY_PASSWORD
258
+ ```
259
+
260
+ #### Raw scheme
261
+
262
+ For any other IANA-registered scheme (for example, Digest, HOBA), provide the
263
+ raw authorization value.
264
+
265
+ | Field | Type | Required | Description |
266
+ | :------- | :----- | :------- | :---------------------------------------------------------------------------- |
267
+ | `type` | string | Yes | Must be `http`. |
268
+ | `scheme` | string | Yes | The scheme name (for example, `Digest`). |
269
+ | `value` | string | Yes | Raw value sent as `Authorization: <scheme> <value>`. Supports dynamic values. |
270
+
271
+ ```yaml
272
+ auth:
273
+ type: http
274
+ scheme: Digest
275
+ value: $MY_DIGEST_VALUE
276
+ ```
277
+
278
+ ### Google Application Default Credentials (`google-credentials`)
279
+
280
+ Uses
281
+ [Google Application Default Credentials (ADC)](https://cloud.google.com/docs/authentication/application-default-credentials)
282
+ to authenticate with Google Cloud services and Cloud Run endpoints. This is the
283
+ recommended auth method for agents hosted on Google Cloud infrastructure.
284
+
285
+ | Field | Type | Required | Description |
286
+ | :------- | :------- | :------- | :-------------------------------------------------------------------------- |
287
+ | `type` | string | Yes | Must be `google-credentials`. |
288
+ | `scopes` | string[] | No | OAuth scopes. Defaults to `https://www.googleapis.com/auth/cloud-platform`. |
289
+
290
+ ```yaml
291
+ ---
292
+ kind: remote
293
+ name: my-gcp-agent
294
+ agent_card_url: https://my-agent-xyz.run.app/.well-known/agent.json
295
+ auth:
296
+ type: google-credentials
297
+ ---
298
+ ```
299
+
300
+ #### How token selection works
301
+
302
+ The provider automatically selects the correct token type based on the agent's
303
+ host:
304
+
305
+ | Host pattern | Token type | Use case |
306
+ | :----------------- | :----------------- | :------------------------------------------ |
307
+ | `*.googleapis.com` | **Access token** | Google APIs (Agent Engine, Vertex AI, etc.) |
308
+ | `*.run.app` | **Identity token** | Cloud Run services |
309
+
310
+ - **Access tokens** authorize API calls to Google services. They are scoped
311
+ (default: `cloud-platform`) and fetched via `GoogleAuth.getClient()`.
312
+ - **Identity tokens** prove the caller's identity to a service that validates
313
+ the token's audience. The audience is set to the target host. These are
314
+ fetched via `GoogleAuth.getIdTokenClient()`.
315
+
316
+ Both token types are cached and automatically refreshed before expiry.
317
+
318
+ #### Setup
319
+
320
+ `google-credentials` relies on ADC, which means your environment must have
321
+ credentials configured. Common setups:
322
+
323
+ - **Local development:** Run `gcloud auth application-default login` to
324
+ authenticate with your Google account.
325
+ - **CI / Cloud environments:** Use a service account. Set the
326
+ `GOOGLE_APPLICATION_CREDENTIALS` environment variable to the path of your
327
+ service account key file, or use workload identity on GKE / Cloud Run.
328
+
329
+ #### Allowed hosts
330
+
331
+ For security, `google-credentials` only sends tokens to known Google-owned
332
+ hosts:
333
+
334
+ - `*.googleapis.com`
335
+ - `*.run.app`
336
+
337
+ Requests to any other host will be rejected with an error. If your agent is
338
+ hosted on a different domain, use one of the other auth types (`apiKey`, `http`,
339
+ or `oauth`).
340
+
341
+ #### Examples
342
+
343
+ The following examples demonstrate how to configure Google Application Default
344
+ Credentials.
345
+
346
+ **Cloud Run agent:**
347
+
348
+ ```yaml
349
+ ---
350
+ kind: remote
351
+ name: cloud-run-agent
352
+ agent_card_url: https://my-agent-xyz.run.app/.well-known/agent.json
353
+ auth:
354
+ type: google-credentials
355
+ ---
356
+ ```
357
+
358
+ **Google API with custom scopes:**
359
+
360
+ ```yaml
361
+ ---
362
+ kind: remote
363
+ name: vertex-agent
364
+ agent_card_url: https://us-central1-aiplatform.googleapis.com/.well-known/agent.json
365
+ auth:
366
+ type: google-credentials
367
+ scopes:
368
+ - https://www.googleapis.com/auth/cloud-platform
369
+ - https://www.googleapis.com/auth/compute
370
+ ---
371
+ ```
372
+
373
+ ### OAuth 2.0 (`oauth`)
374
+
375
+ Performs an interactive OAuth 2.0 Authorization Code flow with PKCE. On first
376
+ use, Gemini CLI opens your browser for sign-in and persists the resulting tokens
377
+ for subsequent requests.
378
+
379
+ | Field | Type | Required | Description |
380
+ | :------------------ | :------- | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------- |
381
+ | `type` | string | Yes | Must be `oauth`. |
382
+ | `client_id` | string | Yes\* | OAuth client ID. Required for interactive auth. |
383
+ | `client_secret` | string | No\* | OAuth client secret. Required by most authorization servers (confidential clients). Can be omitted for public clients that don't require a secret. |
384
+ | `scopes` | string[] | No | Requested scopes. Can also be discovered from the agent card. |
385
+ | `authorization_url` | string | No | Authorization endpoint. Discovered from the agent card if omitted. |
386
+ | `token_url` | string | No | Token endpoint. Discovered from the agent card if omitted. |
387
+
388
+ ```yaml
389
+ ---
390
+ kind: remote
391
+ name: oauth-agent
392
+ agent_card_url: https://example.com/.well-known/agent.json
393
+ auth:
394
+ type: oauth
395
+ client_id: my-client-id.apps.example.com
396
+ ---
397
+ ```
398
+
399
+ If the agent card advertises an `oauth2` security scheme with
400
+ `authorizationCode` flow, the `authorization_url`, `token_url`, and `scopes` are
401
+ automatically discovered. You only need to provide `client_id` (and
402
+ `client_secret` if required).
403
+
404
+ Tokens are persisted to disk and refreshed automatically when they expire.
405
+
406
+ ### Auth validation
407
+
408
+ When Gemini CLI loads a remote agent, it validates your auth configuration
409
+ against the agent card's declared `securitySchemes`. If the agent requires
410
+ authentication that you haven't configured, you'll see an error describing
411
+ what's needed.
412
+
413
+ `google-credentials` is treated as compatible with `http` Bearer security
414
+ schemes, since it produces Bearer tokens.
415
+
416
+ ### Auth retry behavior
417
+
418
+ All auth providers automatically retry on `401` and `403` responses by
419
+ re-fetching credentials (up to 2 retries). This handles cases like expired
420
+ tokens or rotated credentials. For `apiKey` with `!command` values, the command
421
+ is re-executed on retry to fetch a fresh key.
422
+
423
+ ### Agent card fetching and auth
424
+
425
+ When connecting to a remote agent, Gemini CLI first fetches the agent card
426
+ **without** authentication. If the card endpoint returns a `401` or `403`, it
427
+ retries the fetch **with** the configured auth headers. This lets agents have
428
+ publicly accessible cards while protecting their task endpoints, or to protect
429
+ both behind auth.
430
+
431
+ ## Managing Subagents
432
+
433
+ Users can manage subagents using the following commands within Gemini CLI:
434
+
435
+ - `/agents list`: Displays all available local and remote subagents.
436
+ - `/agents reload`: Reloads the agent registry. Use this after adding or
437
+ modifying agent definition files.
438
+ - `/agents enable <agent_name>`: Enables a specific subagent.
439
+ - `/agents disable <agent_name>`: Disables a specific subagent.
440
+
441
+ <!-- prettier-ignore -->
442
+ > [!TIP]
443
+ > You can use the `@cli_help` agent within Gemini CLI for assistance
444
+ > with configuring subagents.
445
+
446
+ ## Disabling remote agents
447
+
448
+ Remote subagents are enabled by default. To disable them, set `enableAgents` to
449
+ `false` in your `settings.json`:
450
+
451
+ ```json
452
+ {
453
+ "experimental": {
454
+ "enableAgents": false
455
+ }
456
+ }
457
+ ```
docs/core/subagents.md ADDED
@@ -0,0 +1,598 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Subagents
2
+
3
+ Subagents are specialized agents that operate within your main Gemini CLI
4
+ session. They are designed to handle specific, complex tasks—like deep codebase
5
+ analysis, documentation lookup, or domain-specific reasoning—without cluttering
6
+ the main agent's context or toolset.
7
+
8
+ ## What are subagents?
9
+
10
+ Subagents are "specialists" that the main Gemini agent can hire for a specific
11
+ job.
12
+
13
+ - **Focused context:** Each subagent has its own system prompt and persona.
14
+ - **Specialized tools:** Subagents can have a restricted or specialized set of
15
+ tools.
16
+ - **Independent context window:** Interactions with a subagent happen in a
17
+ separate context loop, which saves tokens in your main conversation history.
18
+
19
+ Subagents are exposed to the main agent as a tool of the same name. When the
20
+ main agent calls the tool, it delegates the task to the subagent. Once the
21
+ subagent completes its task, it reports back to the main agent with its
22
+ findings.
23
+
24
+ ## How to use subagents
25
+
26
+ You can use subagents through automatic delegation or by explicitly forcing them
27
+ in your prompt.
28
+
29
+ ### Automatic delegation
30
+
31
+ Gemini CLI's main agent is instructed to use specialized subagents when a task
32
+ matches their expertise. For example, if you ask "How does the auth system
33
+ work?", the main agent may decide to call the `codebase_investigator` subagent
34
+ to perform the research.
35
+
36
+ ### Forcing a subagent (@ syntax)
37
+
38
+ You can explicitly direct a task to a specific subagent by using the `@` symbol
39
+ followed by the subagent's name at the beginning of your prompt. This is useful
40
+ when you want to bypass the main agent's decision-making and go straight to a
41
+ specialist.
42
+
43
+ **Example:**
44
+
45
+ ```bash
46
+ @codebase_investigator Map out the relationship between the AgentRegistry and the LocalAgentExecutor.
47
+ ```
48
+
49
+ When you use the `@` syntax, the CLI injects a system note that nudges the
50
+ primary model to use that specific subagent tool immediately.
51
+
52
+ ## Built-in subagents
53
+
54
+ Gemini CLI comes with the following built-in subagents:
55
+
56
+ ### Codebase Investigator
57
+
58
+ - **Name:** `codebase_investigator`
59
+ - **Purpose:** Analyze the codebase, reverse engineer, and understand complex
60
+ dependencies.
61
+ - **When to use:** "How does the authentication system work?", "Map out the
62
+ dependencies of the `AgentRegistry` class."
63
+ - **Configuration:** Enabled by default. You can override its settings in
64
+ `settings.json` under `agents.overrides`. Example (forcing a specific model
65
+ and increasing turns):
66
+ ```json
67
+ {
68
+ "agents": {
69
+ "overrides": {
70
+ "codebase_investigator": {
71
+ "modelConfig": { "model": "gemini-3-flash-preview" },
72
+ "runConfig": { "maxTurns": 50 }
73
+ }
74
+ }
75
+ }
76
+ }
77
+ ```
78
+
79
+ ### CLI Help Agent
80
+
81
+ - **Name:** `cli_help`
82
+ - **Purpose:** Get expert knowledge about Gemini CLI itself, its commands,
83
+ configuration, and documentation.
84
+ - **When to use:** "How do I configure a proxy?", "What does the `/rewind`
85
+ command do?"
86
+ - **Configuration:** Enabled by default.
87
+
88
+ ### Generalist Agent
89
+
90
+ - **Name:** `generalist`
91
+ - **Purpose:** A general, all-purpose subagent that uses the inherited tool
92
+ access and configurations from the main agent. Useful for executing broad,
93
+ resource-heavy subtasks in an isolated conversation, optimizing your main
94
+ agent's context by returning only the final result of that given task.
95
+ - **When to use:** Use this agent when a task requires many steps, handles large
96
+ volumes of information, or requires the same full capabilities as the main
97
+ agent. It is ideal for:
98
+ - **Multi-file modifications:** Applying refactors or fixing errors across
99
+ several files at once.
100
+ - **High-volume execution:** Running commands or tests that produce extensive
101
+ terminal output.
102
+ - **Action-oriented research:** Investigations where the agent needs to both
103
+ search code and run commands or make edits to find a solution. By delegating
104
+ these tasks, you prevent your main conversation from becoming cluttered or
105
+ slow. You can invoke it explicitly using `@generalist`.
106
+ - **Configuration:** Enabled by default.
107
+
108
+ ### Browser Agent
109
+
110
+ - **Name:** `browser_agent`
111
+ - **Purpose:** Automate web browser tasks — navigating websites, filling forms,
112
+ clicking buttons, and extracting information from web pages — using the
113
+ accessibility tree.
114
+ - **When to use:** "Go to example.com and fill out the contact form," "Extract
115
+ the pricing table from this page," "Click the login button and enter my
116
+ credentials."
117
+
118
+ #### Prerequisites
119
+
120
+ The browser agent requires:
121
+
122
+ - **Chrome** version 144 or later (any recent stable release works).
123
+
124
+ The underlying
125
+ [`chrome-devtools-mcp`](https://www.npmjs.com/package/chrome-devtools-mcp)
126
+ server is bundled with Gemini CLI and launched automatically — no separate
127
+ installation is needed.
128
+
129
+ #### Enabling the browser agent
130
+
131
+ The browser agent is disabled by default. Enable it in your `settings.json`:
132
+
133
+ ```json
134
+ {
135
+ "agents": {
136
+ "overrides": {
137
+ "browser_agent": {
138
+ "enabled": true
139
+ }
140
+ }
141
+ }
142
+ }
143
+ ```
144
+
145
+ #### Session modes
146
+
147
+ The `sessionMode` setting controls how Chrome is launched and managed. Set it
148
+ under `agents.browser`:
149
+
150
+ ```json
151
+ {
152
+ "agents": {
153
+ "overrides": {
154
+ "browser_agent": {
155
+ "enabled": true
156
+ }
157
+ },
158
+ "browser": {
159
+ "sessionMode": "persistent"
160
+ }
161
+ }
162
+ }
163
+ ```
164
+
165
+ The available modes are:
166
+
167
+ | Mode | Description |
168
+ | :----------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
169
+ | `persistent` | **(Default)** Launches Chrome with a persistent profile stored at `~/.gemini/cli-browser-profile/`. Cookies, history, and settings are preserved between sessions. |
170
+ | `isolated` | Launches Chrome with a temporary profile that is deleted after each session. Use this for clean-state automation. |
171
+ | `existing` | Attaches to an already-running Chrome instance. You must enable remote debugging first by navigating to `chrome://inspect/#remote-debugging` in Chrome. No new browser process is launched. |
172
+
173
+ #### First-run consent
174
+
175
+ The first time the browser agent is invoked, Gemini CLI displays a consent
176
+ dialog. You must accept before the browser session starts. This dialog only
177
+ appears once.
178
+
179
+ #### Configuration reference
180
+
181
+ All browser-specific settings go under `agents.browser` in your `settings.json`.
182
+ For full details, see the
183
+ [`agents.browser` configuration reference](../reference/configuration.md#agents).
184
+
185
+ | Setting | Type | Default | Description |
186
+ | :------------------------ | :--------- | :------------- | :------------------------------------------------------------------------------ |
187
+ | `sessionMode` | `string` | `"persistent"` | How Chrome is managed: `"persistent"`, `"isolated"`, or `"existing"`. |
188
+ | `headless` | `boolean` | `false` | Run Chrome in headless mode (no visible window). |
189
+ | `profilePath` | `string` | — | Custom path to a browser profile directory. |
190
+ | `visualModel` | `string` | — | Model override for the visual agent. |
191
+ | `allowedDomains` | `string[]` | — | Restrict navigation to specific domains (for example, `["github.com"]`). |
192
+ | `disableUserInput` | `boolean` | `true` | Disable user input on the browser window during automation (non-headless only). |
193
+ | `maxActionsPerTask` | `number` | `100` | Maximum tool calls per task. The agent is terminated when the limit is reached. |
194
+ | `confirmSensitiveActions` | `boolean` | `false` | Require manual confirmation for `upload_file` and `evaluate_script`. |
195
+ | `blockFileUploads` | `boolean` | `false` | Hard-block all file upload requests from the agent. |
196
+
197
+ #### Automation overlay and input blocking
198
+
199
+ In non-headless mode, the browser agent injects a visual overlay into the
200
+ browser window to indicate that automation is in progress. By default, user
201
+ input (keyboard and mouse) is also blocked to prevent accidental interference.
202
+ You can disable this by setting `disableUserInput` to `false`.
203
+
204
+ #### Security
205
+
206
+ The browser agent enforces several layers of security:
207
+
208
+ - **Domain restrictions:** When `allowedDomains` is set, the agent can only
209
+ navigate to the listed domains (and their subdomains when using `*.` prefix).
210
+ Attempting to visit a disallowed domain throws a fatal error that immediately
211
+ terminates the agent. The agent also attempts to detect and block the use of
212
+ allowed domains as proxies (e.g., via query parameters or fragments) to access
213
+ restricted content.
214
+ - **Blocked URL patterns:** The underlying MCP server blocks dangerous URL
215
+ schemes including `file://`, `javascript:`, `data:text/html`,
216
+ `chrome://extensions`, and `chrome://settings/passwords`.
217
+ - **Sensitive action confirmation:** Form filling (`fill`, `fill_form`) always
218
+ requires user confirmation through the policy engine, regardless of approval
219
+ mode. When `confirmSensitiveActions` is `true`, `upload_file` and
220
+ `evaluate_script` also require confirmation.
221
+ - **File upload blocking:** Set `blockFileUploads` to `true` to hard-block all
222
+ file upload requests, preventing the agent from uploading any files.
223
+ - **Action rate limiting:** The `maxActionsPerTask` setting (default: 100)
224
+ limits the total number of tool calls per task to prevent runaway execution.
225
+
226
+ #### Visual agent
227
+
228
+ By default, the browser agent interacts with pages through the accessibility
229
+ tree using element `uid` values. For tasks that require visual identification
230
+ (for example, "click the yellow button" or "find the red error message"), you
231
+ can enable the visual agent by setting a `visualModel`:
232
+
233
+ ```json
234
+ {
235
+ "agents": {
236
+ "overrides": {
237
+ "browser_agent": {
238
+ "enabled": true
239
+ }
240
+ },
241
+ "browser": {
242
+ "visualModel": "gemini-2.5-computer-use-preview-10-2025"
243
+ }
244
+ }
245
+ }
246
+ ```
247
+
248
+ When enabled, the agent gains access to the `analyze_screenshot` tool, which
249
+ captures a screenshot and sends it to the vision model for analysis. The model
250
+ returns coordinates and element descriptions that the browser agent uses with
251
+ the `click_at` tool for precise, coordinate-based interactions.
252
+
253
+ <!-- prettier-ignore -->
254
+ > [!NOTE]
255
+ > The visual agent requires API key or Vertex AI authentication. It is
256
+ > not available when using "Sign in with Google".
257
+
258
+ #### Sandbox support
259
+
260
+ The browser agent adjusts its behavior automatically when running inside a
261
+ sandbox.
262
+
263
+ ##### macOS seatbelt (`sandbox-exec`)
264
+
265
+ When the CLI runs under the macOS seatbelt sandbox, `persistent` and `isolated`
266
+ session modes are forced to `isolated` with `headless` enabled. This avoids
267
+ permission errors caused by seatbelt file-system restrictions on persistent
268
+ browser profiles. If `sessionMode` is set to `existing`, no override is applied.
269
+
270
+ ##### Container sandboxes (Docker / Podman)
271
+
272
+ Chrome is not available inside the container, so the browser agent is
273
+ **disabled** unless `sessionMode` is set to `"existing"`. When enabled with
274
+ `existing` mode, the agent automatically connects to Chrome on the host via the
275
+ resolved IP of `host.docker.internal:9222` instead of using local pipe
276
+ discovery. Port `9222` is currently hardcoded and cannot be customized.
277
+
278
+ To use the browser agent in a Docker sandbox:
279
+
280
+ 1. Start Chrome on the host with remote debugging enabled:
281
+
282
+ ```bash
283
+ # Option A: Launch Chrome from the command line
284
+ google-chrome --remote-debugging-port=9222
285
+
286
+ # Option B: Enable in Chrome settings
287
+ # Navigate to chrome://inspect/#remote-debugging and enable
288
+ ```
289
+
290
+ 2. Configure `sessionMode` and allowed domains in your project's
291
+ `.gemini/settings.json`:
292
+
293
+ ```json
294
+ {
295
+ "agents": {
296
+ "overrides": {
297
+ "browser_agent": { "enabled": true }
298
+ },
299
+ "browser": {
300
+ "sessionMode": "existing",
301
+ "allowedDomains": ["example.com"]
302
+ }
303
+ }
304
+ }
305
+ ```
306
+
307
+ 3. Launch the CLI with port forwarding:
308
+
309
+ ```bash
310
+ GEMINI_SANDBOX=docker SANDBOX_PORTS=9222 gemini
311
+ ```
312
+
313
+ ## Creating custom subagents
314
+
315
+ You can create your own subagents to automate specific workflows or enforce
316
+ specific personas.
317
+
318
+ ### Agent definition files
319
+
320
+ Custom agents are defined as Markdown files (`.md`) with YAML frontmatter. You
321
+ can place them in:
322
+
323
+ 1. **Project-level:** `.gemini/agents/*.md` (Shared with your team)
324
+ 2. **User-level:** `~/.gemini/agents/*.md` (Personal agents)
325
+
326
+ ### File format
327
+
328
+ The file **MUST** start with YAML frontmatter enclosed in triple-dashes `---`.
329
+ The body of the markdown file becomes the agent's **System Prompt**.
330
+
331
+ **Example: `.gemini/agents/security-auditor.md`**
332
+
333
+ ```markdown
334
+ ---
335
+ name: security-auditor
336
+ description: Specialized in finding security vulnerabilities in code.
337
+ kind: local
338
+ tools:
339
+ - read_file
340
+ - grep_search
341
+ model: gemini-3-flash-preview
342
+ temperature: 0.2
343
+ max_turns: 10
344
+ ---
345
+
346
+ You are a ruthless Security Auditor. Your job is to analyze code for potential
347
+ vulnerabilities.
348
+
349
+ Focus on:
350
+
351
+ 1. SQL Injection
352
+ 2. XSS (Cross-Site Scripting)
353
+ 3. Hardcoded credentials
354
+ 4. Unsafe file operations
355
+
356
+ When you find a vulnerability, explain it clearly and suggest a fix. Do not fix
357
+ it yourself; just report it.
358
+ ```
359
+
360
+ ### Configuration schema
361
+
362
+ | Field | Type | Required | Description |
363
+ | :------------- | :----- | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
364
+ | `name` | string | Yes | Unique identifier (slug) used as the tool name for the agent. Only lowercase letters, numbers, hyphens, and underscores. |
365
+ | `description` | string | Yes | Short description of what the agent does. This is visible to the main agent to help it decide when to call this subagent. |
366
+ | `kind` | string | No | `local` (default) or `remote`. |
367
+ | `tools` | array | No | List of tool names this agent can use. Supports wildcards: `*` (all tools), `mcp_*` (all MCP tools), `mcp_server_*` (all tools from a server). **If omitted, it inherits all tools from the parent session.** |
368
+ | `mcpServers` | object | No | Configuration for inline Model Context Protocol (MCP) servers isolated to this specific agent. |
369
+ | `model` | string | No | Specific model to use (for example, `gemini-3-preview`). Defaults to `inherit` (uses the main session model). |
370
+ | `temperature` | number | No | Model temperature (0.0 - 2.0). Defaults to `1`. |
371
+ | `max_turns` | number | No | Maximum number of conversation turns allowed for this agent before it must return. Defaults to `30`. |
372
+ | `timeout_mins` | number | No | Maximum execution time in minutes. Defaults to `10`. |
373
+
374
+ ### Tool wildcards
375
+
376
+ When defining `tools` for a subagent, you can use wildcards to quickly grant
377
+ access to groups of tools:
378
+
379
+ - `*`: Grant access to all available built-in and discovered tools.
380
+ - `mcp_*`: Grant access to all tools from all connected MCP servers.
381
+ - `mcp_my-server_*`: Grant access to all tools from a specific MCP server named
382
+ `my-server`.
383
+
384
+ ### Isolation and recursion protection
385
+
386
+ Each subagent runs in its own isolated context loop. This means:
387
+
388
+ - **Independent history:** The subagent's conversation history does not bloat
389
+ the main agent's context.
390
+ - **Isolated tools:** The subagent only has access to the tools you explicitly
391
+ grant it.
392
+ - **Recursion protection:** To prevent infinite loops and excessive token usage,
393
+ subagents **cannot** call other subagents. If a subagent is granted the `*`
394
+ tool wildcard, it will still be unable to see or invoke other agents.
395
+
396
+ ## Subagent tool isolation
397
+
398
+ Subagent tool isolation moves Gemini CLI away from a single global tool
399
+ registry. By providing isolated execution environments, you can ensure that
400
+ subagents only interact with the parts of the system they are designed for. This
401
+ prevents unintended side effects, improves reliability by avoiding state
402
+ contamination, and enables fine-grained permission control.
403
+
404
+ With this feature, you can:
405
+
406
+ - **Specify tool access:** Define exactly which tools an agent can access using
407
+ a `tools` list in the agent definition.
408
+ - **Define inline MCP servers:** Configure Model Context Protocol (MCP) servers
409
+ (which provide a standardized way to connect AI models to external tools and
410
+ data sources) directly in the subagent's markdown frontmatter, isolating them
411
+ to that specific agent.
412
+ - **Maintain state isolation:** Ensure that subagents only interact with their
413
+ own set of tools and servers, preventing side effects and state contamination.
414
+ - **Apply subagent-specific policies:** Enforce granular rules in your
415
+ [Policy Engine](../reference/policy-engine.md) TOML configuration based on the
416
+ executing subagent's name.
417
+
418
+ ### Configuring isolated tools and servers
419
+
420
+ You can configure tool isolation for a subagent by updating its markdown
421
+ frontmatter. This lets you explicitly state which tools the subagent can use,
422
+ rather than relying on the global registry.
423
+
424
+ Add an `mcpServers` object to define inline MCP servers that are unique to the
425
+ agent.
426
+
427
+ **Example:**
428
+
429
+ ```yaml
430
+ ---
431
+ name: my-isolated-agent
432
+ tools:
433
+ - grep_search
434
+ - read_file
435
+ mcpServers:
436
+ my-custom-server:
437
+ command: 'node'
438
+ args: ['path/to/server.js']
439
+ ---
440
+ ```
441
+
442
+ ### Subagent-specific policies
443
+
444
+ You can enforce fine-grained control over subagents using the
445
+ [Policy Engine's](../reference/policy-engine.md) TOML configuration. This allows
446
+ you to grant or restrict permissions specifically for an agent, without
447
+ affecting the rest of your CLI session.
448
+
449
+ To restrict a policy rule to a specific subagent, add the `subagent` property to
450
+ the `[[rules]]` block in your `policy.toml` file.
451
+
452
+ **Example:**
453
+
454
+ ```toml
455
+ [[rules]]
456
+ name = "Allow pr-creator to push code"
457
+ subagent = "pr-creator"
458
+ description = "Permit pr-creator to push branches automatically."
459
+ action = "allow"
460
+ toolName = "run_shell_command"
461
+ commandPrefix = "git push"
462
+ ```
463
+
464
+ In this configuration, the policy rule only triggers if the executing subagent's
465
+ name matches `pr-creator`. Rules without the `subagent` property apply
466
+ universally to all agents.
467
+
468
+ ## Managing subagents
469
+
470
+ You can manage subagents interactively using the `/agents` command or
471
+ persistently via `settings.json`.
472
+
473
+ ### Interactive management (/agents)
474
+
475
+ If you are in an interactive CLI session, you can use the `/agents` command to
476
+ manage subagents without editing configuration files manually. This is the
477
+ recommended way to quickly enable, disable, or re-configure agents on the fly.
478
+
479
+ For a full list of sub-commands and usage, see the
480
+ [`/agents` command reference](../reference/commands.md#agents).
481
+
482
+ ### Persistent configuration (settings.json)
483
+
484
+ While the `/agents` command and agent definition files provide a starting point,
485
+ you can use `settings.json` for global, persistent overrides. This is useful for
486
+ enforcing specific models or execution limits across all sessions.
487
+
488
+ #### `agents.overrides`
489
+
490
+ Use this to enable or disable specific agents or override their run
491
+ configurations.
492
+
493
+ ```json
494
+ {
495
+ "agents": {
496
+ "overrides": {
497
+ "security-auditor": {
498
+ "enabled": false,
499
+ "runConfig": {
500
+ "maxTurns": 20,
501
+ "maxTimeMinutes": 10
502
+ }
503
+ }
504
+ }
505
+ }
506
+ }
507
+ ```
508
+
509
+ #### `modelConfigs.overrides`
510
+
511
+ You can target specific subagents with custom model settings (like system
512
+ instruction prefixes or specific safety settings) using the `overrideScope`
513
+ field.
514
+
515
+ ```json
516
+ {
517
+ "modelConfigs": {
518
+ "overrides": [
519
+ {
520
+ "match": { "overrideScope": "security-auditor" },
521
+ "modelConfig": {
522
+ "generateContentConfig": {
523
+ "temperature": 0.1
524
+ }
525
+ }
526
+ }
527
+ ]
528
+ }
529
+ }
530
+ ```
531
+
532
+ #### Safety policies (TOML)
533
+
534
+ You can restrict access to specific subagents using the CLI's **Policy Engine**.
535
+ Subagents are treated as virtual tool names for policy matching purposes.
536
+
537
+ To govern access to a subagent, create a `.toml` file in your policy directory
538
+ (e.g., `~/.gemini/policies/`):
539
+
540
+ ```toml
541
+ [[rule]]
542
+ toolName = "codebase_investigator"
543
+ decision = "deny"
544
+ deny_message = "Deep codebase analysis is restricted for this session."
545
+ ```
546
+
547
+ For more information on setting up fine-grained safety guardrails, see the
548
+ [Policy Engine reference](../reference/policy-engine.md#special-syntax-for-subagents).
549
+
550
+ ### Optimizing your subagent
551
+
552
+ The main agent's system prompt encourages it to use an expert subagent when one
553
+ is available. It decides whether an agent is a relevant expert based on the
554
+ agent's description. You can improve the reliability with which an agent is used
555
+ by updating the description to more clearly indicate:
556
+
557
+ - Its area of expertise.
558
+ - When it should be used.
559
+ - Some example scenarios.
560
+
561
+ For example, the following subagent description should be called fairly
562
+ consistently for Git operations.
563
+
564
+ > Git expert agent which should be used for all local and remote git operations.
565
+ > For example:
566
+ >
567
+ > - Making commits
568
+ > - Searching for regressions with bisect
569
+ > - Interacting with source control and issues providers such as GitHub.
570
+
571
+ If you need to further tune your subagent, you can do so by selecting the model
572
+ to optimize for with `/model` and then asking the model why it does not think
573
+ that your subagent was called with a specific prompt and the given description.
574
+
575
+ ## Remote subagents (Agent2Agent)
576
+
577
+ Gemini CLI can also delegate tasks to remote subagents using the Agent-to-Agent
578
+ (A2A) protocol.
579
+
580
+ See the [Remote Subagents documentation](remote-agents) for detailed
581
+ configuration, authentication, and usage instructions.
582
+
583
+ ## Extension subagents
584
+
585
+ Extensions can bundle and distribute subagents. See the
586
+ [Extensions documentation](../extensions/index.md#subagents) for details on how
587
+ to package agents within an extension.
588
+
589
+ ## Disabling subagents
590
+
591
+ Subagents are enabled by default. To disable them, set `enableAgents` to `false`
592
+ in your `settings.json`:
593
+
594
+ ```json
595
+ {
596
+ "experimental": { "enableAgents": false }
597
+ }
598
+ ```
docs/examples/proxy-script.md ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Example proxy script
2
+
3
+ The following is an example of a proxy script that can be used with the
4
+ `GEMINI_SANDBOX_PROXY_COMMAND` environment variable. This script only allows
5
+ `HTTPS` connections to `example.com:443` and declines all other requests.
6
+
7
+ ```javascript
8
+ #!/usr/bin/env node
9
+
10
+ /**
11
+ * @license
12
+ * Copyright 2025 Google LLC
13
+ * SPDX-License-Identifier: Apache-2.0
14
+ */
15
+
16
+ // Example proxy server that listens on :::8877 and only allows HTTPS connections to example.com.
17
+ // Set `GEMINI_SANDBOX_PROXY_COMMAND=scripts/example-proxy.js` to run proxy alongside sandbox
18
+ // Test via `curl https://example.com` inside sandbox (in shell mode or via shell tool)
19
+
20
+ import http from 'node:http';
21
+ import net from 'node:net';
22
+ import { URL } from 'node:url';
23
+ import console from 'node:console';
24
+
25
+ const PROXY_PORT = 8877;
26
+ const ALLOWED_DOMAINS = ['example.com', 'googleapis.com'];
27
+ const ALLOWED_PORT = '443';
28
+
29
+ const server = http.createServer((req, res) => {
30
+ // Deny all requests other than CONNECT for HTTPS
31
+ console.log(
32
+ `[PROXY] Denying non-CONNECT request for: ${req.method} ${req.url}`,
33
+ );
34
+ res.writeHead(405, { 'Content-Type': 'text/plain' });
35
+ res.end('Method Not Allowed');
36
+ });
37
+
38
+ server.on('connect', (req, clientSocket, head) => {
39
+ // req.url will be in the format "hostname:port" for a CONNECT request.
40
+ const { port, hostname } = new URL(`http://${req.url}`);
41
+
42
+ console.log(`[PROXY] Intercepted CONNECT request for: ${hostname}:${port}`);
43
+
44
+ if (
45
+ ALLOWED_DOMAINS.some(
46
+ (domain) => hostname == domain || hostname.endsWith(`.${domain}`),
47
+ ) &&
48
+ port === ALLOWED_PORT
49
+ ) {
50
+ console.log(`[PROXY] Allowing connection to ${hostname}:${port}`);
51
+
52
+ // Establish a TCP connection to the original destination.
53
+ const serverSocket = net.connect(port, hostname, () => {
54
+ clientSocket.write('HTTP/1.1 200 Connection Established\r\n\r\n');
55
+ // Create a tunnel by piping data between the client and the destination server.
56
+ serverSocket.write(head);
57
+ serverSocket.pipe(clientSocket);
58
+ clientSocket.pipe(serverSocket);
59
+ });
60
+
61
+ serverSocket.on('error', (err) => {
62
+ console.error(`[PROXY] Error connecting to destination: ${err.message}`);
63
+ clientSocket.end(`HTTP/1.1 502 Bad Gateway\r\n\r\n`);
64
+ });
65
+ } else {
66
+ console.log(`[PROXY] Denying connection to ${hostname}:${port}`);
67
+ clientSocket.end('HTTP/1.1 403 Forbidden\r\n\r\n');
68
+ }
69
+
70
+ clientSocket.on('error', (err) => {
71
+ // This can happen if the client hangs up.
72
+ console.error(`[PROXY] Client socket error: ${err.message}`);
73
+ });
74
+ });
75
+
76
+ server.listen(PROXY_PORT, () => {
77
+ const address = server.address();
78
+ console.log(`[PROXY] Proxy listening on ${address.address}:${address.port}`);
79
+ console.log(
80
+ `[PROXY] Allowing HTTPS connections to domains: ${ALLOWED_DOMAINS.join(', ')}`,
81
+ );
82
+ });
83
+ ```
docs/extensions/best-practices.md ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Gemini CLI extension best practices
2
+
3
+ This guide covers best practices for developing, securing, and maintaining
4
+ Gemini CLI extensions.
5
+
6
+ ## Development
7
+
8
+ Developing extensions for Gemini CLI is a lightweight, iterative process. Use
9
+ these strategies to build robust and efficient extensions.
10
+
11
+ ### Structure your extension
12
+
13
+ While simple extensions may contain only a few files, we recommend a organized
14
+ structure for complex projects.
15
+
16
+ ```text
17
+ my-extension/
18
+ ├── package.json
19
+ ├── tsconfig.json
20
+ ├── gemini-extension.json
21
+ ├── src/
22
+ │ ├── index.ts
23
+ │ └── tools/
24
+ └── dist/
25
+ ```
26
+
27
+ - **Use TypeScript:** We strongly recommend using TypeScript for type safety and
28
+ improved developer experience.
29
+ - **Separate source and build:** Keep your source code in `src/` and output
30
+ build artifacts to `dist/`.
31
+ - **Bundle dependencies:** If your extension has many dependencies, bundle them
32
+ using a tool like `esbuild` to reduce installation time and avoid conflicts.
33
+
34
+ ### Iterate with `link`
35
+
36
+ Use the `gemini extensions link` command to develop locally without reinstalling
37
+ your extension after every change.
38
+
39
+ ```bash
40
+ cd my-extension
41
+ gemini extensions link .
42
+ ```
43
+
44
+ Changes to your code are immediately available in the CLI after you rebuild the
45
+ project and restart the session.
46
+
47
+ ### Use `GEMINI.md` effectively
48
+
49
+ Your `GEMINI.md` file provides essential context to the model.
50
+
51
+ - **Focus on goals:** Explain the high-level purpose of the extension and how to
52
+ interact with its tools.
53
+ - **Be concise:** Avoid dumping exhaustive documentation into the file. Use
54
+ clear, direct language.
55
+ - **Provide examples:** Include brief examples of how the model should use
56
+ specific tools or commands.
57
+
58
+ ## Security
59
+
60
+ Follow the principle of least privilege and rigorous input validation when
61
+ building extensions.
62
+
63
+ ### Minimal permissions
64
+
65
+ Only request the permissions your MCP server needs to function. Avoid giving the
66
+ model broad access (such as full shell access) if restricted tools are
67
+ sufficient.
68
+
69
+ If your extension uses powerful tools like `run_shell_command`, restrict them in
70
+ your `gemini-extension.json` file:
71
+
72
+ ```json
73
+ {
74
+ "name": "my-safe-extension",
75
+ "excludeTools": ["run_shell_command(rm -rf *)"]
76
+ }
77
+ ```
78
+
79
+ This ensures the CLI blocks dangerous commands even if the model attempts to
80
+ execute them.
81
+
82
+ ### Validate inputs
83
+
84
+ Your MCP server runs on the user's machine. Always validate tool inputs to
85
+ prevent arbitrary code execution or unauthorized filesystem access.
86
+
87
+ ```typescript
88
+ // Example: Validating paths
89
+ if (!path.resolve(inputPath).startsWith(path.resolve(allowedDir) + path.sep)) {
90
+ throw new Error('Access denied');
91
+ }
92
+ ```
93
+
94
+ ### Secure sensitive settings
95
+
96
+ If your extension requires API keys or other secrets, use the `sensitive: true`
97
+ option in your manifest. This ensures keys are stored in the system keychain and
98
+ obfuscated in the CLI output.
99
+
100
+ ```json
101
+ "settings": [
102
+ {
103
+ "name": "API Key",
104
+ "envVar": "MY_API_KEY",
105
+ "sensitive": true
106
+ }
107
+ ]
108
+ ```
109
+
110
+ ## Release
111
+
112
+ Follow standard versioning and release practices to ensure a smooth experience
113
+ for your users.
114
+
115
+ ### Semantic versioning
116
+
117
+ Follow [Semantic Versioning (SemVer)](https://semver.org/) to communicate
118
+ changes clearly.
119
+
120
+ - **Major:** Breaking changes (for example, renaming tools or changing
121
+ arguments).
122
+ - **Minor:** New features (for example, adding new tools or commands).
123
+ - **Patch:** Bug fixes and performance improvements.
124
+
125
+ ### Release channels
126
+
127
+ Use Git branches to manage release channels. This lets users choose between
128
+ stability and the latest features.
129
+
130
+ ```bash
131
+ # Install the stable version (default branch)
132
+ gemini extensions install github.com/user/repo
133
+
134
+ # Install the development version
135
+ gemini extensions install github.com/user/repo --ref dev
136
+ ```
137
+
138
+ ### Clean artifacts
139
+
140
+ When using GitHub Releases, ensure your archives only contain necessary files
141
+ (such as `dist/`, `gemini-extension.json`, and `package.json`). Exclude
142
+ `node_modules/` and `src/` to minimize download size.
143
+
144
+ ## Test and verify
145
+
146
+ Test your extension thoroughly before releasing it to users.
147
+
148
+ - **Manual verification:** Use `gemini extensions link` to test your extension
149
+ in a live CLI session. Verify that tools appear in the debug console (F12) and
150
+ that custom commands resolve correctly.
151
+ - **Automated testing:** If your extension includes an MCP server, write unit
152
+ tests for your tool logic using a framework like Vitest or Jest. You can test
153
+ MCP tools in isolation by mocking the transport layer.
154
+
155
+ ## Troubleshooting
156
+
157
+ Use these tips to diagnose and fix common extension issues.
158
+
159
+ ### Extension not loading
160
+
161
+ If your extension doesn't appear in `/extensions list`:
162
+
163
+ - **Check the manifest:** Ensure `gemini-extension.json` is in the root
164
+ directory and contains valid JSON.
165
+ - **Verify the name:** The `name` field in the manifest must match the extension
166
+ directory name exactly.
167
+ - **Restart the CLI:** Extensions are loaded at the start of a session. Restart
168
+ Gemini CLI after making changes to the manifest or linking a new extension.
169
+
170
+ ### MCP server failures
171
+
172
+ If your tools aren't working as expected:
173
+
174
+ - **Check the logs:** View the CLI logs to see if the MCP server failed to
175
+ start.
176
+ - **Test the command:** Run the server's `command` and `args` directly in your
177
+ terminal to ensure it starts correctly outside of Gemini CLI.
178
+ - **Debug console:** In interactive mode, press **F12** to open the debug
179
+ console and inspect tool calls and responses.
180
+
181
+ ### Command conflicts
182
+
183
+ If a custom command isn't responding:
184
+
185
+ - **Check precedence:** Remember that user and project commands take precedence
186
+ over extension commands. Use the prefixed name (for example,
187
+ `/extension.command`) to verify the extension's version.
188
+ - **Help command:** Run `/help` to see a list of all available commands and
189
+ their sources.
docs/extensions/index.md ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Gemini CLI extensions
2
+
3
+ Gemini CLI extensions package prompts, MCP servers, custom commands, themes,
4
+ hooks, sub-agents, and agent skills into a familiar and user-friendly format.
5
+ With extensions, you can expand the capabilities of Gemini CLI and share those
6
+ capabilities with others. They are designed to be easily installable and
7
+ shareable.
8
+
9
+ To see what's possible, browse the
10
+ [Gemini CLI extension gallery](https://geminicli.com/extensions/browse/).
11
+
12
+ ## Choose your path
13
+
14
+ Choose the guide that best fits your needs.
15
+
16
+ ### I want to use extensions
17
+
18
+ Learn how to discover, install, and manage extensions to enhance your Gemini CLI
19
+ experience.
20
+
21
+ - **[Manage extensions](#manage-extensions):** List and verify your installed
22
+ extensions.
23
+ - **[Install extensions](#installation):** Add new capabilities from GitHub or
24
+ local paths.
25
+
26
+ ### I want to build extensions
27
+
28
+ Learn how to create, test, and share your own extensions with the community.
29
+
30
+ - **[Build extensions](writing-extensions.md):** Create your first extension
31
+ from a template.
32
+ - **[Best practices](best-practices.md):** Learn how to build secure and
33
+ reliable extensions.
34
+ - **[Publish to the gallery](releasing.md):** Share your work with the world.
35
+
36
+ ## Manage extensions
37
+
38
+ Use the interactive `/extensions` command to verify your installed extensions
39
+ and their status:
40
+
41
+ ```bash
42
+ /extensions list
43
+ ```
44
+
45
+ You can also manage extensions from your terminal using the `gemini extensions`
46
+ command group:
47
+
48
+ ```bash
49
+ gemini extensions list
50
+ ```
51
+
52
+ ## Installation
53
+
54
+ Install an extension by providing its GitHub repository URL. For example:
55
+
56
+ ```bash
57
+ gemini extensions install https://github.com/gemini-cli-extensions/workspace
58
+ ```
59
+
60
+ For more advanced installation options, see the
61
+ [Extension reference](reference.md#install-an-extension).
docs/extensions/reference.md ADDED
@@ -0,0 +1,361 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Extension reference
2
+
3
+ This guide covers the `gemini extensions` commands and the structure of the
4
+ `gemini-extension.json` configuration file.
5
+
6
+ ## Manage extensions
7
+
8
+ Use the `gemini extensions` command group to manage your extensions from the
9
+ terminal.
10
+
11
+ Note that commands like `gemini extensions install` are not supported within the
12
+ CLI's interactive mode. However, you can use the `/extensions list` command to
13
+ view installed extensions. All management operations, including updates to slash
14
+ commands, take effect only after you restart the CLI session.
15
+
16
+ ### Install an extension
17
+
18
+ Install an extension by providing its GitHub repository URL or a local file
19
+ path.
20
+
21
+ Gemini CLI creates a copy of the extension during installation. You must run
22
+ `gemini extensions update` to pull changes from the source. To install from
23
+ GitHub, you must have `git` installed on your machine.
24
+
25
+ ```bash
26
+ gemini extensions install <source> [--ref <ref>] [--auto-update] [--pre-release] [--consent] [--skip-settings]
27
+ ```
28
+
29
+ - `<source>`: The GitHub URL or local path of the extension.
30
+ - `--ref`: The git ref (branch, tag, or commit) to install.
31
+ - `--auto-update`: Enable automatic updates for this extension.
32
+ - `--pre-release`: Enable installation of pre-release versions.
33
+ - `--consent`: Acknowledge security risks and skip the confirmation prompt.
34
+ - `--skip-settings`: Skip the configuration on install process.
35
+
36
+ ### Uninstall an extension
37
+
38
+ To uninstall one or more extensions, use the `uninstall` command:
39
+
40
+ ```bash
41
+ gemini extensions uninstall <name...>
42
+ ```
43
+
44
+ ### Disable an extension
45
+
46
+ Extensions are enabled globally by default. You can disable an extension
47
+ entirely or for a specific workspace.
48
+
49
+ ```bash
50
+ gemini extensions disable <name> [--scope <scope>]
51
+ ```
52
+
53
+ - `<name>`: The name of the extension to disable.
54
+ - `--scope`: The scope to disable the extension in (`user` or `workspace`).
55
+
56
+ ### Enable an extension
57
+
58
+ Re-enable a disabled extension using the `enable` command:
59
+
60
+ ```bash
61
+ gemini extensions enable <name> [--scope <scope>]
62
+ ```
63
+
64
+ - `<name>`: The name of the extension to enable.
65
+ - `--scope`: The scope to enable the extension in (`user` or `workspace`).
66
+
67
+ ### Update an extension
68
+
69
+ Update an extension to the version specified in its `gemini-extension.json`
70
+ file.
71
+
72
+ ```bash
73
+ gemini extensions update <name>
74
+ ```
75
+
76
+ To update all installed extensions at once:
77
+
78
+ ```bash
79
+ gemini extensions update --all
80
+ ```
81
+
82
+ ### Create an extension from a template
83
+
84
+ Create a new extension directory using a built-in template.
85
+
86
+ ```bash
87
+ gemini extensions new <path> [template]
88
+ ```
89
+
90
+ - `<path>`: The directory to create.
91
+ - `[template]`: The template to use (for example, `mcp-server`, `context`,
92
+ `custom-commands`).
93
+
94
+ ### Link a local extension
95
+
96
+ Create a symbolic link between your development directory and Gemini CLI
97
+ extensions directory. This lets you test changes immediately without
98
+ reinstalling.
99
+
100
+ ```bash
101
+ gemini extensions link <path>
102
+ ```
103
+
104
+ ## Extension format
105
+
106
+ Gemini CLI loads extensions from `<home>/.gemini/extensions`. Each extension
107
+ must have a `gemini-extension.json` file in its root directory.
108
+
109
+ ### `gemini-extension.json`
110
+
111
+ The manifest file defines the extension's behavior and configuration.
112
+
113
+ ```json
114
+ {
115
+ "name": "my-extension",
116
+ "version": "1.0.0",
117
+ "description": "My awesome extension",
118
+ "mcpServers": {
119
+ "my-server": {
120
+ "command": "node",
121
+ "args": ["${extensionPath}/my-server.js"],
122
+ "cwd": "${extensionPath}"
123
+ }
124
+ },
125
+ "contextFileName": "GEMINI.md",
126
+ "excludeTools": ["run_shell_command"],
127
+ "migratedTo": "https://github.com/new-owner/new-extension-repo",
128
+ "plan": {
129
+ "directory": ".gemini/plans"
130
+ }
131
+ }
132
+ ```
133
+
134
+ - `name`: The name of the extension. This is used to uniquely identify the
135
+ extension and for conflict resolution when extension commands have the same
136
+ name as user or project commands. The name should be lowercase or numbers and
137
+ use dashes instead of underscores or spaces. This is how users will refer to
138
+ your extension in the CLI. Note that we expect this name to match the
139
+ extension directory name.
140
+ - `version`: The version of the extension.
141
+ - `description`: A short description of the extension. This will be displayed on
142
+ [geminicli.com/extensions](https://geminicli.com/extensions).
143
+ - `migratedTo`: The URL of the new repository source for the extension. If this
144
+ is set, the CLI will automatically check this new source for updates and
145
+ migrate the extension's installation to the new source if an update is found.
146
+ - `mcpServers`: A map of MCP servers to settings. The key is the name of the
147
+ server, and the value is the server configuration. These servers will be
148
+ loaded on startup just like MCP servers defined in a
149
+ [`settings.json` file](../reference/configuration.md). If both an extension
150
+ and a `settings.json` file define an MCP server with the same name, the server
151
+ defined in the `settings.json` file takes precedence.
152
+ - Note that all MCP server configuration options are supported except for
153
+ `trust`.
154
+ - For portability, you should use `${extensionPath}` to refer to files within
155
+ your extension directory.
156
+ - Separate your executable and its arguments using `command` and `args`
157
+ instead of putting them both in `command`.
158
+ - `contextFileName`: The name of the file that contains the context for the
159
+ extension. This will be used to load the context from the extension directory.
160
+ If this property is not used but a `GEMINI.md` file is present in your
161
+ extension directory, then that file will be loaded.
162
+ - `excludeTools`: An array of tool names to exclude from the model. You can also
163
+ specify command-specific restrictions for tools that support it, like the
164
+ `run_shell_command` tool. For example,
165
+ `"excludeTools": ["run_shell_command(rm -rf)"]` will block the `rm -rf`
166
+ command. Note that this differs from the MCP server `excludeTools`
167
+ functionality, which can be listed in the MCP server config.
168
+ - `plan`: Planning features configuration.
169
+ - `directory`: The directory where planning artifacts are stored. This serves
170
+ as a fallback if the user hasn't specified a plan directory in their
171
+ settings. If not specified by either the extension or the user, the default
172
+ is `~/.gemini/tmp/<project>/<session-id>/plans/`.
173
+
174
+ When Gemini CLI starts, it loads all the extensions and merges their
175
+ configurations. If there are any conflicts, the workspace configuration takes
176
+ precedence.
177
+
178
+ ### Extension settings
179
+
180
+ Extensions can define settings that users provide during installation, such as
181
+ API keys or URLs. These values are stored in a `.env` file within the extension
182
+ directory.
183
+
184
+ To define settings, add a `settings` array to your manifest:
185
+
186
+ ```json
187
+ {
188
+ "name": "my-api-extension",
189
+ "version": "1.0.0",
190
+ "settings": [
191
+ {
192
+ "name": "API Key",
193
+ "description": "Your API key for the service.",
194
+ "envVar": "MY_API_KEY",
195
+ "sensitive": true
196
+ }
197
+ ]
198
+ }
199
+ ```
200
+
201
+ - `name`: The setting's display name.
202
+ - `description`: A clear explanation of the setting.
203
+ - `envVar`: The environment variable name where the value is stored.
204
+ - `sensitive`: If `true`, the value is stored in the system keychain and
205
+ obfuscated in the UI.
206
+
207
+ To update an extension's settings:
208
+
209
+ ```bash
210
+ gemini extensions config <name> [setting] [--scope <scope>]
211
+ ```
212
+
213
+ #### Environment variable sanitization
214
+
215
+ For security reasons, sensitive environment variables are filtered out and not
216
+ passed to extensions or MCP servers by default.
217
+
218
+ Extensions **will not** inherit the user's full shell environment variables.
219
+ They will only have access to:
220
+
221
+ 1. Standard safe variables (e.g., `HOME`, `PATH`, `TMPDIR`).
222
+ 2. Variables explicitly declared and requested in the `gemini-extension.json`
223
+ manifest via the `settings` array (using the `envVar` property).
224
+
225
+ If your extension requires specific environment variables (like an API key,
226
+ custom host, or config path), you **must** declare them in the `settings` array
227
+ so the CLI can allowlist them for use within the extension.
228
+
229
+ ### Custom commands
230
+
231
+ Provide [custom commands](../cli/custom-commands.md) by placing TOML files in a
232
+ `commands/` subdirectory. Gemini CLI uses the directory structure to determine
233
+ the command name.
234
+
235
+ For an extension named `gcp`:
236
+
237
+ - `commands/deploy.toml` becomes `/deploy`
238
+ - `commands/gcs/sync.toml` becomes `/gcs:sync` (namespaced with a colon)
239
+
240
+ ### Hooks
241
+
242
+ Intercept and customize CLI behavior using [hooks](../hooks/index.md). Define
243
+ hooks in a `hooks/hooks.json` file within your extension directory. Note that
244
+ hooks are not defined in the `gemini-extension.json` manifest.
245
+
246
+ ### Agent skills
247
+
248
+ Bundle [agent skills](../cli/skills.md) to provide specialized workflows. Place
249
+ skill definitions in a `skills/` directory. For example,
250
+ `skills/security-audit/SKILL.md` exposes a `security-audit` skill.
251
+
252
+ ### Sub-agents
253
+
254
+ <!-- prettier-ignore -->
255
+ > [!NOTE]
256
+ > Sub-agents are a preview feature currently under active development.
257
+
258
+ Provide [sub-agents](../core/subagents.md) that users can delegate tasks to. Add
259
+ agent definition files (`.md`) to an `agents/` directory in your extension root.
260
+
261
+ ### <a id="policy-engine"></a>Policy Engine
262
+
263
+ Extensions can contribute policy rules and safety checkers to Gemini CLI
264
+ [Policy Engine](../reference/policy-engine.md). These rules are defined in
265
+ `.toml` files and take effect when the extension is activated.
266
+
267
+ To add policies, create a `policies/` directory in your extension's root and
268
+ place your `.toml` policy files inside it. Gemini CLI automatically loads all
269
+ `.toml` files from this directory.
270
+
271
+ Rules contributed by extensions run in their own tier (tier 2), alongside
272
+ workspace-defined policies. This tier has higher priority than the default rules
273
+ but lower priority than user or admin policies.
274
+
275
+ <!-- prettier-ignore -->
276
+ > [!WARNING]
277
+ > For security, Gemini CLI ignores any `allow` decisions or `yolo`
278
+ > mode configurations in extension policies. This ensures that an extension
279
+ > cannot automatically approve tool calls or bypass security measures without
280
+ > your confirmation.
281
+
282
+ **Example `policies.toml`**
283
+
284
+ ```toml
285
+ [[rule]]
286
+ mcpName = "my_server"
287
+ toolName = "dangerous_tool"
288
+ decision = "ask_user"
289
+ priority = 100
290
+
291
+ [[safety_checker]]
292
+ mcpName = "my_server"
293
+ toolName = "write_data"
294
+ priority = 200
295
+ [safety_checker.checker]
296
+ type = "in-process"
297
+ name = "allowed-path"
298
+ required_context = ["environment"]
299
+ ```
300
+
301
+ ### Themes
302
+
303
+ Extensions can provide custom themes to personalize the CLI UI. Themes are
304
+ defined in the `themes` array in `gemini-extension.json`.
305
+
306
+ **Example**
307
+
308
+ ```json
309
+ {
310
+ "name": "my-green-extension",
311
+ "version": "1.0.0",
312
+ "themes": [
313
+ {
314
+ "name": "shades-of-green",
315
+ "type": "custom",
316
+ "background": {
317
+ "primary": "#1a362a"
318
+ },
319
+ "text": {
320
+ "primary": "#a6e3a1",
321
+ "secondary": "#6e8e7a",
322
+ "link": "#89e689"
323
+ },
324
+ "status": {
325
+ "success": "#76c076",
326
+ "warning": "#d9e689",
327
+ "error": "#b34e4e"
328
+ },
329
+ "border": {
330
+ "default": "#4a6c5a"
331
+ },
332
+ "ui": {
333
+ "comment": "#6e8e7a"
334
+ }
335
+ }
336
+ ]
337
+ }
338
+ ```
339
+
340
+ Custom themes provided by extensions can be selected using the `/theme` command
341
+ or by setting the `ui.theme` property in your `settings.json` file. Note that
342
+ when referring to a theme from an extension, the extension name is appended to
343
+ the theme name in parentheses, for example,
344
+ `shades-of-green (my-green-extension)`.
345
+
346
+ ### Conflict resolution
347
+
348
+ Extension commands have the lowest precedence. If an extension command name
349
+ conflicts with a user or project command, the extension command is prefixed with
350
+ the extension name (for example, `/gcp.deploy`) using a dot separator.
351
+
352
+ ## Variables
353
+
354
+ Gemini CLI supports variable substitution in `gemini-extension.json` and
355
+ `hooks/hooks.json`.
356
+
357
+ | Variable | Description |
358
+ | :----------------- | :---------------------------------------------- |
359
+ | `${extensionPath}` | The absolute path to the extension's directory. |
360
+ | `${workspacePath}` | The absolute path to the current workspace. |
361
+ | `${/}` | The platform-specific path separator. |