feat(skills): add AGY — Google Gemini CLI second-opinion router

Sibling of the grok skill: routes text/verify/review (+ review-files,
review-diff, raw) to the official Google Gemini CLI (gemini, npm global,
v0.45.1) for an independent second model. ask-gemini.sh mirrors ask-grok.sh
(identity-aware gating, binary auto-locate, cygpath hardening, prompt-file
inputs, clean stdout/stderr separation, JSON .response extraction). review
modes copy targets into a temp dir + --include-directories to bypass
Gemini's gitignore/workspace sandbox. verify/review pinned to
gemini-3.1-pro-preview (GEMINI_MODEL overridable). migrate-identity.sh
auto-detects gemini and writes a per-machine identity.json gemini block.
Auth: Google OAuth (no key). Fleet Gemini host: GURU-5070.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-05 06:44:10 -07:00
parent a87cb66b32
commit 2cd0c3ddd0
3 changed files with 434 additions and 0 deletions

128
.claude/skills/agy/SKILL.md Normal file
View File

@@ -0,0 +1,128 @@
---
name: agy
description: >
Route a task to the official Google Gemini CLI for an independent second
model — a sibling of the `grok` second-opinion router. Use for: an
independent, different-vendor SECOND OPINION or adversarial VERIFICATION of a
Claude finding/design before acting on it, a Gemini code REVIEW of a file /
set of files / git diff, and one-shot Gemini TEXT answers. Invoke on:
"ask gemini", "gemini verify", "second opinion from gemini", "gemini review",
"agy ...". Gemini is an independent second model (and Google-ecosystem reach),
NOT a replacement for Claude's own codebase work.
---
# AGY — Gemini capability router
Claude shells out to the locally-installed **Google Gemini CLI** (`gemini`, npm
global, v0.45.1) for a genuinely independent, different-vendor second model.
AGY is the sibling of [`grok`](../grok/SKILL.md): both are second-opinion /
review routers. Use whichever you want a second model from (or both, to triangulate).
Verified working on this machine (2026-06-05): text, verify, review (single
file / file set / git diff).
**Auth:** Gemini uses **Google login (OAuth)****no API key**. Creds live at
`~/.gemini/oauth_creds.json`. If calls fail with an auth error, run `gemini`
interactively once and choose **"Login with Google"**, then retry.
## The wrapper
```
bash "$CLAUDETOOLS_ROOT/.claude/skills/agy/scripts/ask-gemini.sh" <mode> ...
```
| Mode | Usage | What it does |
|------|-------|--------------|
| `text` | `ask-gemini.sh text "<prompt>"` or `text --prompt-file <path>` | One-shot text answer from an independent model. `--prompt-file` for long content (review/summarize a doc). Default model routing. |
| `verify` | `ask-gemini.sh verify "<claim/finding>"` or `verify --prompt-file <path>` | Adversarial second opinion — Gemini tries to REFUTE / find gaps, returns a verdict + reasons. Pinned to the strong model. |
| `review` | `ask-gemini.sh review <file-path> ["<instructions>"]` | Gemini reads the file itself (its `read_file` tool, read-only `plan` mode) and reviews it. Accepts absolute or repo-relative paths, and paths with spaces. Works even on gitignored files. |
| `review-files` | `ask-gemini.sh review-files [-i "<instr>"] <f1> [f2 …]` | Review a **set** of files together (cross-file consistency, multi-file change). Paths absolute or repo-relative; spaces OK. No code passed as a shell arg. |
| `review-diff` | `ask-gemini.sh review-diff [-C <repo-dir>] [-i "<instr>"] <gitref> [-- <pathspec>]` | Review a **git diff** (`git diff <gitref>` from `<repo-dir>`; default repo root, use `-C` for a submodule e.g. `-C projects/msp-tools/guru-rmm`). Diff goes via the prompt file; Gemini can `read_file` changed files for full context. |
| `raw` | `ask-gemini.sh raw <gemini args...>` | Escape hatch — passes args straight to `gemini`. |
The script runs Gemini headless with `-o json`, extracts the answer from
`.response` (parsing from the first `{` so the CLI's cosmetic warning lines are
ignored), and keeps stderr separate from the JSON so 429-backoff / warning noise
never corrupts the parse.
### Model
- `text` uses Gemini's **default routing** (currently a flash-tier model) — fast, cheap.
- `verify` / `review*` pin a **strong** model — `gemini-3.1-pro-preview` (verified
available on this account 2026-06-05; the CLI's own pro tier).
- Override either with `GEMINI_MODEL=<id>` (e.g. `GEMINI_MODEL=gemini-2.5-pro`).
## Machine availability (fleet)
AGY is **per-machine** — the skill syncs fleet-wide but the `gemini` binary does
not. Availability is gated by `identity.json` (per-machine, gitignored):
```json
"gemini": { "installed": true,
"binary": "C:/Users/guru/AppData/Roaming/npm/gemini",
"auth": "oauth", "is_fleet_host": true,
"capabilities": ["text","verify","review"] }
```
- If `gemini.installed` is `false` (or the block is absent), `ask-gemini.sh` exits
**3** with routing guidance instead of failing obscurely. Claude on such a
machine should NOT attempt local Gemini.
- **Current fleet Gemini host: `GURU-5070`** — the only machine with the Gemini
CLI installed and Google-OAuth'd right now. When others get it, install
`@google/gemini-cli`, run `gemini` once to log in with Google, then set their
`identity.json` `gemini` block (and update this line).
**Remote routing (NOT yet wired):** a non-host machine cannot run Gemini locally.
To fulfill an AGY request from elsewhere, route it to the host (`GURU-5070`) —
same pending channels as Grok (GuruRMM agent exec, a relay, or a coord-API job
queue). Until that's built, AGY requests originate on the host machine.
## When to route to Gemini (AGY)
- **Independent verification** — a genuinely different vendor/model to red-team a
Claude finding or design before acting on it. (`verify`)
- **Second-model code review** — have Gemini read and critique a file, a set of
files, or a diff independently of Claude. (`review`, `review-files`, `review-diff`)
- **Diverse drafts / second opinion** — alternative phrasing or approach to
compare. (`text`)
- **Google-ecosystem reach** — when a Google-side model/behavior is specifically
wanted as the comparison point.
AGY and [GROK](../grok/SKILL.md) are sibling second-opinion routers. Pick one, or
run both and compare — disagreement between them is a strong signal to slow down.
## When NOT to
- Pure classify / extract / summarize → cheaper via Tier-0 Ollama (`.claude/OLLAMA.md`).
- Editing this repo's code → Claude's own agents own the codebase work. Gemini's
`review*` modes are read-only (`--approval-mode plan`) by design; do not give
Gemini write access to this repo.
- Image / video generation → that's GROK's lane (`grok image` / `grok video`),
not Gemini here.
- **Never** delegate unsupervised destructive / production actions to Gemini.
Always review Gemini output before acting on it — like Grok, it can over-claim.
## Safety / operational notes
- `--skip-trust` is REQUIRED for headless runs (the CWD isn't a Gemini "trusted
folder"). Equivalent env: `GEMINI_CLI_TRUST_WORKSPACE=true`. The wrapper passes it.
- `review*` runs under `--approval-mode plan` (read-only): Gemini can read files
but cannot modify anything. Do not change this to `auto_edit`/`yolo`.
- Gemini's `read_file` honors `.gitignore` **and** a workspace sandbox (only files
inside the workspace are readable). The wrapper sidesteps both by copying each
review target into a temp dir added via `--include-directories` — so review
works for tracked, gitignored, and spaced-path files alike.
- Prompts are passed via `-p "$(cat <prompt-file>)"` built from a temp file, not
inline shell args (avoids quote hell with long/structured content).
- stdin is always closed (`</dev/null`) so `-p` never hangs waiting on stdin.
- stdout carries two cosmetic warning lines ("True color (24-bit) support not
detected", "Ripgrep is not available...") before output; JSON extraction from
the first `{` ignores them. A transient `429 No capacity` backoff may appear on
**stderr** and self-recovers — it does not affect the parsed answer.
## Reference
- Binary: npm global `gemini` (`C:/Users/guru/AppData/Roaming/npm/gemini` on the
host; the npm global dir is on PATH). The wrapper auto-locates it or honors `GEMINI=`.
- Version 0.45.1. Auth: Google OAuth (`~/.gemini/oauth_creds.json`), no API key.
- Headless contract: `gemini -p "<prompt>" -o json --skip-trust </dev/null`
`{session_id, response, stats}`; answer is `.response`.
- Sibling router: [`grok`](../grok/SKILL.md) (image/video/live-data + second opinion).