gemini-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Gemini CLI Skill

Gemini CLI 技能

Use Google’s
gemini
CLI as an external “second brain” when you need a very large context window, a second opinion, or safe sandbox execution. This skill does not use MCP; it runs the local CLI directly.
当你需要超大上下文窗口、第二种意见或安全的沙箱执行时,可将Google的
gemini
CLI作为外部“第二大脑”使用。本技能使用MCP;它直接运行本地CLI。

When To Use

使用场景

Use this skill when the user asks to:
  • “Ask Gemini” / “Use Gemini”
  • Analyze or summarize large files or directories (especially with
    @path
    references)
  • Brainstorm options with a specific framework (SCAMPER, design thinking, etc.)
  • Generate structured edit suggestions (“change mode”) that can be applied deterministically
当用户提出以下需求时使用本技能:
  • “Ask Gemini” / “Use Gemini”
  • 分析或总结大型文件或目录(尤其是带有
    @path
    引用的内容)
  • 结合特定框架进行头脑风暴(如SCAMPER、设计思维等)
  • 生成可确定性应用的结构化编辑建议(“变更模式”)

Prerequisites

前置条件

  • gemini
    CLI is installed and configured (e.g.
    gemini --version
    works)
  • You are allowed to run local shell commands in this environment
  • For sandbox execution, Gemini CLI supports
    -s/--sandbox
    (see
    gemini --help
    )
  • 已安装并配置
    gemini
    CLI(例如
    gemini --version
    可正常运行)
  • 你被允许在此环境中运行本地shell命令
  • 若要进行沙箱执行,Gemini CLI需支持
    -s/--sandbox
    参数(详见
    gemini --help

Core Commands

核心命令

One-shot query (plain)

一次性查询(普通模式)

bash
gemini "Explain what this code does: @src/main.ts"
bash
gemini "Explain what this code does: @src/main.ts"

Choose a model

选择模型

bash
gemini -m gemini-2.5-pro "..."
gemini -m gemini-2.5-flash "..."
bash
gemini -m gemini-2.5-pro "..."
gemini -m gemini-2.5-flash "..."

Sandbox mode

沙箱模式

bash
gemini -s "Safely test @scripts/example.py and explain the results."
bash
gemini -s "Safely test @scripts/example.py and explain the results."

Helper Script (Recommended)

辅助脚本(推荐使用)

This skill ships with a dependency-free wrapper that mirrors the core behavior of
gemini-mcp-tool
without MCP:
skills/gemini-cli/scripts/gemini-tool.mjs
Important: Gemini CLI can only read files under its current “project directory” (typically the process working directory). Run the wrapper from the repo you want Gemini to read, or pass
--cwd
.
bash
node skills/gemini-cli/scripts/gemini-tool.mjs help
本技能附带一个无依赖的包装器,可在不使用MCP的情况下复刻
gemini-mcp-tool
的核心功能:
skills/gemini-cli/scripts/gemini-tool.mjs
重要提示:Gemini CLI仅能读取其当前“项目目录”下的文件(通常为进程工作目录)。请在你希望Gemini读取的仓库中运行该包装器,或传递
--cwd
参数。
bash
node skills/gemini-cli/scripts/gemini-tool.mjs help

Ask Gemini (wrapper)

调用Gemini(包装器)

bash
node skills/gemini-cli/scripts/gemini-tool.mjs ask --prompt "Summarize @. in 5 bullets."
node skills/gemini-cli/scripts/gemini-tool.mjs ask --cwd /path/to/project --prompt "Summarize @. in 5 bullets."
node skills/gemini-cli/scripts/gemini-tool.mjs ask --prompt "..." --model gemini-2.5-pro
node skills/gemini-cli/scripts/gemini-tool.mjs ask --prompt "..." --sandbox
bash
node skills/gemini-cli/scripts/gemini-tool.mjs ask --prompt "Summarize @. in 5 bullets."
node skills/gemini-cli/scripts/gemini-tool.mjs ask --cwd /path/to/project --prompt "Summarize @. in 5 bullets."
node skills/gemini-cli/scripts/gemini-tool.mjs ask --prompt "..." --model gemini-2.5-pro
node skills/gemini-cli/scripts/gemini-tool.mjs ask --prompt "..." --sandbox

Brainstorm (wrapper)

头脑风暴(包装器)

bash
node skills/gemini-cli/scripts/gemini-tool.mjs brainstorm --prompt "How should we design onboarding?" --methodology scamper --ideaCount 12
bash
node skills/gemini-cli/scripts/gemini-tool.mjs brainstorm --prompt "How should we design onboarding?" --methodology scamper --ideaCount 12

Change Mode (structured edits + chunk caching)

变更模式(结构化编辑 + 分块缓存)

Use change mode when you want Gemini to output deterministic OLD/NEW blocks that can be applied by exact string matching.
bash
node skills/gemini-cli/scripts/gemini-tool.mjs ask --changeMode --prompt "In @src/foo.ts, rename Foo to Bar and update call sites."
If the response is chunked, the output includes a
cacheKey
. Fetch the next chunk:
bash
node skills/gemini-cli/scripts/gemini-tool.mjs fetch-chunk --cacheKey <key> --chunkIndex 2
当你希望Gemini输出可通过精确字符串匹配确定性应用的OLD/NEW代码块时,使用变更模式。
bash
node skills/gemini-cli/scripts/gemini-tool.mjs ask --changeMode --prompt "In @src/foo.ts, rename Foo to Bar and update call sites."
如果响应被分块,输出内容将包含一个
cacheKey
。获取下一个分块:
bash
node skills/gemini-cli/scripts/gemini-tool.mjs fetch-chunk --cacheKey <key> --chunkIndex 2

Safety Rules

安全规则

  • Never execute destructive commands from Gemini output without explicit user approval.
  • In change mode, the
    OLD
    block must match the file content exactly; otherwise, do not apply the edit.
  • Prefer read-only analysis unless the user explicitly requests changes.
  • 未经用户明确批准,绝不要执行Gemini输出中的破坏性命令。
  • 在变更模式下,
    OLD
    块必须与文件内容完全匹配;否则,请勿应用该编辑。
  • 除非用户明确要求修改,否则优先选择只读分析。