---
name: gemini-sub-agent-34f09ee86acd
description: >
  Use Google Gemini as a free sub-agent via a Google One / Gemini Advanced subscription (no API key or API credits needed).
  Use when: (1) delegating tasks that would normally cost Sonnet/Haiku credits, (2) processing large documents or long-context tasks (1M token window),
  (3) running agentic coding tasks autonomously, (4) any text analysis, summarization, or Q&A task.
  Replaces paid cloud models for medium-complexity tasks.
  NOT for: tasks needing OpenClaw-native tools (web_search, sessions_spawn, Telegram), real-time data, or tasks requiring OpenClaw context.
---

# gemini-sub-agent

Use Google Gemini (via subscription, $0 API cost) as a sub-agent inside OpenClaw workflows.

## Setup

Run once on a fresh machine:
```bash
bash skills/gemini-sub-agent/scripts/setup.sh
```

Then authenticate (headless VPS flow):
1. On VPS: `gcloud auth application-default login --no-browser` → copy the `--remote-bootstrap` URL
2. On laptop: `gcloud auth application-default login --remote-bootstrap="<URL>"` → copy the `localhost:8085` output
3. Paste `localhost:8085` output back into VPS prompt
4. Complete Gemini CLI OAuth: `GOOGLE_GENAI_USE_GCA=true gemini -p "hello"` → paste auth code

Credentials are cached indefinitely and auto-refresh.

## Available Models

| Model | Use for |
|---|---|
| `gemini-3.1-pro-preview` | **Default** — latest flagship, best reasoning |
| `gemini-2.5-pro` | Stable coding tasks, multi-file edits |
| `gemini-3-flash-preview` | Fast summaries, quick Q&A |
| `gemini-3-pro-preview` | Previous gen Pro, reliable fallback |
| `gemini-2.5-flash` | Lightweight fallback |

## Usage Patterns

### 1. Simple text task (exec)
```bash
ask-gemini "your prompt here"
ask-gemini -m gemini-2.5-pro "your prompt"
```

### 2. Pipe large content (long-context)
```bash
cat large_file.txt | ask-gemini "summarize this in 5 bullets"
cat report.md | ask-gemini "extract all action items"
```

### 3. Agentic coding (replaces Swift/Sonnet for 30-200 line tasks)
```bash
cd /path/to/project
GOOGLE_GENAI_USE_GCA=true gemini -m gemini-2.5-pro -y -p "write a script that..."
```
`-y` = yolo mode (auto-approves all file writes and shell commands). Gemini reads/writes files autonomously.

### 4. Pipe files directly into agentic session
```bash
cat existing_script.py | GOOGLE_GENAI_USE_GCA=true gemini -m gemini-2.5-pro -y -p "refactor this to add error handling"
```

## Routing Rules (when to use Gemini vs others)

| Task | Use |
|---|---|
| Text, analysis, summarization | `ask-gemini` |
| Medium coding (30–200 lines) | Gemini agentic (`-y`) instead of Swift/Sonnet |
| Large file / long-context | `ask-gemini` (1M token window) |
| Web search / research | Research agent (Grok) — Gemini has no web access |
| Multi-agent orchestration | OpenClaw native (sessions_spawn) |
| Complex architecture / debugging | Codex (Opus) — escalate if Gemini fails twice |

## Escalation

If Gemini returns wrong output twice on the same task → escalate to Swift (Sonnet) or Codex (Opus).
Log the failure in `failures/hot_antipatterns.md` with the task type.

## Scripts

- `scripts/setup.sh` — Full install: gemini-cli + gcloud + ask-gemini wrapper
- `scripts/ask-gemini` — The wrapper script itself (copy to `/usr/local/bin/`)


---
Source attribution: modbender
Original project: https://github.com/modbender/skill-library-mcp/blob/d9c8fe903b5b4e82237dbe8d0df8567783022e18/data/gemini-sub-agent/SKILL.md
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Mega AI Hub.

## Upstream license notice

MIT License

Copyright (c) 2025 skill-library-mcp contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Mega AI Hub resource metadata

Creator / publisher: modbender
Original project: https://github.com/modbender/skill-library-mcp/blob/d9c8fe903b5b4e82237dbe8d0df8567783022e18/data/gemini-sub-agent/SKILL.md
Attribution basis: Source repository record

Fields of work: Data & Analytics, Development & Engineering
Roles: Backend Developer, Data Scientist, ML / AI Engineer
Specialties: API, Backend
Tools: Google Gemini
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 3feee7bd295f828aaf604648e7785a3d86c0c805b7d19322ffd3b0c1d4af68d2
