Gemini CLI Cheat Sheet: Flags, Slash Commands, settings.json and MCP
Checked against Gemini CLI Gemini CLI v0.71.1 (24 Nov 2026) on 28 November 2026. Each section links to the official docs it was checked against.
This sheet is for developers using Google's open-source Gemini CLI agent in the terminal. It covers v0.71.1, released 24 Nov 2026, using the project README, its docs folder and geminicli.com. The CLI wasn't installed here, so all rows are checked against the docs, not run.
When to use what
Check which product you should be on before anything else. The README says free personal use and Google AI Pro or Ultra subscriptions moved to Antigravity CLI on 18 June 2026, and that Gemini CLI now targets Gemini Code Assist Standard and Enterprise, Code Assist for GitHub and paid API or Vertex keys. If you're a hobbyist with a personal Google account, read that note before you install.
For approvals, --approval-mode is the switch to learn: default asks before edits and commands, auto_edit lets file edits through, and yolo approves everything. The old -y flag still works but is marked deprecated. Shift+Tab cycles modes while you work, which is handy when a task moves from reading to editing.
Use -p for one-shot scripted calls and add --output-format json when another program reads the result; the JSON formatter helps when you inspect that output by hand. Put shared project setup in .gemini/settings.json and personal taste in ~/.gemini/settings.json. For MCP, gemini mcp add writes the config for you, and the MCP config validator catches a broken block before the CLI does. Our Gemini CLI page has the product overview.
npm install -g @google/gemini-cliInstall globally from npm; add @preview or @nightly for other channels
npx @google/gemini-cliRun without installing
brew install gemini-cliInstall with Homebrew on macOS or Linux
gemini -p "summarise README.md"Answer one prompt and exit, for scripts
gemini -i "explain src/"Run a first prompt, then stay in the interactive session
gemini -m flashPick a model or alias (auto, pro, flash, flash-lite); auto is the default
gemini --approval-mode auto_editApprove file edits automatically; choices are default, auto_edit, yolo, plan
gemini -sRun tools inside the sandbox (--sandbox)
gemini -r latestResume the most recent session; --list-sessions shows the others
gemini --include-directories ../lib,../docsAdd folders outside the current one to the workspace
gemini -p "..." --output-format jsonEmit text, json or stream-json for another program to parse
Custom commands are TOML files in ~/.gemini/commands/ or .gemini/commands/.
@src/utils/ explain this folderInline a file or folder into the prompt; git-ignored files are left out
!git statusRun a shell command; a lone ! toggles shell mode
/memory showPrint the combined GEMINI.md context being sent
/initGenerate a GEMINI.md for the current project
/model set flash --persistChange model and save it as your default
/mcp listShow configured MCP servers and their tools; /mcp reload restarts them
/compressReplace the chat history with a summary to save tokens
/directory add ../apiAdd another folder to the workspace mid-session
/resume save before-refactorSave a named checkpoint of the chat (alias /chat)
/restoreList or roll back to file checkpoints taken before tool edits
/statsShow token use for the session, model or tools
/tools descList available tools with their descriptions
Rebind keys in ~/.gemini/keybindings.json.
Shift+TabCycle approval modes: default, auto-edit, plan
Ctrl+YToggle YOLO mode on or off
Esc EscClear the input, or open rewind when the input is already empty
Ctrl+RSearch earlier prompts
Ctrl+GEdit the prompt or plan in your external editor
Ctrl+CCancel the running request, or quit on an empty prompt
?Show the shortcuts panel when typed on an empty prompt
Precedence, lowest to highest: defaults, system defaults, user, project, system settings, environment variables, command-line flags.
~/.gemini/settings.jsonUser settings; .gemini/settings.json in a repo overrides them
/etc/gemini-cli/settings.jsonLinux system settings, which beat both user and project files
"model": { "name": "pro" }Default model, nested under model.name
"general": { "defaultApprovalMode": "auto_edit" }Start every session in this approval mode
"context": { "fileName": ["AGENTS.md", "GEMINI.md"] }Read other instruction file names as well as GEMINI.md
"env": { "KEY": "${MY_KEY:-dev}" }Reference environment variables, with a fallback value, inside settings
~/.gemini/GEMINI.mdGlobal context file, loaded before the GEMINI.md files in your project and its parents
@./docs/style.mdImport another Markdown file from inside a GEMINI.md
Tools are named mcp_<server>_<tool>, so the docs advise against underscores in server names. Extensions live in ~/.gemini/extensions and are described by gemini-extension.json.
gemini mcp add github npx -y @modelcontextprotocol/server-githubAdd a stdio server to the project scope (the default)
gemini mcp add -s user --transport http docs https://api.example.com/mcp/Add a remote HTTP server for every project
gemini mcp listList servers and whether they connected
gemini mcp remove docsDelete a server entry
"mcpServers": { "db": { "command": "node", "args": ["db.js"], "includeTools": ["query"] } }Hand-written stdio entry that exposes only one tool
"httpUrl": "http://localhost:3000/mcp"Use streamable HTTP; url means SSE and command means stdio
"trust": trueSkip confirmations for that server's tools (off by default)
gemini extensions install <source>Install an extension from a GitHub URL or local path
gemini extensions listShow installed extensions
gemini extensions update --allUpdate every installed extension
gemini extensions new ./my-ext mcp-serverScaffold an extension from the mcp-server template
Worked example: Add a project MCP server and limit what it can do
Register the server from the repo root so it lands in .gemini/settings.json:
gemini mcp add github npx -y @modelcontextprotocol/server-github
Then open the project settings and narrow the tool list:
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "$GITHUB_TOKEN" },
"includeTools": ["search_issues", "get_issue"]
}
}
}
Start gemini and run /mcp list. You should see the github server with only the two tools you allowed. The token comes from your shell through $GITHUB_TOKEN, so the settings file can be committed without a secret in it. If a tool you expected is missing, check excludeTools too, because an exclude wins over an include.
Common mistakes
Installing Gemini CLI for free personal use after June 2026
Read the README note: personal and Google AI Pro or Ultra access moved to Antigravity CLI.
Putting a server name like
my_dbin mcpServersUse hyphens; tool names are built as
mcp_<server>_<tool>and underscores make them ambiguous.Setting
"trust": trueon every server to stop promptsTrust only servers you wrote or audited, and use
includeToolsto cut the rest down.Using
-yin new scriptsIt's deprecated; write
--approval-mode yoloso the intent is explicit and survives removal.Committing an API key inside
.gemini/settings.jsonReference it as
$VARor${VAR}and keep the value in your shell or a secrets manager.
Related cheat sheets
Sources
- https://raw.githubusercontent.com/google-gemini/gemini-cli/main/README.md
- https://www.geminicli.com/docs/cli/cli-reference/
- https://www.geminicli.com/docs/reference/commands
- https://www.geminicli.com/docs/reference/configuration
- https://www.geminicli.com/docs/reference/keyboard-shortcuts
- https://raw.githubusercontent.com/google-gemini/gemini-cli/main/docs/cli/gemini-md.md
- https://raw.githubusercontent.com/google-gemini/gemini-cli/main/docs/tools/mcp-server.md
- https://www.geminicli.com/docs/extensions/reference/
- https://raw.githubusercontent.com/google-gemini/gemini-cli/main/docs/changelogs/index.md
How we research: where our facts come from, how often we re-check them, and why no one can pay for a review or a verdict.