Skip to content

Menu

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-cli

Install globally from npm; add @preview or @nightly for other channels

From the docs, not run by us
npx @google/gemini-cli

Run without installing

From the docs, not run by us
brew install gemini-cli

Install with Homebrew on macOS or Linux

From the docs, not run by us
gemini -p "summarise README.md"

Answer one prompt and exit, for scripts

From the docs, not run by us
gemini -i "explain src/"

Run a first prompt, then stay in the interactive session

From the docs, not run by us
gemini -m flash

Pick a model or alias (auto, pro, flash, flash-lite); auto is the default

From the docs, not run by us
gemini --approval-mode auto_edit

Approve file edits automatically; choices are default, auto_edit, yolo, plan

From the docs, not run by us
gemini -s

Run tools inside the sandbox (--sandbox)

From the docs, not run by us
gemini -r latest

Resume the most recent session; --list-sessions shows the others

From the docs, not run by us
gemini --include-directories ../lib,../docs

Add folders outside the current one to the workspace

From the docs, not run by us
gemini -p "..." --output-format json

Emit text, json or stream-json for another program to parse

Try it: JSON FormatterFrom the docs, not run by us

Custom commands are TOML files in ~/.gemini/commands/ or .gemini/commands/.

@src/utils/ explain this folder

Inline a file or folder into the prompt; git-ignored files are left out

From the docs, not run by us
!git status

Run a shell command; a lone ! toggles shell mode

From the docs, not run by us
/memory show

Print the combined GEMINI.md context being sent

From the docs, not run by us
/init

Generate a GEMINI.md for the current project

Try it: AGENTS.md / CLAUDE.md GeneratorFrom the docs, not run by us
/model set flash --persist

Change model and save it as your default

From the docs, not run by us
/mcp list

Show configured MCP servers and their tools; /mcp reload restarts them

From the docs, not run by us
/compress

Replace the chat history with a summary to save tokens

Try it: Token CounterFrom the docs, not run by us
/directory add ../api

Add another folder to the workspace mid-session

From the docs, not run by us
/resume save before-refactor

Save a named checkpoint of the chat (alias /chat)

From the docs, not run by us
/restore

List or roll back to file checkpoints taken before tool edits

From the docs, not run by us
/stats

Show token use for the session, model or tools

From the docs, not run by us
/tools desc

List available tools with their descriptions

From the docs, not run by us

Rebind keys in ~/.gemini/keybindings.json.

Shift+Tab

Cycle approval modes: default, auto-edit, plan

From the docs, not run by us
Ctrl+Y

Toggle YOLO mode on or off

From the docs, not run by us
Esc Esc

Clear the input, or open rewind when the input is already empty

From the docs, not run by us
Ctrl+R

Search earlier prompts

From the docs, not run by us
Ctrl+G

Edit the prompt or plan in your external editor

From the docs, not run by us
Ctrl+C

Cancel the running request, or quit on an empty prompt

From the docs, not run by us
?

Show the shortcuts panel when typed on an empty prompt

From the docs, not run by us

Precedence, lowest to highest: defaults, system defaults, user, project, system settings, environment variables, command-line flags.

~/.gemini/settings.json

User settings; .gemini/settings.json in a repo overrides them

Try it: JSON FormatterFrom the docs, not run by us
/etc/gemini-cli/settings.json

Linux system settings, which beat both user and project files

From the docs, not run by us
"model": { "name": "pro" }

Default model, nested under model.name

From the docs, not run by us
"general": { "defaultApprovalMode": "auto_edit" }

Start every session in this approval mode

From the docs, not run by us
"context": { "fileName": ["AGENTS.md", "GEMINI.md"] }

Read other instruction file names as well as GEMINI.md

Try it: AGENTS.md / CLAUDE.md GeneratorFrom the docs, not run by us
"env": { "KEY": "${MY_KEY:-dev}" }

Reference environment variables, with a fallback value, inside settings

Try it: env-to-jsonFrom the docs, not run by us
~/.gemini/GEMINI.md

Global context file, loaded before the GEMINI.md files in your project and its parents

From the docs, not run by us
@./docs/style.md

Import another Markdown file from inside a GEMINI.md

From the docs, not run by us

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-github

Add a stdio server to the project scope (the default)

Try it: MCP Config GeneratorFrom the docs, not run by us
gemini mcp add -s user --transport http docs https://api.example.com/mcp/

Add a remote HTTP server for every project

From the docs, not run by us
gemini mcp list

List servers and whether they connected

From the docs, not run by us
gemini mcp remove docs

Delete a server entry

From the docs, not run by us
"mcpServers": { "db": { "command": "node", "args": ["db.js"], "includeTools": ["query"] } }

Hand-written stdio entry that exposes only one tool

Try it: MCP Config ValidatorFrom the docs, not run by us
"httpUrl": "http://localhost:3000/mcp"

Use streamable HTTP; url means SSE and command means stdio

From the docs, not run by us
"trust": true

Skip confirmations for that server's tools (off by default)

From the docs, not run by us
gemini extensions install <source>

Install an extension from a GitHub URL or local path

From the docs, not run by us
gemini extensions list

Show installed extensions

From the docs, not run by us
gemini extensions update --all

Update every installed extension

From the docs, not run by us
gemini extensions new ./my-ext mcp-server

Scaffold an extension from the mcp-server template

From the docs, not run by us

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_db in mcpServers

    Use hyphens; tool names are built as mcp_<server>_<tool> and underscores make them ambiguous.

  • Setting "trust": true on every server to stop prompts

    Trust only servers you wrote or audited, and use includeTools to cut the rest down.

  • Using -y in new scripts

    It's deprecated; write --approval-mode yolo so the intent is explicit and survives removal.

  • Committing an API key inside .gemini/settings.json

    Reference it as $VAR or ${VAR} and keep the value in your shell or a secrets manager.