Gemini CLI
Gemini CLI is Google's official open-source terminal AI agent, announced and released in June 2025. It is not a chat wrapper for the command line — it is an autonomous coding agent that plans and executes multi-step tasks using tools, runs in your terminal, and has access to your filesystem, shell, and the web. It is powered by Gemini 2.5 Pro and offers the largest publicly available context window (1M tokens) of any terminal agent.
Installation
Gemini CLI requires Node.js. Install with:
npm install -g @google/gemini-cliAfter installation, run gemini in your terminal and authenticate with your Google account. For personal Google accounts, Gemini CLI is free — it uses Gemini 2.5 Pro under your account quota. For higher throughput or production use, connect an API key with billing enabled.
ReAct Loop — How It Operates
Gemini CLI operates through a ReAct (Reason + Act) loop. For any task you give it:
- Reason: The model analyses the task, reviews relevant context, and decides on a plan.
- Act: It uses a tool — reads a file, runs a shell command, searches the web — to gather information or make a change.
- Observe: It reads the output of the action.
- Repeat: Reasons about what it learned, decides the next action, and continues until the task is complete.
This loop enables genuinely complex multi-step tasks — “fix the failing test in this repository” might involve reading test output, tracing through source files, identifying the root cause, editing a function, re-running tests, and confirming the fix — all without human intervention at each step.
Built-In Tools
- File read/write: Read any file in your project, create new files, edit existing ones.
- Shell execution: Run arbitrary shell commands — npm install, pytest, git diff, make build — and read the output.
- Google Search: Search the web and read results to answer questions or look up documentation.
- Web browsing: Fetch and read the full content of specific web pages — useful for reading docs, checking an API reference, or reviewing a library's README.
MCP Server Support
Gemini CLI supports MCP (Model Context Protocol) — you can connect any local or remote MCP server to extend the agent with additional tools. This allows integration with databases, proprietary internal APIs, cloud services, or any external system that exposes an MCP interface. The same MCP server ecosystem used with Claude Code or other MCP-compatible tools works with Gemini CLI.
1M Token Context Window
At launch, Gemini CLI offered the largest context window of any publicly available terminal AI agent — one million tokens. In practice, this means you can include entire codebases, large log files, extensive documentation, or lengthy conversation histories as context without worrying about truncation. For large legacy codebases or complex debugging sessions spanning many files, this is a meaningful practical advantage.
Extensions
Third-party developers can build Gemini CLI Extensions to integrate external services directly into the CLI agent. Extensions follow a standardised format and can add new tools, connectors, or workflows — similar to the extension ecosystem for other developer tools. This was introduced later in 2025 and the ecosystem is actively growing.
Common Use Cases
- Bug fixing: “The test at line 47 in auth_test.py is failing — find and fix the root cause.”
- Feature implementation: “Add pagination support to the /users endpoint following the existing pattern in /posts.”
- Code review: “Review all changes in the current git diff and summarise potential issues.”
- Documentation: “Generate docstrings for all public functions in src/utils/ that are missing them.”
- Dependency updates: “Upgrade all packages to their latest minor versions and run tests to check for breakage.”
Checklist
- How do you install Gemini CLI, and what runtime does it require?
- What is the ReAct loop and how does it enable multi-step autonomous tasks?
- What four built-in tools does Gemini CLI provide to its agent?
- What is the context window size of Gemini CLI, and why does it matter?
- How does MCP support extend the capabilities of Gemini CLI beyond its built-in tools?