gemini

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Gemini Skill Guide

Gemini技能指南

When to Use This Skill

何时使用该技能

Primary Use Cases:
  1. User explicitly requests
    gemini
    CLI execution (Mode 1: Direct CLI)
  2. Large-context analysis requiring 1M token window (Mode 2: Gemini Delegation)
  3. Repository-scale code reviews and architectural analysis
  4. Multimodal analysis (code + images/diagrams)
  5. Cross-module dependency tracking
Do NOT use for:
  • Simple code explanations (use Claude directly)
  • Small context tasks (<100K tokens)
  • Tasks not requiring Gemini-specific capabilities
主要使用场景:
  1. 用户明确要求执行
    gemini
    CLI(模式1:直接CLI调用)
  2. 需要100万token窗口的大上下文分析(模式2:Gemini委托)
  3. 仓库级代码评审与架构分析
  4. 多模态分析(代码 + 图片/图表)
  5. 跨模块依赖跟踪
请勿用于:
  • 简单代码解释(直接使用Claude)
  • 小上下文任务(<10万tokens)
  • 不需要Gemini专属功能的任务

Execution Modes

执行模式

Mode 1: Direct CLI Execution

模式1:直接CLI执行

When: User explicitly asks to run gemini CLI
Workflow:
  1. Gather configuration using structured questions:
    • Model selection (gemini-3-pro-preview vs gemini-3-flash-preview)
    • Approval mode (default, auto_edit, yolo)
    • Output format (text, json, stream-json)
  2. Execute:
    bash
    gemini "<PROMPT>" -m <MODEL> --approval-mode <MODE> --output-format <FORMAT>
  3. Inform user: "You can resume with 'gemini --resume latest' anytime"
Resuming:
bash
gemini "<CONTINUATION PROMPT>" --resume latest
适用场景: 用户明确要求运行gemini CLI
工作流程:
  1. 通过结构化问题收集配置信息:
    • 模型选择(gemini-3-pro-preview vs gemini-3-flash-preview)
    • 审批模式(default、auto_edit、yolo)
    • 输出格式(text、json、stream-json)
  2. 执行命令:
    bash
    gemini "<PROMPT>" -m <MODEL> --approval-mode <MODE> --output-format <FORMAT>
  3. 告知用户:"您可随时通过'gemini --resume latest'恢复会话"
恢复会话:
bash
gemini "<CONTINUATION PROMPT>" --resume latest

Mode 2: Gemini Delegation for Large Context

模式2:大上下文场景下的Gemini委托

When: Task requires large context window (>100K tokens), multimodal input, or repository-scale analysis
Workflow:
  1. Analyze context and identify what Gemini analysis would help
  2. Formulate comprehensive query with all relevant context:
    • Problem statement
    • Current findings
    • Code snippets or file references
    • Specific questions
  3. Leverage Gemini's 1M token context for comprehensive analysis
  4. Execute:
    gemini "<DETAILED CONTEXT>" --output-format json
  5. Synthesize Gemini response into actionable insights
  6. Report findings with:
    • Clear summary of Gemini's analysis
    • Specific recommendations or solutions
    • Additional considerations or caveats
    • Next steps if applicable
适用场景: 任务需要大上下文窗口(>10万tokens)、多模态输入,或仓库级分析
工作流程:
  1. 分析上下文,确定Gemini分析能提供的帮助
  2. 结合所有相关上下文制定全面查询:
    • 问题说明
    • 当前发现
    • 代码片段或文件引用
    • 具体问题
  3. 利用Gemini的100万token上下文进行全面分析
  4. 执行命令:
    gemini "<DETAILED CONTEXT>" --output-format json
  5. 将Gemini的响应提炼为可执行的洞察
  6. 汇报发现内容,包含:
    • Gemini分析的清晰摘要
    • 具体建议或解决方案
    • 其他注意事项或警告
    • 适用的后续步骤

Error Handling

错误处理

  • Verify gemini binary exists before execution:
    which gemini
  • Stop immediately on non-zero exit codes and report to user
  • Request direction before retrying failed commands
  • Before using high-autonomy flags, confirm with user:
    • --yolo
      (auto-approve all actions)
    • --approval-mode yolo
  • 执行前验证gemini二进制文件是否存在:
    which gemini
  • 遇到非零退出码时立即停止并向用户报告
  • 重试失败命令前需请求用户指示
  • 使用高自主性标志前需与用户确认:
    • --yolo
      (自动批准所有操作)
    • --approval-mode yolo

Context Management

上下文管理

  • Gemini excels at large context (up to 1M tokens)
  • For massive contexts (>500K tokens), consider module-by-module summaries
  • Use
    --include-directories
    to add additional workspace paths
  • Leverage session resume for iterative refinement
  • Gemini擅长处理大上下文(最多100万tokens)
  • 对于超大规模上下文(>50万tokens),考虑按模块生成摘要
  • 使用
    --include-directories
    添加额外工作区路径
  • 利用会话恢复功能进行迭代优化

Configuration Gathering Patterns

配置收集模式

Initial Configuration (Mode 1, Step 1)

初始配置(模式1,步骤1)

At the start of Mode 1 execution, gather model, approval mode, and output format:
Standard configuration question:
text
Select gemini configuration (model, approval mode, and output format):

1. "gemini-3-pro-preview / default / json (Recommended)" - High quality, safe mode
2. "gemini-3-pro-preview / auto_edit / json" - High quality, auto-approve edits
3. "gemini-3-flash-preview / default / json" - Fast, safe mode
4. "gemini-3-flash-preview / auto_edit / json" - Fast, auto-approve edits
5. "gemini-3-pro-preview / yolo / json" - High quality, fully autonomous
6. "gemini-3-flash-preview / yolo / json" - Fast, fully autonomous
7. "Custom" - User will specify model, approval, and format separately
在模式1执行开始时,收集模型、审批模式和输出格式信息:
标准配置问题:
text
选择gemini配置(模型、审批模式和输出格式):

1. "gemini-3-pro-preview / default / json(推荐)" - 高质量、安全模式
2. "gemini-3-pro-preview / auto_edit / json" - 高质量、自动批准编辑
3. "gemini-3-flash-preview / default / json" - 快速、安全模式
4. "gemini-3-flash-preview / auto_edit / json" - 快速、自动批准编辑
5. "gemini-3-pro-preview / yolo / json" - 高质量、完全自主
6. "gemini-3-flash-preview / yolo / json" - 快速、完全自主
7. "自定义" - 用户将单独指定模型、审批模式和格式

High-Impact Flags Confirmation

高影响标志确认

Before executing with --yolo or autonomous flags:
text
Ready to execute with these flags: [LIST FLAGS]. Proceed?

1. "Execute now" - Run as configured
2. "Modify configuration" - Change settings
3. "Cancel" - Abort
在使用--yolo或自主标志执行前:
text
即将使用以下标志执行:[标志列表]。是否继续?

1. "立即执行" - 按配置运行
2. "修改配置" - 更改设置
3. "取消" - 终止操作

Post-Execution Follow-up

执行后跟进

After gemini command completes:
text
Gemini completed. [SUMMARY]. Next steps?

1. "Resume with additional prompt" - Continue session
2. "Analyze results" - Review output
3. "Complete" - Finished
4. "Retry with different config" - Adjust settings
gemini命令完成后:
text
Gemini执行完成。[摘要]。下一步操作?

1. "使用新提示恢复" - 继续会话
2. "分析结果" - 查看输出
3. "完成" - 结束任务
4. "使用不同配置重试" - 调整设置

Error Recovery

错误恢复

When command fails or has warnings:
text
Error: [SPECIFIC ERROR]. How to proceed?

1. "Resume with adjustments" - Fix and continue
2. "Retry with different config" - Change model/approval/format
3. "Accept partial results" - Use what worked
4. "Invoke heal-skill" - Fix outdated SKILL.md
当命令失败或出现警告时:
text
错误: [具体错误信息]。如何处理?

1. "调整后恢复" - 修复问题后继续
2. "使用不同配置重试" - 更改模型/审批模式/格式
3. "接受部分结果" - 使用可用的有效结果
4. "调用heal-skill" - 更新过时的SKILL.md

Running a Task

任务执行步骤

  1. Gather configuration using the patterns above
  2. Assemble the command with the appropriate options:
    • -m, --model <MODEL>
      (gemini-3-pro-preview or gemini-3-flash-preview)
    • --approval-mode <MODE>
      (default, auto_edit, yolo)
    • -o, --output-format <FORMAT>
      (text, json, stream-json)
    • --include-directories <DIRS>
      (additional workspace paths)
    • -r, --resume <SESSION>
      (latest or session index)
  3. Run the command, capture output, and summarize for the user
  4. After Gemini completes, inform the user: "You can resume this Gemini session at any time by saying 'gemini resume' or asking me to continue."
  1. 使用上述模式收集配置信息
  2. 组装带有适当选项的命令:
    • -m, --model <MODEL>
      (gemini-3-pro-preview或gemini-3-flash-preview)
    • --approval-mode <MODE>
      (default、auto_edit、yolo)
    • -o, --output-format <FORMAT>
      (text、json、stream-json)
    • --include-directories <DIRS>
      (额外工作区路径)
    • -r, --resume <SESSION>
      (latest或会话索引)
  3. 运行命令,捕获输出并为用户生成摘要
  4. Gemini完成后,告知用户:"您可随时通过说'gemini resume'或要求我继续来恢复此Gemini会话。"

Quick Reference

快速参考

Use caseApproval modeKey flags
Safe analysis
default
--approval-mode default --output-format json
Auto-approve edits
auto_edit
--approval-mode auto_edit --output-format json
Fully autonomous
yolo
--yolo --output-format json
Resume recent sessionInherited
--resume latest
Add workspace directoriesMatch task
--include-directories <DIRS>
Interactive continuationdefault
-i "<PROMPT>"
(stays interactive after)
使用场景审批模式关键标志
安全分析
default
--approval-mode default --output-format json
自动批准编辑
auto_edit
--approval-mode auto_edit --output-format json
完全自主
yolo
--yolo --output-format json
恢复最近会话继承原有配置
--resume latest
添加工作区目录匹配任务需求
--include-directories <DIRS>
交互式续接default
-i "<PROMPT>"
(续接后保持交互状态)

Model Selection

模型选择

ModelUse CaseContextSpeed
gemini-3-pro-preview
Complex reasoning, architecture review1M tokensSlower
gemini-3-flash-preview
Quick analysis, simple tasks1M tokensFaster
模型使用场景上下文容量速度
gemini-3-pro-preview
复杂推理、架构评审100万tokens较慢
gemini-3-flash-preview
快速分析、简单任务100万tokens较快

Session Management

会话管理

bash
undefined
bash
undefined

List available sessions

列出可用会话

gemini --list-sessions
gemini --list-sessions

Resume most recent session

恢复最近的会话

gemini --resume latest
gemini --resume latest

Resume specific session by index

通过索引恢复特定会话

gemini --resume 5
gemini --resume 5

Delete a session

删除会话

gemini --delete-session 3
undefined
gemini --delete-session 3
undefined

MCP Server Integration

MCP服务器集成

bash
undefined
bash
undefined

List configured MCP servers

列出已配置的MCP服务器

gemini mcp list
gemini mcp list

Add an MCP server

添加MCP服务器

gemini mcp add <name> <command> [args...]
gemini mcp add <name> <command> [args...]

Remove an MCP server

删除MCP服务器

gemini mcp remove <name>
gemini mcp remove <name>

Limit to specific MCP servers

限制使用特定MCP服务器

gemini "<PROMPT>" --allowed-mcp-server-names mcp-skillset
undefined
gemini "<PROMPT>" --allowed-mcp-server-names mcp-skillset
undefined

Extension System

扩展系统

bash
undefined
bash
undefined

List installed extensions

列出已安装的扩展

gemini extensions list
gemini extensions list

Install extension from git or path

从git或路径安装扩展

gemini extensions install <source> [--auto-update] [--pre-release]
gemini extensions install <source> [--auto-update] [--pre-release]

Update extensions

更新扩展

gemini extensions update [--all]
gemini extensions update [--all]

Disable/enable extension

禁用/启用扩展

gemini extensions disable <name> gemini extensions enable <name>
undefined
gemini extensions disable <name> gemini extensions enable <name>
undefined

Following Up

后续跟进

  • After every
    gemini
    command, offer follow-up options
  • When resuming, use:
    gemini "<new prompt>" --resume latest
  • The resumed session automatically uses the same context from the original
  • Restate the chosen model and approval mode when proposing follow-up actions
  • 每次
    gemini
    命令执行后,提供后续操作选项
  • 恢复会话时使用:
    gemini "<new prompt>" --resume latest
  • 恢复后的会话会自动沿用原会话的上下文
  • 提议后续操作时,重申所选的模型和审批模式

Error Handling Guidelines

错误处理指南

  • Stop and report failures whenever
    gemini --version
    or a
    gemini
    command exits non-zero; request direction before retrying
  • Confirm high-impact flags before execution
  • When output includes warnings or partial results, offer error recovery options
  • gemini --version
    或任意
    gemini
    命令返回非零退出码时,立即停止并报告失败,重试前需请求用户指示
  • 执行高影响标志前需确认
  • 当输出包含警告或部分结果时,提供错误恢复选项

Comparison with Codex Skill

与Codex技能的对比

FeatureGeminiCodex
Context window1M tokens~200K tokens
Primary modelsgemini-3-pro/flashgpt-5.2-codex
Approval modesdefault/auto_edit/yolonever/on-request/on-failure
SandboxBoolean (--sandbox)read-only/workspace-write/danger-full-access
Resume--resume latest/indexcodex exec resume --last
Stderr handlingN/A2>/dev/null for thinking tokens
Output formattext/json/stream-jsonjson flag
特性GeminiCodex
上下文窗口100万tokens~20万tokens
主要模型gemini-3-pro/flashgpt-5.2-codex
审批模式default/auto_edit/yolonever/on-request/on-failure
沙箱布尔值(--sandbox)read-only/workspace-write/danger-full-access
恢复会话--resume latest/indexcodex exec resume --last
标准错误处理N/A2>/dev/null用于处理思考令牌
输出格式text/json/stream-jsonjson标志

Integration Patterns

集成模式

With Other CLI Agents

与其他CLI Agent集成

bash
undefined
bash
undefined

Use gemini for large context, codex for GPT-specific

使用gemini处理大上下文,codex处理GPT专属任务

gemini "Analyze entire codebase architecture" --output-format json codex exec "Implement specific feature based on analysis" --full-auto
gemini "Analyze entire codebase architecture" --output-format json codex exec "Implement specific feature based on analysis" --full-auto

Chain with research CLI

与research CLI联动

research docs -t "framework API" --format json | gemini "Apply this to codebase"
undefined
research docs -t "framework API" --format json | gemini "Apply this to codebase"
undefined

Multimodal Analysis

多模态分析

bash
undefined
bash
undefined

Gemini can process images inline with code

Gemini可同时处理图片和代码

gemini "Analyze this architecture diagram and compare with implementation"
--include-directories ./docs ./src
undefined
gemini "Analyze this architecture diagram and compare with implementation"
--include-directories ./docs ./src
undefined

Heal-Skill Integration

Heal-Skill集成

When gemini CLI API changes are detected (command failures, unexpected output formats, or deprecated flags):
  1. Detection: Notice command failures or API mismatches during execution
  2. Trigger: Flag skill for healing via
    /heal-skill gemini
  3. Analysis: Healing agent analyzes current CLI with
    gemini --help
    and
    gemini --version
  4. Update: Updates skill documentation to match current API
  5. Validation: Re-validates agent configuration for compatibility
  6. Model Verification: Ensures only gemini-3 models are referenced
  7. Context Window Verification: Confirms 1M token context window specifications
Common Changes to Monitor:
  • New or deprecated command flags
  • Changes to approval modes or output formats
  • Model availability updates (gemini-3 family)
  • MCP server integration API changes
  • Session management API modifications
  • Extension system updates
  • Context window specification changes
当检测到gemini CLI API变更时(命令失败、意外输出格式或已弃用标志):
  1. 检测: 执行过程中发现命令失败或API不匹配
  2. 触发: 通过
    /heal-skill gemini
    标记技能需要修复
  3. 分析: 修复Agent通过
    gemini --help
    gemini --version
    分析当前CLI
  4. 更新: 更新技能文档以匹配当前API
  5. 验证: 重新验证Agent配置的兼容性
  6. 模型验证: 确保仅引用gemini-3系列模型
  7. 上下文窗口验证: 确认100万token上下文窗口的规格
需监控的常见变更:
  • 新增或已弃用的命令标志
  • 审批模式或输出格式的变更
  • 模型可用性更新(gemini-3系列)
  • MCP服务器集成API变更
  • 会话管理API修改
  • 扩展系统更新
  • 上下文窗口规格变更