Gemini CLI Cheatsheet - Google Terminal AI Agent Full Reference
All Gemini CLI terminal AI agent commands in one place — from install & auth to headless exec, approval modes, and MCP/extensions — organized by scenario. Copy and go.
Back to AI CLIInstall & Auth 6
npm install -g @google/gemini-cliInstall globally via npm (Node 20+ required)
gemini --versionVerify install and show version
geminiFirst run triggers browser OAuth sign-in
gemini --auth-method=api-keySwitch to API-key auth
export GEMINI_API_KEY="your-key"Set API key env var (servers/CI)
export GOOGLE_GENAI_USE_VERTEXAI=trueEnterprise / Vertex AI auth
Run Modes 8
geminiLaunch the interactive TUI agent (default)
gemini "Refactor the user-auth module"Launch the TUI seeded with a prompt
gemini -p "Explain this function"Headless mode: print and exit (--prompt)
gemini -i "Implement the cache first"Seed a prompt then stay interactive (--prompt-interactive)
gemini mcpManage MCP servers
gemini extensionsManage Gemini CLI extensions
gemini skillsManage agent skills (install/link/list)
gemini gemmaLocal Gemma model routing (setup/start/stop/status)
Global Flags 15
gemini -m gemini-2.5-pro "task"Override the model for one invocation (-m/--model)
gemini -y "Refactor the whole module"Auto-approve all actions (--yolo; prefer --approval-mode=yolo)
gemini --approval-mode plan "Explore architecture"Read-only plan mode (default/auto_edit/yolo/plan)
gemini -w feat/loginRun in a fresh git worktree (--worktree)
gemini -sRun tool calls in the configured sandbox (Docker/Podman)
gemini --skip-trustTrust the current workspace for this session only
gemini --checkpointingEnable per-edit snapshots, restorable via /restore
gemini -r latestResume the previous session (--resume, latest or index)
gemini --list-sessionsPrint sessions for the current project and exit
gemini --delete-session 2Delete a session by index
gemini --include-directories ../backend,../frontendAdd directories to the workspace map
gemini -o json "task"Output format text/json/stream-json (json for scripting)
gemini -e context7Restrict the active extension set (--extensions)
gemini -lList installed extensions and exit (--list-extensions)
gemini --debugVerbose debug logging (--debug/-d)
Session Slash Commands 14
/helpList all available commands
/modelSwitch the active model (Pro/Flash, etc.)
/contextShow current conversation token usage
/compressSummarize the conversation to free context (past 2M)
/clearReset the conversation
/saveSave the conversation to a checkpoint
/restoreResume a saved conversation
/yoloSkip all confirmation prompts (use with caution)
/mcp listList configured MCP servers
/toolsList all available tools
/initGenerate a GEMINI.md for the project
/memory listView loaded context files
/memory refreshReload GEMINI.md without restarting
/quitExit
MCP & Extensions 7
gemini mcp add <name> <url>Add an MCP server
gemini mcp remove <name>Remove an MCP server
gemini mcp listList MCP servers
gemini mcp enable <name>Enable an MCP server
gemini mcp disable <name>Disable an MCP server
gemini extensions install <name>Install a Gemini CLI extension
gemini mcp add --url https://example.com/mcpAdd an HTTP MCP server
GEMINI.md & Config 5
echo "Build: make build\nTest: go test ./..." > GEMINI.mdWrite GEMINI.md at repo root, auto-loaded each session
@./docs/architecture.mdInject a file/directory into the prompt with @
!git statusRun a shell command directly inside Gemini with !
echo ".env\nnode_modules/" > .geminiignoreKeep the agent away from secrets and large dirs
cat ~/.gemini/settings.jsonInspect user-level config (model/MCP/tool perms)
💡 Tips
- The personal Google account free tier is 1000 requests/day and it is open-source/forkable — the default choice for long-context (2M) and self-hosted use.
- For headless automation use `gemini -p -o json` with --approval-mode=yolo (preferred over the deprecated -y) for unattended tasks.
- Write build/test commands into GEMINI.md; Gemini auto-loads it each session — more stable than repeating prompts. Use .geminiignore to block .env etc.
- Past the 2M ceiling use /compress to keep going; use /save + /restore to preserve sessions across days.
Official References
Commands are compiled from the official docs below. Click to verify the latest usage.
Maintained by LaoHand
Publicly updated on Aug 5, 2026, continuously proofread against official docs.
Found an error? Report it
Wrong command or description? Open an issue to help us fix it.
Found an error? Report it