Home
Login

Gemini CLI是谷歌官方开源的AI命令行工具,将Gemini AI能力直接集成到终端中

Apache-2.0TypeScript 10.0kgoogle-geminigemini-cli Last Updated: 2025-06-25

Gemini CLI - 谷歌官方开源AI命令行工具

项目概述

Gemini CLI 是谷歌官方推出的开源AI命令行工具,它将强大的Gemini AI能力直接集成到你的终端中。这个工具旨在连接你的开发工具,理解你的代码,并加速你的工作流程。

项目地址: https://github.com/google-gemini/gemini-cli

核心功能

🔍 代码理解与编辑

  • 大型代码库查询和编辑: 支持在Gemini的100万token上下文窗口内外查询和编辑大型代码库
  • 智能代码理解: 深度理解项目架构和代码逻辑
  • 代码重构与优化: 协助进行代码重构和性能优化

🚀 应用生成

  • 多模态应用生成: 利用Gemini的多模态能力,从PDF文档或手绘草图生成新应用
  • 快速原型开发: 快速创建应用原型和演示

⚙️ 自动化操作任务

  • Git操作自动化: 处理复杂的git rebase、查询pull request等操作
  • 项目管理: 自动化项目管理任务
  • 工作流优化: 简化日常开发工作流程

🔧 工具集成与扩展

  • MCP服务器支持: 通过工具和MCP服务器连接新功能
  • 媒体生成集成: 支持与Imagen、Veo或Lyria的媒体生成功能集成
  • Google搜索集成: 内置Google搜索工具,为查询提供实时信息支持

安装与设置

系统要求

  • Node.js: 需要Node.js 18或更高版本

安装方式

方式一:直接运行(推荐)

npx https://github.com/google-gemini/gemini-cli

方式二:全局安装

npm install -g @google/gemini-cli

身份验证

个人Google账户登录

当提示时,使用个人Google账户登录,这将为你提供:

  • 每分钟最多60个模型请求
  • 每天最多1,000个模型请求(使用Gemini 2.5 Pro)

API密钥配置(高级用户)

如果需要使用特定模型或更高的请求容量:

  1. Google AI Studio生成API密钥
  2. 设置环境变量:
export GEMINI_API_KEY="YOUR_API_KEY"

使用示例

新项目创建

$ cd new-project/
$ gemini
> Write me a Gemini Discord bot that answers questions using a FAQ.md file I will provide

现有项目分析

$ 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

常见使用场景

🏗️ 系统架构分析

> Describe the main pieces of this system's architecture.
> What security mechanisms are in place?

🐛 代码开发与调试

> Implement a first draft for GitHub issue #123.
> Help me migrate this codebase to the latest version of Java. Start with a plan.

📊 项目管理与协作

> Make me a slide deck showing the git history from the last 7 days, grouped by feature and team member.
> Make a full-screen web app for a wall display to show our most interacted-with GitHub issues.

🛠️ 自动化任务

> Convert all the images in this directory to png, and rename them to use dates from the exif data.
> Organise my PDF invoices by month of expenditure.

技术特性

🧠 AI能力

  • 大上下文处理: 支持100万token的超大上下文窗口
  • 多模态理解: 支持文本、图像、代码等多种数据类型
  • 自然语言交互: 支持自然语言查询和指令

🔧 集成能力

  • MCP协议支持: 支持模型上下文协议(Model Context Protocol)
  • 企业工具集成: 可与企业协作套件集成
  • 本地系统工具: 支持本地系统工具的集成

🎨 用户体验

  • 颜色主题选择: 支持多种终端颜色主题
  • 交互式界面: 提供友好的命令行交互体验
  • 实时反馈: 提供实时的AI响应和建议

文档与支持

📚 官方文档

🔧 开发者资源

项目意义

Gemini CLI 代表了AI与开发工具集成的新趋势,它不仅仅是一个简单的AI聊天工具,而是一个完整的AI驱动的开发环境。通过将Gemini的强大AI能力直接集成到命令行中,开发者可以:

  1. 提升开发效率: 通过AI辅助快速理解和修改代码
  2. 简化复杂任务: 将复杂的开发任务转化为简单的自然语言指令
  3. 增强创造力: 利用AI的创意能力快速原型开发和问题解决
  4. 优化工作流程: 自动化重复性任务,专注于更有价值的工作

Gemini CLI 项目体现了谷歌在AI工具实用化方面的努力,为开发者社区提供了一个强大而灵活的AI编程助手。

Star History Chart