Gemini CLI — Google's AI in Your Terminal
Gemini CLI — Google AI in Your Terminal
Section titled “Gemini CLI — Google AI in Your Terminal”Gemini CLI is Google’s open-source command-line AI agent, powered by Gemini 2.5 Pro with a 1 million token context window. It brings the same powerful AI that drives Google’s products to your terminal for coding, analysis, and automation tasks.
Gemini CLI is free and open-source — Google offers a generous free tier via Google AI Studio API keys.
Installation
Section titled “Installation”# Install via npmnpm install -g @google/gemini-cli
# Or run without installing (npx)npx @google/gemini-cli
# Authenticategemini auth login# Follow the browser flow to connect your Google account / API keyQuick Start
Section titled “Quick Start”# Start interactive session in your projectcd my-projectgemini
# Ask a one-shot questiongemini "Explain what this codebase does"
# Give it a taskgemini "Add input validation to all API endpoints and write tests"Key Features
Section titled “Key Features”1M Token Context Window
Section titled “1M Token Context Window”With Gemini 2.5 Flash’s 1 million token window, Gemini CLI can:
- Load your entire project — not just open files
- Process large log files or exported data
- Read multiple repositories simultaneously
- Understand complex dependency graphs
# Load an entire large projectgemini --include "**/*.ts,**/*.json" "Find all security vulnerabilities"Google Search Grounding
Section titled “Google Search Grounding”Gemini CLI can search Google in real time during tasks:
gemini "Update the AWS SDK v2 calls to v3 syntax"# → Searches for AWS SDK v3 migration guide# → Applies up-to-date patterns to your codeAgentic Mode
Section titled “Agentic Mode”Gemini CLI can take autonomous actions:
- Read and write files
- Run shell commands
- Execute tests and fix failures
- Navigate directory structures
gemini "Refactor the authentication module to use JWT and add comprehensive tests"# Reads auth files → Plans changes → Edits files → Runs tests → Fixes failuresMCP Support
Section titled “MCP Support”Gemini CLI supports the Model Context Protocol (MCP), allowing it to connect to:
- Databases (read schema, query data)
- APIs (fetch live data)
- Documentation servers
- Internal tools
# Start with MCP server for database accessgemini --mcp-server postgres://localhost/mydb "Optimize these slow queries"Gemini CLI vs Claude Code
Section titled “Gemini CLI vs Claude Code”| Feature | Gemini CLI | Claude Code |
|---|---|---|
| Context window | 1M tokens (Flash) / 2M (Pro) | 200K tokens |
| Search grounding | Yes (Google Search) | Yes (Web search) |
| Model | Gemini 2.5 Flash/Pro | Claude 3.7 Sonnet |
| MCP support | Yes | Yes |
| Open source | Yes | Yes |
| Free tier | Yes (generous via AI Studio) | Requires Claude Pro |
| File operations | Yes | Yes |
| Shell commands | Yes | Yes |
| Best for | Large repos, GCP projects | General coding, AWS |
Free Tier
Section titled “Free Tier”Gemini CLI is free to use with Google AI Studio API keys:
- Gemini 2.5 Flash: Free tier includes 1,500 requests/day
- Gemini 2.5 Pro: Free tier includes 50 requests/day
For heavier usage, the Gemini API is billed per token (significantly cheaper than OpenAI).
Configuration
Section titled “Configuration”# Set default modelgemini config set model gemini-2.5-flash
# Set your project context file (like CLAUDE.md)cat > GEMINI.md << 'EOF'# Project Context- Stack: Node.js + TypeScript + PostgreSQL- Test runner: Jest- Lint: ESLint + Prettier- Always run `npm test` after changesEOF
# Enable Google Search groundinggemini config set search trueCommon Use Cases
Section titled “Common Use Cases”# Understand a new codebasegemini "Give me a tour of this codebase — what does it do, how is it structured?"
# Fix a failing testgemini "The test in auth.test.ts line 42 is failing. Fix the underlying issue."
# Security auditgemini "Review this codebase for OWASP Top 10 vulnerabilities"
# Generate documentationgemini "Generate OpenAPI 3.0 spec for all API routes in src/routes/"
# Upgrade dependenciesgemini "Upgrade all dependencies to latest versions and fix any breaking changes"Useful Links
Section titled “Useful Links”- Gemini CLI GitHub
- Google AI Studio (API Key)
- Gemini API Docs
- Google Anti-Gravity — Google’s IDE-based coding tool