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.

AI CLI·55 commands·Last updated 2026-08-05
Back to AI CLI

Install & Auth 6

npm install -g @google/gemini-cli
Install globally via npm (Node 20+ required)
gemini --version
Verify install and show version
gemini
First run triggers browser OAuth sign-in
gemini --auth-method=api-key
Switch to API-key auth
export GEMINI_API_KEY="your-key"
Set API key env var (servers/CI)
export GOOGLE_GENAI_USE_VERTEXAI=true
Enterprise / Vertex AI auth

Run Modes 8

gemini
Launch 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 mcp
Manage MCP servers
gemini extensions
Manage Gemini CLI extensions
gemini skills
Manage agent skills (install/link/list)
gemini gemma
Local 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/login
Run in a fresh git worktree (--worktree)
gemini -s
Run tool calls in the configured sandbox (Docker/Podman)
gemini --skip-trust
Trust the current workspace for this session only
gemini --checkpointing
Enable per-edit snapshots, restorable via /restore
gemini -r latest
Resume the previous session (--resume, latest or index)
gemini --list-sessions
Print sessions for the current project and exit
gemini --delete-session 2
Delete a session by index
gemini --include-directories ../backend,../frontend
Add directories to the workspace map
gemini -o json "task"
Output format text/json/stream-json (json for scripting)
gemini -e context7
Restrict the active extension set (--extensions)
gemini -l
List installed extensions and exit (--list-extensions)
gemini --debug
Verbose debug logging (--debug/-d)

Session Slash Commands 14

/help
List all available commands
/model
Switch the active model (Pro/Flash, etc.)
/context
Show current conversation token usage
/compress
Summarize the conversation to free context (past 2M)
/clear
Reset the conversation
/save
Save the conversation to a checkpoint
/restore
Resume a saved conversation
/yolo
Skip all confirmation prompts (use with caution)
/mcp list
List configured MCP servers
/tools
List all available tools
/init
Generate a GEMINI.md for the project
/memory list
View loaded context files
/memory refresh
Reload GEMINI.md without restarting
/quit
Exit

MCP & Extensions 7

gemini mcp add <name> <url>
Add an MCP server
gemini mcp remove <name>
Remove an MCP server
gemini mcp list
List 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/mcp
Add an HTTP MCP server

GEMINI.md & Config 5

echo "Build: make build\nTest: go test ./..." > GEMINI.md
Write GEMINI.md at repo root, auto-loaded each session
@./docs/architecture.md
Inject a file/directory into the prompt with @
!git status
Run a shell command directly inside Gemini with !
echo ".env\nnode_modules/" > .geminiignore
Keep the agent away from secrets and large dirs
cat ~/.gemini/settings.json
Inspect 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