> gemini cli
Google's open-source terminal AI agent — a generous free tier, slash commands, GEMINI.md project context, MCP servers, and headless mode for scripts
// getting started
5 commandsInstall the Gemini CLI
$ npm install -g @google/gemini-cliStart an interactive session in your project
$ geminiPick which model answers your prompts
$ gemini -m flashAdd folders outside the project to the workspace
$ gemini --include-directories ../shared-lib,../api-typesUpgrade or switch to a preview release channel
$ npm install -g @google/gemini-cli@latest// authentication
5 commandsSign in with a Google account for the free tier
$ geminiAuthenticate with a Gemini API key
$ export GEMINI_API_KEY=your-api-keyConnect to Vertex AI with application-default credentials
$ unset GOOGLE_API_KEY GEMINI_API_KEYAuthenticate Vertex AI with a service account key
$ unset GOOGLE_API_KEY GEMINI_API_KEYSwitch the authentication method mid-session
$ /auth// sessions & context
7 commandsResume your most recent session
$ gemini --resumeList, resume, and delete specific sessions
$ gemini --list-sessionsSave and restore named conversation checkpoints
$ /chat save before-refactorInject a file or folder into your prompt
$ @src/auth.ts explain the bug on line 42Give the project persistent instructions with GEMINI.md
$ /initUpdate loaded memory without restarting
$ /memory showHide files from the agent with .geminiignore
$ printf '*.log\napikeys.txt\n/packages/\n' > .geminiignore// headless & scripting
5 commandsRun a one-off prompt without the interface
$ gemini -p "summarize README.md"Pipe file or command output into Gemini
$ cat error.log | gemini -p "find the root cause"Get machine-readable JSON output
$ gemini -p "list the exported functions" --output-format json | jq -r '.response'Seed an interactive session with a first prompt
$ gemini -i "explain the architecture of this repo"Auto-approve tool calls for automation
$ gemini -p "fix the failing test" --approval-mode auto_edit// slash commands
5 commands// configuration
5 commandsFind and layer your settings.json files
$ cat ~/.gemini/settings.jsonSet common options in settings.json
$ /settingsConfigure the CLI with environment variables
$ export GEMINI_MODEL=gemini-2.5-flashMake agent file edits reversible with checkpointing
$ gemini --checkpointingOpt out of usage telemetry
$ /privacy// mcp & extensions
5 commandsAdd a local MCP server from the command line
$ gemini mcp add github npx -y @modelcontextprotocol/server-githubAdd a remote HTTP or SSE MCP server
$ gemini mcp add --transport http docs https://api.example.com/mcpConfigure MCP servers in settings.json
$ /mcpList and refresh MCP servers and tools
$ gemini mcp listInstall and manage extensions
$ gemini extensions install https://github.com/gemini-cli-extensions/security