CommunityCoding & Developmentgithub.com

WJZ-P/gemini-skill

Interact with Gemini through its official website (gemini.google.com) to perform image generation, conversations, and more. Triggers on keywords like 'generate image', 'draw', 'nano banana'. Operates via a three-tier priority system: MCP tools first, skill scripts second, and browser connection last (requires user approval). Starting an external browser to access Gemini is strictly prohibited.

What is gemini-skill?

This AI agent skill, named 'WJZ-P/gemini-skill', provides a structured and automated interface to Google's Gemini web application (gemini.google.com). It is designed for AI agents or developer tools that need to programmatically perform tasks such as generating images, managing chat sessions, and extracting text responses from Gemini, all without manual browser interaction. The skill operates on a strict three-tier execution priority: first, it attempts to use built-in MCP tools for maximum efficiency and reliability; second, it falls back to running scripts provided with the skill; and third, it can connect to a managed browser instance only after explicit user consent. Crucially, the agent is forbidden from launching its own browser to access Gemini, preventing session conflicts. The skill exposes a comprehensive set of MCP tools for image generation, session management, model switching (pro, quick, think), image upload/download, and diagnostics. It supports long-running operations (60-180 seconds) with synchronous blocking calls and automatic progress reporting. This skill is ideal for developers building workflows that require reliable, automated access to Gemini's capabilities, such as generating marketing visuals, prototyping designs, or iterating on creative prompts within an AI-assisted coding environment. The provided markdown documentation includes clear rules for progress synchronization, failure handling, and MCP client configuration.

Works with~Claude Code~Codex CLI~Cursor✓Gemini CLI
npx skills add WJZ-P/gemini-skill

Installed? Explore more Coding & Development skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

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

Related Skills