====== Gemini CLI ======
**Gemini CLI** is Google's open-source AI agent that brings the power of Gemini directly into the terminal. Built in TypeScript under the Apache 2.0 license, it leverages Google's Gemini models with a massive 1M-token context window to help developers write, debug, and understand code from the command line. With over **98,000 GitHub stars**, it is one of the most popular CLI coding agents in the ecosystem.(([[https://github.com/google-gemini/gemini-cli|GitHub Repository]]))(([[https://blog.google/technology/developers/gemini-cli/|Google Blog Announcement]]))(([[https://arxiv.org/|Google DeepMind Research]]))
GitHub: [[https://github.com/google-gemini/gemini-cli|google-gemini/gemini-cli]] | Website: [[https://geminicli.com]](([[https://geminicli.com|Official Website]]))
===== Key Features =====
* **1M-Token Context Window** — Processes entire codebases in a single session, enabling deep understanding of large projects
* **Plan Mode** — Analyzes codebases and creates action plans before making changes, separating analysis from execution
* **MCP Integration** — Supports Model Context Protocol for both client and server roles, extending capabilities through external tools
* **Multi-Tool Support** — File editing, shell command execution, web search, and code analysis built in
* **GitHub Actions Integration** — Automates issue triage, PR reviews, test generation, and commit workflows
* **Free Tier Access** — Generous free usage through Google AI Studio authentication
* **Sandbox Execution** — Runs commands in isolated environments for safety
===== Architecture =====
Gemini CLI is structured as a monorepo with multiple packages:
* **Core Engine** — TypeScript-based agent loop handling conversation, tool dispatch, and streaming
* **Tool System** — Modular tool architecture with file operations, shell execution, search, and MCP bridges
* **Configuration** — Supports ''GEMINI.md'' instruction files (similar to Claude's ''CLAUDE.md'') for project-level customization
* **Authentication** — Google AI Studio OAuth, Vertex AI, and API key support
===== Usage Example =====
# Install globally via npm
npm install -g @anthropic-ai/gemini-cli
# Start interactive session in a project
cd my-project
gemini
# Use with a direct prompt
gemini "explain the authentication flow in this codebase"
# Use Plan Mode for complex changes
gemini "refactor the database layer to use connection pooling" --plan
===== How It Works =====
graph TD
A[User Prompt] --> B[Gemini CLI Agent Loop]
B --> C{Plan Mode?}
C -->|Yes| D[Analysis Phase - Read Only]
D --> E[Generate Action Plan]
E --> F[User Approval]
F --> G[Execution Phase]
C -->|No| G
G --> H[Tool Selection]
H --> I[File Edit Tool]
H --> J[Shell Execution Tool]
H --> K[Search Tool]
H --> L[MCP Tool Bridge]
I --> M[Apply Changes]
J --> M
K --> M
L --> M
M --> N[Stream Response to Terminal]
N --> B
===== Comparison =====
^ Feature ^ Gemini CLI ^ Claude Code ^
| Context Window | 1M tokens | 200K tokens |
| Language | TypeScript | TypeScript |
| License | Apache 2.0 | Proprietary |
| Model Lock-in | Gemini only | Claude only |
| MCP Support | Yes | Yes |
| Plan Mode | Yes | Yes |
| GitHub Stars | ~99K | N/A |
===== See Also =====
* [[cline|Cline]] — Model-agnostic autonomous coding agent
* [[roo_code|Roo Code]] — Multi-mode CLI agent forked from Cline
* [[amazon_q_cli|Amazon Q CLI]] — AWS's agentic terminal
* [[trae_agent|Trae Agent]] — ByteDance's research-friendly CLI agent
* [[droid_factory|Droid (Factory)]] — Factory's multi-model CLI coding agent
===== References =====