A Claude Code skill that teaches Claude to delegate expensive work — web search, large reads, long writes, bulk analysis — to Google's Gemini CLI as a worker subagent.
Claude stays the orchestrator: planning, deciding, and verifying. Gemini runs in its own context window, burns its own tokens, and returns a short answer. You get the combined intelligence of both models while keeping Claude's context lean.
Why Gemini? Gemini CLI gives you a local agent with its own tool use, code execution, and web access — all running in its own context. Delegating heavy work to Gemini means Claude's context stays focused on orchestration while Gemini handles the grunt work in parallel.
- Adaptive approval mode — defaults to
--approval-mode auto_edit(workspace-write), automatically escalates to full access when the task needs network or cross-workspace access. No approval prompts — Claude announces the choice in one line and proceeds. - Thin-forwarder contract — Gemini's stdout is the authoritative return. No Claude-side freelancing, no phantom-answer drift.
- Smart stderr logging — captures Gemini's thinking stream to
/tmp/gemini-<rand>.loginstead of/dev/null, so the happy path stays clean but failures are fully debuggable. - Reasoning effort by task class — audits and security reviews get
high, normal edits use the default. No extra config. - Resume-first pattern — follow-ups reuse Gemini's prior session state via
gemini --resume latest, avoiding redundant context re-loading. - Parallel batch dispatch — independent subtasks fire in parallel via Claude Code's background task system.
- Background lifecycle — long runs go background (
run_in_background: true), poll withTaskOutput, cancel withTaskStop. - Structured outcome classification — every result is classified as
success/partial/errorand handled accordingly. No silent retries. - Multi-modal personas — 5 pre-written persona templates (
reviewer,debugger,auditor,researcher,refactorer), each with its own sandbox/effort defaults and explicit return-format contract. Drop-in your own in the same format. - Zero-dep helper scripts —
scripts/doctor.shfor health checks,scripts/gemini-dispatch.shfor direct CLI use,scripts/sync-skill.shfor maintainers.
- Claude Code (CLI, desktop app, or IDE extension)
- Gemini CLI — Google's
geminicommand-line agent. Install via npm:npm install -g @anthropic-ai/gemini-cli gemini auth # first-time auth with Google account - A bash-compatible shell:
- macOS, Linux: native
- Windows: git-bash (comes with Git for Windows) or WSL
That's it. No Node dependencies for the skill itself, no config files, no MCP servers.
Pick one:
git clone https://github.com/dwgx/claude-gemini-subagent.git
cp -r claude-gemini-subagent/skills/gemini-subagent ~/.claude/skills/That's it. Claude Code auto-discovers skills under ~/.claude/skills/.
If your Claude Code supports marketplace plugins:
/plugin install https://github.com/dwgx/claude-gemini-subagentOr add this repo as a marketplace and install normally.
mkdir -p ~/.claude/skills/gemini-subagent && \
curl -fsSL https://raw.githubusercontent.com/dwgx/claude-gemini-subagent/main/skills/gemini-subagent/SKILL.md \
-o ~/.claude/skills/gemini-subagent/SKILL.mdDetailed platform-specific instructions in INSTALL.md.
Once installed, just talk to Claude normally. The skill self-triggers on phrases like:
- "丟給 gemini 查一下 bun 最新版本"
- "丟給 gemini 掃一下這個 repo 裡的 TODO"
- "delegate this audit to gemini"
- "gemini 幫我分析一下這個長 log"
- "I'm stuck — ask gemini for a fresh pass"
Claude will announce the dispatch in one line (including which approval mode it picked and why), run gemini, and summarize the result. You never see the raw stdout unless you ask.
Tell Claude to use a specific persona for more structured output:
用 gemini 的 auditor persona 審計 src/api/auth/
Dispatch gemini in debugger mode — test_payment.py::test_refund is failing
See personas/ for all available modes, or write your own (it's just markdown with a {{TASK}} placeholder).
./scripts/gemini-dispatch.sh --persona researcher \
"What's the current stable version of Bun as of today?"See examples/sample-dispatches.md for 8 real dispatch patterns you can copy.
./scripts/doctor.shValidates every moving part — Gemini CLI presence and version, flag support, shell environment, skill install location. Run this first if anything seems off.
Five principles, stolen from the best parts of five other projects:
- Thin forwarder — one call in, stdout out. No freelancing.
- Adaptive escalation (our own) — default low-privilege, escalate automatically, announce the choice. No prompts.
- Stderr to temp log, not /dev/null —
filename=$(openssl rand -hex 4); gemini ... 2>>"/tmp/gemini-${filename}.log". Clean happy path, full debug on failure. - Structured outcome classification —
success/partial/error, each with a handling rule. - Resume-first — follow-ups reuse session state via
gemini --resume latest, never paying to reload context.
- Not a replacement for Read/Edit on small, known targets. Direct tools are cheaper for tiny ops. This skill only earns its keep when the alternative would cost >3k Claude tokens.
- Not a way to offload thinking. Claude still owns planning, decisions, and judgment. Gemini is a worker, not a co-pilot.
- Not a silent fallback. Every dispatch is announced so you can course-correct.
- Not a queue system. For heavy async lifecycle (multiple long jobs, status polling), use dedicated task runner tools — they complement this skill.
| Symptom | Likely cause | Fix |
|---|---|---|
gemini: command not found |
Gemini CLI not installed or not on PATH | npm install -g @anthropic-ai/gemini-cli, then restart your terminal |
operation not permitted / approval mode denial |
Task needs higher approval mode | Skill should auto-escalate; if it didn't, check the task description matched an escalation trigger |
network unreachable |
Approval mode restricting network | Escalate to full access (skill does this automatically for network tasks) |
| Skill doesn't trigger when expected | Description phrasing didn't match | Say "丟給 gemini" or "delegate to gemini" explicitly; phrasing matters for skill triggering |
Still stuck? Open an issue.
This skill builds on the design patterns established by the Claude-Codex subagent ecosystem and adapts them for the Gemini CLI:
- Thin-forwarder contract pattern
- Structured outcome classification
- Resume-first follow-up pattern
- File-based persona registry
- Stderr temp-log pattern for debugging
MIT — see LICENSE. LICENSE).