gemini
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGemini Skill Guide
Gemini技能指南
When to Use This Skill
何时使用该技能
Primary Use Cases:
- User explicitly requests CLI execution (Mode 1: Direct CLI)
gemini - Large-context analysis requiring 1M token window (Mode 2: Gemini Delegation)
- Repository-scale code reviews and architectural analysis
- Multimodal analysis (code + images/diagrams)
- 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
主要使用场景:
- 用户明确要求执行CLI(模式1:直接CLI调用)
gemini - 需要100万token窗口的大上下文分析(模式2:Gemini委托)
- 仓库级代码评审与架构分析
- 多模态分析(代码 + 图片/图表)
- 跨模块依赖跟踪
请勿用于:
- 简单代码解释(直接使用Claude)
- 小上下文任务(<10万tokens)
- 不需要Gemini专属功能的任务
Execution Modes
执行模式
Mode 1: Direct CLI Execution
模式1:直接CLI执行
When: User explicitly asks to run gemini CLI
Workflow:
-
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)
-
Execute:bash
gemini "<PROMPT>" -m <MODEL> --approval-mode <MODE> --output-format <FORMAT> -
Inform user: "You can resume with 'gemini --resume latest' anytime"
Resuming:
bash
gemini "<CONTINUATION PROMPT>" --resume latest适用场景: 用户明确要求运行gemini CLI
工作流程:
-
通过结构化问题收集配置信息:
- 模型选择(gemini-3-pro-preview vs gemini-3-flash-preview)
- 审批模式(default、auto_edit、yolo)
- 输出格式(text、json、stream-json)
-
执行命令:bash
gemini "<PROMPT>" -m <MODEL> --approval-mode <MODE> --output-format <FORMAT> -
告知用户:"您可随时通过'gemini --resume latest'恢复会话"
恢复会话:
bash
gemini "<CONTINUATION PROMPT>" --resume latestMode 2: Gemini Delegation for Large Context
模式2:大上下文场景下的Gemini委托
When: Task requires large context window (>100K tokens), multimodal input,
or repository-scale analysis
Workflow:
- Analyze context and identify what Gemini analysis would help
- Formulate comprehensive query with all relevant context:
- Problem statement
- Current findings
- Code snippets or file references
- Specific questions
- Leverage Gemini's 1M token context for comprehensive analysis
- Execute:
gemini "<DETAILED CONTEXT>" --output-format json - Synthesize Gemini response into actionable insights
- Report findings with:
- Clear summary of Gemini's analysis
- Specific recommendations or solutions
- Additional considerations or caveats
- Next steps if applicable
适用场景: 任务需要大上下文窗口(>10万tokens)、多模态输入,或仓库级分析
工作流程:
- 分析上下文,确定Gemini分析能提供的帮助
- 结合所有相关上下文制定全面查询:
- 问题说明
- 当前发现
- 代码片段或文件引用
- 具体问题
- 利用Gemini的100万token上下文进行全面分析
- 执行命令:
gemini "<DETAILED CONTEXT>" --output-format json - 将Gemini的响应提炼为可执行的洞察
- 汇报发现内容,包含:
- 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:
- (auto-approve all actions)
--yolo --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 to add additional workspace paths
--include-directories - 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 settingsgemini命令完成后:
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.mdRunning a Task
任务执行步骤
- Gather configuration using the patterns above
- Assemble the command with the appropriate options:
- (gemini-3-pro-preview or gemini-3-flash-preview)
-m, --model <MODEL> - (default, auto_edit, yolo)
--approval-mode <MODE> - (text, json, stream-json)
-o, --output-format <FORMAT> - (additional workspace paths)
--include-directories <DIRS> - (latest or session index)
-r, --resume <SESSION>
- Run the command, capture output, and summarize for the user
- After Gemini completes, inform the user: "You can resume this Gemini session at any time by saying 'gemini resume' or asking me to continue."
- 使用上述模式收集配置信息
- 组装带有适当选项的命令:
- (gemini-3-pro-preview或gemini-3-flash-preview)
-m, --model <MODEL> - (default、auto_edit、yolo)
--approval-mode <MODE> - (text、json、stream-json)
-o, --output-format <FORMAT> - (额外工作区路径)
--include-directories <DIRS> - (latest或会话索引)
-r, --resume <SESSION>
- 运行命令,捕获输出并为用户生成摘要
- Gemini完成后,告知用户:"您可随时通过说'gemini resume'或要求我继续来恢复此Gemini会话。"
Quick Reference
快速参考
| Use case | Approval mode | Key flags |
|---|---|---|
| Safe analysis | | |
| Auto-approve edits | | |
| Fully autonomous | | |
| Resume recent session | Inherited | |
| Add workspace directories | Match task | |
| Interactive continuation | default | |
| 使用场景 | 审批模式 | 关键标志 |
|---|---|---|
| 安全分析 | | |
| 自动批准编辑 | | |
| 完全自主 | | |
| 恢复最近会话 | 继承原有配置 | |
| 添加工作区目录 | 匹配任务需求 | |
| 交互式续接 | default | |
Model Selection
模型选择
| Model | Use Case | Context | Speed |
|---|---|---|---|
| Complex reasoning, architecture review | 1M tokens | Slower |
| Quick analysis, simple tasks | 1M tokens | Faster |
| 模型 | 使用场景 | 上下文容量 | 速度 |
|---|---|---|---|
| 复杂推理、架构评审 | 100万tokens | 较慢 |
| 快速分析、简单任务 | 100万tokens | 较快 |
Session Management
会话管理
bash
undefinedbash
undefinedList 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
undefinedgemini --delete-session 3
undefinedMCP Server Integration
MCP服务器集成
bash
undefinedbash
undefinedList 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
undefinedgemini "<PROMPT>" --allowed-mcp-server-names mcp-skillset
undefinedExtension System
扩展系统
bash
undefinedbash
undefinedList 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>
undefinedgemini extensions disable <name>
gemini extensions enable <name>
undefinedFollowing Up
后续跟进
- After every command, offer follow-up options
gemini - 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 or a
gemini --versioncommand exits non-zero; request direction before retryinggemini - 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技能的对比
| Feature | Gemini | Codex |
|---|---|---|
| Context window | 1M tokens | ~200K tokens |
| Primary models | gemini-3-pro/flash | gpt-5.2-codex |
| Approval modes | default/auto_edit/yolo | never/on-request/on-failure |
| Sandbox | Boolean (--sandbox) | read-only/workspace-write/danger-full-access |
| Resume | --resume latest/index | codex exec resume --last |
| Stderr handling | N/A | 2>/dev/null for thinking tokens |
| Output format | text/json/stream-json | json flag |
| 特性 | Gemini | Codex |
|---|---|---|
| 上下文窗口 | 100万tokens | ~20万tokens |
| 主要模型 | gemini-3-pro/flash | gpt-5.2-codex |
| 审批模式 | default/auto_edit/yolo | never/on-request/on-failure |
| 沙箱 | 布尔值(--sandbox) | read-only/workspace-write/danger-full-access |
| 恢复会话 | --resume latest/index | codex exec resume --last |
| 标准错误处理 | N/A | 2>/dev/null用于处理思考令牌 |
| 输出格式 | text/json/stream-json | json标志 |
Integration Patterns
集成模式
With Other CLI Agents
与其他CLI Agent集成
bash
undefinedbash
undefinedUse 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"
undefinedresearch docs -t "framework API" --format json | gemini "Apply this to codebase"
undefinedMultimodal Analysis
多模态分析
bash
undefinedbash
undefinedGemini can process images inline with code
Gemini可同时处理图片和代码
gemini "Analyze this architecture diagram and compare with implementation"
--include-directories ./docs ./src
--include-directories ./docs ./src
undefinedgemini "Analyze this architecture diagram and compare with implementation"
--include-directories ./docs ./src
--include-directories ./docs ./src
undefinedHeal-Skill Integration
Heal-Skill集成
When gemini CLI API changes are detected (command failures, unexpected output formats, or deprecated flags):
- Detection: Notice command failures or API mismatches during execution
- Trigger: Flag skill for healing via
/heal-skill gemini - Analysis: Healing agent analyzes current CLI with and
gemini --helpgemini --version - Update: Updates skill documentation to match current API
- Validation: Re-validates agent configuration for compatibility
- Model Verification: Ensures only gemini-3 models are referenced
- 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变更时(命令失败、意外输出格式或已弃用标志):
- 检测: 执行过程中发现命令失败或API不匹配
- 触发: 通过标记技能需要修复
/heal-skill gemini - 分析: 修复Agent通过和
gemini --help分析当前CLIgemini --version - 更新: 更新技能文档以匹配当前API
- 验证: 重新验证Agent配置的兼容性
- 模型验证: 确保仅引用gemini-3系列模型
- 上下文窗口验证: 确认100万token上下文窗口的规格
需监控的常见变更:
- 新增或已弃用的命令标志
- 审批模式或输出格式的变更
- 模型可用性更新(gemini-3系列)
- MCP服务器集成API变更
- 会话管理API修改
- 扩展系统更新
- 上下文窗口规格变更