gemini-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Gemini CLI

Gemini CLI

Query and edit large codebases, generate apps from images or PDFs, and automate complex workflows - all from your terminal with Gemini AI.
通过终端借助Gemini AI查询和编辑大型代码库、从图片或PDF生成应用、自动化复杂工作流。

Quick Start

快速开始

bash
undefined
bash
undefined

Install globally

全局安装

npm install -g @google/gemini-cli
npm install -g @google/gemini-cli

Run (starts interactive session)

运行(启动交互式会话)

gemini
gemini

Or run without install

或无需安装直接运行

npx @google/gemini-cli
undefined
npx @google/gemini-cli
undefined

Authentication

身份验证

On first run, select authentication method:
  1. Login with Google - Most common, uses existing Google account
  2. API Key - For programmatic access via
    GEMINI_API_KEY
    environment variable
  3. Vertex AI - Enterprise, requires Google Cloud project
首次运行时,选择身份验证方式:
  1. 使用Google账号登录 - 最常用方式,使用现有Google账号
  2. API密钥 - 通过
    GEMINI_API_KEY
    环境变量实现程序化访问
  3. Vertex AI - 企业级方案,需要Google Cloud项目

Key Commands

核心命令

CommandDescription
/help
Show available commands
/settings
Open settings editor
/model
Select Gemini model (Auto, Pro, Flash)
/chat save <tag>
Save conversation state
/chat resume <tag>
Resume saved conversation
/restore
Revert file changes to checkpoint
/memory show
Display loaded GEMINI.md content
/skills list
List available agent skills
/mcp list
List MCP servers and tools
/tools
Display available tools
!<cmd>
Execute shell command
@<path>
Include file/directory in prompt
命令描述
/help
显示可用命令
/settings
打开设置编辑器
/model
选择Gemini模型(Auto、Pro、Flash)
/chat save <tag>
保存对话状态
/chat resume <tag>
恢复已保存的对话
/restore
将文件更改恢复到检查点状态
/memory show
显示已加载的GEMINI.md内容
/skills list
列出可用的Agent技能
/mcp list
列出MCP服务器和工具
/tools
显示可用工具
!<cmd>
执行Shell命令
@<path>
在提示中包含文件/目录

Configuration

配置

Configuration files location:
~/.gemini/
(global) or
.gemini/
(project)
Key files:
  • settings.json
    - CLI settings
  • GEMINI.md
    - Project context/instructions (hierarchical memory)
  • skills/
    - Agent skills directory
配置文件位置:
~/.gemini/
(全局)或
.gemini/
(项目级)
关键文件:
  • settings.json
    - CLI设置文件
  • GEMINI.md
    - 项目上下文/说明文件(分层记忆)
  • skills/
    - Agent技能目录

Documentation

文档

Full documentation in
docs/
. Consult
docs/000-index.md
for detailed navigation.
完整文档位于
docs/
目录。请查阅
docs/000-index.md
获取详细导航指引。

By Topic

按主题分类

TopicFilesDescription
Installation & Setup003-009Get Gemini CLI installed and configured
Basic Usage010-016Core commands, settings, and interface
Advanced Features017-032Security, automation, and customization
Architecture033-037Internal design and APIs
Tools038-045Built-in capabilities for files, shell, web, memory
Extensions046-048Creating and managing extensions
Hooks049-052Event-driven automation
IDE Integration053-054Editor integration and plugins
Development055-058Contributing and testing
Releases059-063Version history and updates
Reference064-067FAQ, troubleshooting, pricing, legal
主题文件描述
安装与设置003-009完成Gemini CLI的安装和配置
基础使用010-016核心命令、设置和界面操作
高级功能017-032安全、自动化和自定义配置
架构033-037内部设计与API
工具038-045内置的文件、Shell、网页、记忆相关功能
扩展046-048扩展的创建与管理
钩子049-052事件驱动的自动化
IDE集成053-054编辑器集成与插件
开发055-058贡献与测试
版本发布059-063版本历史与更新
参考064-067FAQ、故障排查、定价、法律相关

By Keyword

按关键词分类

KeywordFile
installation
docs/004-docs-get-started-installation.md
authentication
docs/005-docs-get-started-authentication.md
configuration
docs/006-docs-get-started-configuration.md
commands
docs/011-docs-cli-commands.md
settings
docs/012-docs-cli-settings.md
model-selection
docs/013-docs-cli-model.md
themes
docs/014-docs-cli-themes.md
keyboard-shortcuts
docs/015-docs-cli-keyboard-shortcuts.md
session-management
docs/016-docs-cli-session-management.md
checkpointing
docs/017-docs-cli-checkpointing.md
sandboxing
docs/018-docs-cli-sandbox.md
headless-mode
docs/019-docs-cli-headless.md
custom-commands
docs/020-docs-cli-custom-commands.md
agent-skills
docs/021-docs-cli-skills.md
enterprise
docs/022-docs-cli-enterprise.md
trusted-folders
docs/023-docs-cli-trusted-folders.md
system-prompt
docs/024-docs-cli-system-prompt.md
token-caching
docs/025-docs-cli-token-caching.md
telemetry
docs/026-docs-cli-telemetry.md
mcp-server
docs/027-docs-cli-tutorials.md
gemini-md
docs/029-docs-cli-gemini-md.md
architecture
docs/033-docs-architecture.md
policy-engine
docs/035-docs-core-policy-engine.md
tools-api
docs/036-docs-core-tools-api.md
file-system-tools
docs/039-docs-tools-file-system.md
shell-command
docs/040-docs-tools-shell.md
web-search
docs/041-docs-tools-web-search.md
web-fetch
docs/042-docs-tools-web-fetch.md
memory-tool
docs/043-docs-tools-memory.md
todo-tool
docs/044-docs-tools-todos.md
mcp-servers
docs/045-docs-tools-mcp-server.md
extensions
docs/046-docs-extensions.md
hooks
docs/049-docs-hooks.md
ide-integration
docs/053-docs-ide-integration.md
faq
docs/064-docs-faq.md
troubleshooting
docs/065-docs-troubleshooting.md
pricing
docs/066-docs-quota-and-pricing.md
关键词文件
installation
docs/004-docs-get-started-installation.md
authentication
docs/005-docs-get-started-authentication.md
configuration
docs/006-docs-get-started-configuration.md
commands
docs/011-docs-cli-commands.md
settings
docs/012-docs-cli-settings.md
model-selection
docs/013-docs-cli-model.md
themes
docs/014-docs-cli-themes.md
keyboard-shortcuts
docs/015-docs-cli-keyboard-shortcuts.md
session-management
docs/016-docs-cli-session-management.md
checkpointing
docs/017-docs-cli-checkpointing.md
sandboxing
docs/018-docs-cli-sandbox.md
headless-mode
docs/019-docs-cli-headless.md
custom-commands
docs/020-docs-cli-custom-commands.md
agent-skills
docs/021-docs-cli-skills.md
enterprise
docs/022-docs-cli-enterprise.md
trusted-folders
docs/023-docs-cli-trusted-folders.md
system-prompt
docs/024-docs-cli-system-prompt.md
token-caching
docs/025-docs-cli-token-caching.md
telemetry
docs/026-docs-cli-telemetry.md
mcp-server
docs/027-docs-cli-tutorials.md
gemini-md
docs/029-docs-cli-gemini-md.md
architecture
docs/033-docs-architecture.md
policy-engine
docs/035-docs-core-policy-engine.md
tools-api
docs/036-docs-core-tools-api.md
file-system-tools
docs/039-docs-tools-file-system.md
shell-command
docs/040-docs-tools-shell.md
web-search
docs/041-docs-tools-web-search.md
web-fetch
docs/042-docs-tools-web-fetch.md
memory-tool
docs/043-docs-tools-memory.md
todo-tool
docs/044-docs-tools-todos.md
mcp-servers
docs/045-docs-tools-mcp-server.md
extensions
docs/046-docs-extensions.md
hooks
docs/049-docs-hooks.md
ide-integration
docs/053-docs-ide-integration.md
faq
docs/064-docs-faq.md
troubleshooting
docs/065-docs-troubleshooting.md
pricing
docs/066-docs-quota-and-pricing.md

Learning Path

学习路径

  1. Foundation: Install (004), authenticate (005), configure (006)
  2. Core Usage: Commands (011), settings (012), model selection (013)
  3. Productivity: Checkpointing (017), custom commands (020), skills (021)
  4. Advanced: Extensions (046-048), hooks (049-052), MCP servers (045)
  1. 基础阶段:安装(004)、身份验证(005)、配置(006)
  2. 核心使用:命令(011)、设置(012)、模型选择(013)
  3. 效率提升:检查点(017)、自定义命令(020)、技能(021)
  4. 高级进阶:扩展(046-048)、钩子(049-052)、MCP服务器(045)

Common Tasks

常见任务

Configure GEMINI.md for project context

为项目上下文配置GEMINI.md

->
docs/006-docs-get-started-configuration.md
(hierarchical memory setup)
->
docs/006-docs-get-started-configuration.md
(分层记忆设置)

Create custom slash commands

创建自定义斜杠命令

->
docs/020-docs-cli-custom-commands.md
(TOML-based command definitions)
->
docs/020-docs-cli-custom-commands.md
(基于TOML的命令定义)

Set up agent skills

设置Agent技能

->
docs/021-docs-cli-skills.md
(create SKILL.md with frontmatter)
->
docs/021-docs-cli-skills.md
(创建带前置元数据的SKILL.md)

Run in headless/CI mode

以无头/CI模式运行

->
docs/019-docs-cli-headless.md
(automation and JSON output)
->
docs/019-docs-cli-headless.md
(自动化与JSON输出)

Configure MCP servers

配置MCP服务器

->
docs/045-docs-tools-mcp-server.md
(Model Context Protocol integration)
->
docs/045-docs-tools-mcp-server.md
(模型上下文协议集成)

Build CLI extensions

构建CLI扩展

->
docs/047-docs-extensions-getting-started-extensions.md
(extension development)
->
docs/047-docs-extensions-getting-started-extensions.md
(扩展开发)

Write automation hooks

编写自动化钩子

->
docs/050-docs-hooks-writing-hooks.md
(event-driven scripts)
->
docs/050-docs-hooks-writing-hooks.md
(事件驱动脚本)

Sandbox execution for security

沙箱执行保障安全

->
docs/018-docs-cli-sandbox.md
(Docker/Podman isolation)
->
docs/018-docs-cli-sandbox.md
(Docker/Podman隔离)

Troubleshoot common issues

排查常见问题

->
docs/065-docs-troubleshooting.md
(debugging and error resolution)
->
docs/065-docs-troubleshooting.md
(调试与错误解决)

Understand pricing and quotas

了解定价与配额

->
docs/066-docs-quota-and-pricing.md
(free tier, paid options)
->
docs/066-docs-quota-and-pricing.md
(免费层级、付费选项)