Community编程与开发github.com

WJZ-P/gemini-skill

通过 Gemini 官网(gemini.google.com)执行生图、对话等操作。用户提到"生图/画图/绘图/nano banana/nanobanana/生成图片"等关键词时触发。操作方式分三级优先级:首选 MCP 工具 → 次选 Skill 脚本 → 最次连接 Skill 浏览器手动操作(需用户授权)。禁止自行启动外部浏览器访问 Gemini。

gemini-skill 是什么?

gemini-skill is a Gemini CLI agent skill that 通过 Gemini 官网(gemini.google.com)执行生图、对话等操作。用户提到"生图/画图/绘图/nano banana/nanobanana/生成图片"等关键词时触发。操作方式分三级优先级:首选 MCP 工具 → 次选 Skill 脚本 → 最次连接 Skill 浏览器手动操作(需用户授权)。禁止自行启动外部浏览器访问 Gemini。.

兼容平台~Claude Code~Codex CLI~Cursor✓Gemini CLI
npx skills add WJZ-P/gemini-skill

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Gemini Skill

⚠️ Operation Priority (Must Follow)

All interactions with Gemini must follow this priority order:

  1. 🥇 Primary: Call MCP Tools — Directly invoke the MCP tools exposed by this skill to complete the operation, covering the vast majority of scenarios.
  2. 🥈 Secondary: Run Skill Scripts — When MCP tools cannot satisfy the requirement, run scripts provided in this skill's project.
  3. 🥉 Tertiary: Connect to Skill-Managed Browser — Only when the first two methods fail, use gemini_browser_info to obtain CDP connection info and actively connect to the browser managed by this skill. This requires explicit user consent first.

Strictly Prohibited: Launching a new browser instance to access the Gemini page (e.g., using OpenClaw browser, starting a new Puppeteer instance, etc.) as this will cause session conflicts.

If the browser Daemon is not running, the MCP tools will automatically start it — no manual action needed.

📡 Progress Sync & Long-Running Tool Rules

MCP tool calls (especially image generation, waiting for replies, etc.) can be lengthy (60–180 seconds). The following rules must be observed:

  • All MCP tools in this skill are synchronous blocking calls — they wait for the final result before returning. There is no "intermediate state" that requires polling.
  • When calling a long-running tool, timeoutMs must be set to ≥180000 (3 minutes) to prevent premature timeout at the transport layer.
  • Do not end the conversation or report "still running"/"tool timeout" to the user before receiving the tool's final return.
  • Send a progress message to the user every 15–30 seconds (e.g., "Waiting for Gemini to generate image… waited 30 seconds…") to maintain feedback.
  • After obtaining the final result, immediately return the artifact (file path) or report the error without omission.
  • If fullSize mode fails, you can fall back and retry with fullSize=false (preview mode is more stable).

Trigger Keywords

  • Image Generation Tasks: generate image, draw, create image, poster, nano banana, nanobanana, image generation, 生成图片 (if the request is ambiguous, first confirm with the user if they need image generation)

Usage

This skill exposes tools via an MCP Server, which the AI can call directly.

Browser startup, session management, image extraction, file saving, and other workflows are all encapsulated within the tools.

⚠️ Mandatory Rules

AI must always complete all operations through MCP tools.

It is forbidden to bypass MCP by writing ad-hoc scripts (e.g., node -e "..." or creating temporary .js files) to import / require functions exported by this project (such as createGeminiSession, createOps, etc.).

If MCP tools truly cannot meet the current requirement, the AI must first explain the reason to the user and obtain explicit consent before writing a temporary script to call the underlying API. Any such action without user consent is prohibited.

Available Tools

Core Image Generation (Complete Flow Encapsulated):

Tool NameDescriptionParameters
gemini_generate_imageComplete image generation flow: new session → send prompt → wait → extract image → save locally (approx. 60–120 seconds)prompt, newSession (default false), referenceImages (array of reference image paths), fullSize (default true, high-res original; false for preview), timeout (default 120000ms)

Session Management:

Tool NameDescriptionParameters
gemini_new_chatCreate a new blank conversationNone
gemini_temp_chatEnter temporary chat mode (no history retained)None

Model Switching:

Tool NameDescriptionParameters
gemini_switch_modelSwitch Gemini modelmodel (pro / quick / think)

Text Chat:

Tool NameDescriptionParameters
gemini_send_messageSend a text message and wait for the reply to complete, returning Gemini's response text directlymessage, timeout (default 120000ms)

Image Operations:

Tool NameDescriptionParameters
gemini_upload_imagesUpload images to the input box (only upload, does not send; can be paired with send_message)images (array of paths)
gemini_get_imagesGet metadata of all loaded images in the sessionNone
gemini_extract_imageExtract the base64 of a specified image and save it locallyimageUrl (obtained from get_images)
gemini_download_full_size_imageDownload a full-size high-res image; defaults to the latest image, index can be specifiedindex (optional, 0-based, oldest to newest)
gemini_share_latest_imageCreate a public share link for an image and return it directly; defaults to the latest imageindex (optional), timeout, copyToClipboard, closeDialog

Text Response Extraction:

Tool NameDescriptionParameters
gemini_get_all_text_responsesGet all text responses in the session (text only, no images)None
gemini_get_latest_text_responseGet the latest text responseNone

Login Status:

Tool NameDescriptionParameters
gemini_check_loginCheck if logged in to a Google accountNone

Page Navigation:

Tool NameDescriptionParameters
gemini_navigate_toOpen a specified Gemini page URL (e.g., history session link); only gemini.google.com domain is allowedurl (target URL), timeout (default 30000ms)

Diagnostics & Recovery:

Tool NameDescriptionParameters
gemini_probeProbe the status of various page elements (input box, buttons, model, etc.)None
gemini_reload_pageRefresh the page (use when stuck or behaving abnormally)timeout (default 30000ms)
gemini_browser_infoGet browser connection info (CDP port, wsEndpoint, etc.)None

Typical Usage

Quick Image Generation (All-in-One):

  1. Call gemini_generate_image with a prompt → returns a local image path

Image Generation with Share Link:

  1. Call gemini_generate_image to generate the image
  2. Call gemini_share_latest_image to return a public link

Flexible Combination (Fine-Grained Control):

  1. gemini_new_chat — create a new session
  2. gemini_switch_model → pro — switch to a high-quality model
  3. gemini_upload_images — upload reference images
  4. gemini_send_message — send a description
  5. gemini_get_images → gemini_extract_image — get and save the image

Troubleshooting:

  1. gemini_probe — check if page elements are in place
  2. gemini_reload_page — refresh if the page is stuck
  3. gemini_browser_info — get CDP info to connect and debug manually

MCP Client Configuration

{
  "mcpServers": {
    "gemini": {
      "command": "node",
      "args": ["<project_absolute_path>/src/mcp-server.js"]
    }
  }
}

You can also start manually with npm run mcp.

Error Handling

The tools already include retry logic. If they still fail, the return value with isError: true and an error message will explain the cause:

  • Generation timeout — Suggest the user simplify the prompt and retry
  • Daemon not started — The tool will try to start it automatically; if it still fails, run npm run daemon manually
  • Page anomaly — Use gemini_browser_info to inspect the browser state

References

  • Detailed execution and fallback: references/gemini-flow.md
  • Keywords and routing: references/intent-routing.md

相关技能