2025-05-14 13:51:17 -07:00
# Gemini CLI
Initial commit of Gemini Code CLI
This commit introduces the initial codebase for the Gemini Code CLI, a command-line interface designed to facilitate interaction with the Gemini API for software engineering tasks.
The code was migrated from a previous git repository as a single squashed commit.
Core Features & Components:
* **Gemini Integration:** Leverages the `@google/genai` SDK to interact with the Gemini models, supporting chat history, streaming responses, and function calling (tools).
* **Terminal UI:** Built with Ink (React for CLIs) providing an interactive chat interface within the terminal, including input prompts, message display, loading indicators, and tool interaction elements.
* **Tooling Framework:** Implements a robust tool system allowing Gemini to interact with the local environment. Includes tools for:
* File system listing (`ls`)
* File reading (`read-file`)
* Content searching (`grep`)
* File globbing (`glob`)
* File editing (`edit`)
* File writing (`write-file`)
* Executing bash commands (`terminal`)
* **State Management:** Handles the streaming state of Gemini responses and manages the conversation history.
* **Configuration:** Parses command-line arguments (`yargs`) and loads environment variables (`dotenv`) for setup.
* **Project Structure:** Organized into `core`, `ui`, `tools`, `config`, and `utils` directories using TypeScript. Includes basic build (`tsc`) and start scripts.
This initial version establishes the foundation for a powerful CLI tool enabling developers to use Gemini for coding assistance directly in their terminal environment.
---
Created by yours truly: __Gemini Code__
2025-04-15 21:41:08 -07:00
2025-05-14 13:51:17 -07:00
[](https://github.com/google-gemini/gemini-cli/actions/workflows/ci.yml)
2025-08-10 14:52:14 -04:00
[](https://www.npmjs.com/package/@google/gemini -cli)
[](https://github.com/google-gemini/gemini-cli/blob/main/LICENSE)
2025-04-21 15:47:53 -07:00
2025-06-24 15:31:40 -07:00

2025-08-10 14:52:14 -04:00
Gemini CLI is an open-source AI agent that brings the power of Gemini directly into your terminal. It provides lightweight access to Gemini, giving you the most direct path from your prompt to our model.
2025-06-25 18:12:31 +08:00
2025-08-10 14:52:14 -04:00
## 🚀 Why Gemini CLI?
2025-06-25 18:12:31 +08:00
2025-08-10 14:52:14 -04:00
- **🎯 Free tier**: 60 requests/min and 1,000 requests/day with personal Google account
- **🧠 Powerful Gemini 2.5 Pro**: Access to 1M token context window
- **🔧 Built-in tools**: Google Search grounding, file operations, shell commands, web fetching
- **🔌 Extensible**: MCP (Model Context Protocol) support for custom integrations
- **💻 Terminal-first**: Designed for developers who live in the command line
- **🛡️ Open source**: Apache 2.0 licensed
2025-06-25 18:12:31 +08:00
2025-08-10 14:52:14 -04:00
## 📦 Installation
2025-05-15 20:04:33 -07:00
2025-08-10 14:52:14 -04:00
### Quick Install
2025-07-21 23:45:24 +02:00
2025-08-10 14:52:14 -04:00
#### Run instantly with npx
2025-07-21 23:45:24 +02:00
2025-08-10 14:52:14 -04:00
```bash
# Using npx (no installation required)
npx https://github.com/google-gemini/gemini-cli
```
#### Install globally with npm
```bash
npm install -g @google/gemini -cli
```
2025-06-21 16:18:23 -07:00
2025-08-10 14:52:14 -04:00
#### Install globally with Homebrew (macOS/Linux)
2025-06-21 16:18:23 -07:00
2025-08-10 14:52:14 -04:00
```bash
brew install gemini-cli
```
2025-06-25 17:46:05 +08:00
2025-08-10 14:52:14 -04:00
#### System Requirements
2025-07-14 18:21:40 +02:00
2025-08-10 14:52:14 -04:00
- Node.js version 20 or higher
- macOS, Linux, or Windows
2025-07-14 18:21:40 +02:00
2025-08-10 14:52:14 -04:00
## 📋 Key Features
2025-06-25 17:46:05 +08:00
2025-08-10 14:52:14 -04:00
With Gemini CLI you can:
2025-07-21 23:45:24 +02:00
2025-08-10 14:52:14 -04:00
- **Code Understanding & Generation**
- Query and edit large codebases
- Generate new apps from PDFs, images, or sketches using multimodal capabilities
- Debug issues and troubleshoot with natural language
- **Automation & Integration**
- Automate operational tasks like querying pull requests or handling complex rebases
- Use MCP servers to connect new capabilities, including [media generation with Imagen, Veo or Lyria ](https://github.com/GoogleCloudPlatform/vertex-ai-creative-studio/tree/main/experiments/mcp-genmedia )
- Run non-interactively in scripts for workflow automation
- **Advanced Capabilities**
- Ground your queries with built-in [Google Search ](https://ai.google.dev/gemini-api/docs/grounding ) for real-time information
- Conversation checkpointing to save and resume complex sessions
- Custom context files (GEMINI.md) to tailor behavior for your projects
2025-07-21 23:45:24 +02:00
2025-08-10 14:52:14 -04:00
- **🔗 GitHub Integration**
- Use the Gemini CLI GitHub Action for automated PR reviews
- Automated issue triage and on-demand AI assistance directly in your repositories
- Seamless integration with your GitHub workflows
2025-07-21 23:45:24 +02:00
2025-08-10 14:52:14 -04:00
## 🔐 Authentication Options
2025-07-21 23:45:24 +02:00
2025-08-10 14:52:14 -04:00
Choose the authentication method that best fits your needs:
2025-07-21 23:45:24 +02:00
2025-08-10 14:52:14 -04:00
### Option 1: OAuth login (Using your Google Account)
2025-07-21 23:45:24 +02:00
2025-08-10 14:52:14 -04:00
**✨ Best for:** Individual developers as well as anyone who has a Gemini Code Assist License. (see [quota limits and terms of service ](https://cloud.google.com/gemini/docs/quotas ) for details)
2025-06-22 20:19:13 -04:00
2025-08-10 14:52:14 -04:00
**Benefits:**
2025-06-22 20:19:13 -04:00
2025-08-10 14:52:14 -04:00
- **Free tier**: 60 requests/min and 1,000 requests/day
- **Gemini 2.5 Pro** with 1M token context window
- **No API key management** - just sign in with your Google account
- **Automatic updates** to latest models
2025-06-22 20:19:13 -04:00
2025-08-10 14:52:14 -04:00
#### Start Gemini CLI, then choose OAuth and follow the browser authentication flow when prompted
2025-06-22 20:19:13 -04:00
2025-08-10 14:52:14 -04:00
```bash
gemini
```
2025-06-22 20:19:13 -04:00
2025-08-10 14:52:14 -04:00
#### If you are using a paid Code Assist License from your organization, remember to set the Google Cloud Project
2025-05-30 12:20:12 -07:00
2025-08-10 14:52:14 -04:00
```bash
# Set your Google Cloud Project
export GOOGLE_CLOUD_PROJECT="YOUR_PROJECT_NAME"
gemini
```
2025-07-01 14:16:40 -05:00
2025-08-10 14:52:14 -04:00
### Option 2: Gemini API Key
2025-07-07 11:43:27 -07:00
2025-08-10 14:52:14 -04:00
**✨ Best for:** Developers who need specific model control or paid tier access
2025-07-07 11:43:27 -07:00
2025-08-10 14:52:14 -04:00
**Benefits:**
2025-07-07 11:43:27 -07:00
2025-08-10 14:52:14 -04:00
- **Free tier**: 100 requests/day with Gemini 2.5 Pro
- **Model selection**: Choose specific Gemini models
- **Usage-based billing**: Upgrade for higher limits when needed
2025-07-07 11:43:27 -07:00
2025-08-10 14:52:14 -04:00
```bash
# Get your key from https://aistudio.google.com/apikey
export GEMINI_API_KEY="YOUR_API_KEY"
gemini
```
2025-07-07 11:43:27 -07:00
2025-08-10 14:52:14 -04:00
### Option 3: Vertex AI
2025-06-23 13:02:52 -07:00
2025-08-10 14:52:14 -04:00
**✨ Best for:** Enterprise teams and production workloads
2025-05-30 12:20:12 -07:00
2025-08-10 14:52:14 -04:00
**Benefits:**
2025-05-30 12:20:12 -07:00
2025-08-10 14:52:14 -04:00
- **Enterprise features**: Advanced security and compliance
- **Scalable**: Higher rate limits with billing account
- **Integration**: Works with existing Google Cloud infrastructure
2025-06-25 18:12:31 +08:00
2025-08-10 14:52:14 -04:00
```bash
# Get your key from Google Cloud Console
export GOOGLE_API_KEY="YOUR_API_KEY"
export GOOGLE_GENAI_USE_VERTEXAI=true
2025-06-25 10:03:07 -06:00
gemini
2025-05-30 12:20:12 -07:00
```
2025-08-10 14:52:14 -04:00
For Google Workspace accounts and other authentication methods, see the [authentication guide ](./docs/cli/authentication.md ).
2025-05-30 12:20:12 -07:00
2025-08-10 14:52:14 -04:00
## 🚀 Getting Started
### Basic Usage
#### Start in current directory
```bash
2025-06-25 10:03:07 -06:00
gemini
2025-05-30 12:20:12 -07:00
```
2025-08-10 14:52:14 -04:00
#### Include multiple directories
```bash
gemini --include-directories ../lib,../docs
```
#### Use specific model
```bash
gemini -m gemini-2.5-flash
```
#### Non-interactive mode for scripts
2025-06-23 17:55:24 -04:00
2025-08-10 14:52:14 -04:00
```bash
gemini -p "Explain the architecture of this codebase"
```
### Quick Examples
2025-06-23 15:07:18 +08:00
2025-08-10 14:52:14 -04:00
#### Start a new project
2025-06-26 03:00:36 +08:00
2025-08-10 14:52:14 -04:00
````bash
cd new-project/
gemini
> Write me a Discord bot that answers questions using a FAQ.md file I will provide
2025-06-26 03:00:36 +08:00
2025-08-10 14:52:14 -04:00
#### Analyze existing code
```bash
git clone https://github.com/google-gemini/gemini-cli
cd gemini-cli
gemini
> Give me a summary of all of the changes that went in yesterday
````
## 🔗 GitHub Integration
2025-08-06 13:01:42 +09:00
Integrate Gemini CLI directly into your GitHub workflows with the [**Gemini CLI GitHub Action** ](https://github.com/google-github-actions/run-gemini-cli ). Key features include:
- **Pull Request Reviews**: Automatically review pull requests when they're opened.
- **Issue Triage**: Automatically triage and label GitHub issues.
- **On-demand Collaboration**: Mention `@gemini-cli` in issues and pull requests for assistance and task delegation.
- **Custom Workflows**: Set up your own scheduled tasks and event-driven automations.
2025-08-10 14:52:14 -04:00
## 📚 Documentation
2025-06-23 15:07:18 +08:00
2025-08-10 14:52:14 -04:00
### Getting Started
2025-06-23 15:07:18 +08:00
2025-08-10 14:52:14 -04:00
- [**Quickstart Guide** ](./docs/cli/index.md ) - Get up and running quickly
- [**Authentication Setup** ](./docs/cli/authentication.md ) - Detailed auth configuration
- [**Configuration Guide** ](./docs/cli/configuration.md ) - Settings and customization
- [**Keyboard Shortcuts** ](./docs/keyboard-shortcuts.md ) - Productivity tips
2025-06-23 15:07:18 +08:00
2025-08-10 14:52:14 -04:00
### Core Features
2025-06-23 15:07:18 +08:00
2025-08-10 14:52:14 -04:00
- [**Commands Reference** ](./docs/cli/commands.md ) - All slash commands (`/help` , `/chat` , `/mcp` , etc.)
- [**Checkpointing** ](./docs/checkpointing.md ) - Save and resume conversations
- [**Memory Management** ](./docs/tools/memory.md ) - Using GEMINI.md context files
- [**Token Caching** ](./docs/cli/token-caching.md ) - Optimize token usage
2025-06-23 15:07:18 +08:00
2025-08-10 14:52:14 -04:00
### Tools & Extensions
2025-07-28 16:54:09 +01:00
2025-08-10 14:52:14 -04:00
- [**Built-in Tools Overview** ](./docs/tools/index.md )
- [File System Operations ](./docs/tools/file-system.md )
- [Shell Commands ](./docs/tools/shell.md )
- [Web Fetch & Search ](./docs/tools/web-fetch.md )
- [Multi-file Operations ](./docs/tools/multi-file.md )
- [**MCP Server Integration** ](./docs/tools/mcp-server.md ) - Extend with custom tools
- [**Custom Extensions** ](./docs/extension.md ) - Build your own commands
2025-07-28 16:54:09 +01:00
2025-08-10 14:52:14 -04:00
### Advanced Topics
2025-07-28 16:54:09 +01:00
2025-08-10 14:52:14 -04:00
- [**Architecture Overview** ](./docs/architecture.md ) - How Gemini CLI works
- [**IDE Integration** ](./docs/extension.md ) - VS Code companion
- [**Sandboxing & Security** ](./docs/sandbox.md ) - Safe execution environments
- [**Enterprise Deployment** ](./docs/deployment.md ) - Docker, system-wide config
- [**Telemetry & Monitoring** ](./docs/telemetry.md ) - Usage tracking
- [**Tools API Development** ](./docs/core/tools-api.md ) - Create custom tools
2025-07-28 16:54:09 +01:00
2025-08-10 14:52:14 -04:00
### Configuration & Customization
2025-07-28 16:54:09 +01:00
2025-08-10 14:52:14 -04:00
- [**Settings Reference** ](./docs/cli/configuration.md ) - All configuration options
- [**Theme Customization** ](./docs/cli/themes.md ) - Visual customization
- [**.gemini Directory** ](./docs/gemini-ignore.md ) - Project-specific settings
- [**Environment Variables** ](./docs/cli/configuration.md#environment-variables )
2025-07-28 16:54:09 +01:00
2025-08-10 14:52:14 -04:00
### Troubleshooting & Support
2025-07-28 16:54:09 +01:00
2025-08-10 14:52:14 -04:00
- [**Troubleshooting Guide** ](./docs/troubleshooting.md ) - Common issues and solutions
- [**FAQ** ](./docs/troubleshooting.md#frequently-asked-questions ) - Quick answers
- Use `/bug` command to report issues directly from the CLI
2025-06-23 15:07:18 +08:00
2025-08-10 14:52:14 -04:00
### Using MCP Servers
Configure MCP servers in `~/.gemini/settings.json` to extend Gemini CLI with custom tools:
2025-06-23 15:07:18 +08:00
```text
2025-08-10 14:52:14 -04:00
> @github List my open pull requests
> @slack Send a summary of today's commits to #dev channel
> @database Run a query to find inactive users
2025-06-23 15:07:18 +08:00
```
2025-08-10 14:52:14 -04:00
See the [MCP Server Integration guide ](./docs/tools/mcp-server.md ) for setup instructions.
2025-06-23 15:07:18 +08:00
2025-08-10 14:52:14 -04:00
## 🤝 Contributing
2025-06-23 15:07:18 +08:00
2025-08-10 14:52:14 -04:00
We welcome contributions! Gemini CLI is fully open source (Apache 2.0), and we encourage the community to:
2025-06-23 15:07:18 +08:00
2025-08-10 14:52:14 -04:00
- Report bugs and suggest features
- Improve documentation
- Submit code improvements
- Share your MCP servers and extensions
2025-06-23 15:07:18 +08:00
2025-08-10 14:52:14 -04:00
See our [Contributing Guide ](./CONTRIBUTING.md ) for development setup, coding standards, and how to submit pull requests.
2025-06-23 15:07:18 +08:00
2025-08-10 14:52:14 -04:00
Check our [Official Roadmap ](https://github.com/orgs/google-gemini/projects/11/ ) for planned features and priorities.
2025-06-23 15:07:18 +08:00
2025-08-10 14:52:14 -04:00
## 📖 Resources
- **[Official Roadmap ](./ROADMAP.md )** - See what's coming next
- **[NPM Package ](https://www.npmjs.com/package/@google/gemini-cli )** - Package registry
- **[GitHub Issues ](https://github.com/google-gemini/gemini-cli/issues )** - Report bugs or request features
- **[Security Advisories ](https://github.com/google-gemini/gemini-cli/security/advisories )** - Security updates
2025-06-23 15:07:18 +08:00
2025-06-29 19:11:58 +05:30
### Uninstall
2025-08-10 14:52:14 -04:00
See the [Uninstall Guide ](docs/Uninstall.md ) for removal instructions.
2025-06-29 19:11:58 +05:30
2025-08-10 14:52:14 -04:00
## 📄 Legal
2025-06-02 09:42:24 -07:00
2025-08-10 14:52:14 -04:00
- **License**: [Apache License 2.0 ](LICENSE )
- **Terms of Service**: [Terms & Privacy ](./docs/tos-privacy.md )
- **Security**: [Security Policy ](SECURITY.md )
2025-08-01 12:12:32 -04:00
2025-08-10 14:52:14 -04:00
---
2025-08-01 12:12:32 -04:00
2025-08-10 14:52:14 -04:00
<p align="center">
Built with ❤️ by Google and the open source community
</p>