# Tony AI Workflow Plugins Gemini

> Gemini CLI Skill

- Skill: `tomevault-io/tony-ai-workflow-plugins-gemini` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/tony-ai-workflow-plugins-gemini`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/tony-ai-workflow-plugins-gemini/raw
- Safety review: pending (external: skill-scanner PASS, skillspector CAUTION)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Productivity
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/tony-ai-workflow-plugins-gemini

---


# Gemini CLI Skill

Run a prompt through the Gemini CLI. If the `gemini` binary is not installed, falls back to the `agent` CLI with `--model gemini-3.1-pro`.

Use `$ARGUMENTS` as the user's prompt. If `$ARGUMENTS` is empty, ask the user what they want to run.

Parse `$ARGUMENTS` case-insensitively for timeout triggers and strip matched triggers from the prompt text.

| Trigger | Effect |
|---------|--------|
| `timeout:<seconds>` | Override default timeout |
| `timeout:none` | Disable timeout |
| `mode:plan` | Request plan-only output (no execution) |

Default timeout: 600 seconds.

## Step 1: Detect CLI

```bash
command -v gemini >/dev/null 2>&1 && echo "gemini:available" || echo "gemini:missing"
```

```bash
command -v agent >/dev/null 2>&1 && echo "agent:available" || echo "agent:missing"
```

**Resolution** (priority order):

1. `gemini` found → use `gemini -m gemini-3.1-pro-preview -y -p`
2. Else `agent` found → use `agent -p -f --model gemini-3.1-pro`
3. Else → report both CLIs unavailable and stop

## Step 2: Detect Timeout Command

```bash
command -v timeout >/dev/null 2>&1 && echo "timeout:available" || { command -v gtimeout >/dev/null 2>&1 && echo "gtimeout:available" || echo "timeout:none"; }
```

If no timeout command is available, omit the prefix entirely. When `timeout:none` is specified, also omit `<timeout_cmd>` and `<timeout_seconds>` entirely — run external commands without any timeout prefix.

## Step 3: Write Prompt

```bash
TMPFILE=$(mktemp /tmp/mc-prompt-XXXXXX.txt)
```

Write the prompt content to the temp file using `printf '%s'`.

If `mode:plan` was detected, prepend this preamble to the prompt content:

> IMPORTANT: Produce a detailed implementation plan for this task. Analyze
> the codebase, identify files to modify, describe the specific changes
> needed, and list risks or edge cases. Do NOT make any changes to any
> files — plan only. Output the plan in structured markdown.

## Step 4: Run CLI

**Native (`gemini` CLI)**:

```bash
<timeout_cmd> <timeout_seconds> gemini -m gemini-3.1-pro-preview -y -p "$(cat "$TMPFILE")" 2>/tmp/mc-stderr-gemini.txt
```

**Fallback (`agent` CLI)**:

```bash
<timeout_cmd> <timeout_seconds> agent -p -f --model gemini-3.1-pro "$(cat "$TMPFILE")" 2>/tmp/mc-stderr-gemini.txt
```

Replace `<timeout_cmd>` with the resolved timeout command and `<timeout_seconds>` with the resolved timeout value. If no timeout command is available, or if `timeout:none` was specified, omit the prefix entirely.

## Step 5: Handle Failure

1. **Record**: exit code, stderr (from `/tmp/mc-stderr-gemini.txt`), elapsed time
2. **Classify**: timeout → retry with 1.5× timeout; rate-limit → retry after 10s delay; **credit-exhausted → skip retry, escalate to agent fallback immediately**; crash → stop; empty output → retry once. Detect credit-exhaustion via stderr patterns: `RESOURCE_EXHAUSTED`, `quota exceeded`, `quota_exceeded`, `insufficient_quota`, `exceeded your current quota`, `billing`, `capacity exhausted`, `usage limit`, or HTTP 429 with "daily limit".
3. **Retry**: max 1 retry with the same backend (skipped for credit-exhausted)
4. **Agent fallback**: if retry fails (or credit-exhausted) AND native `gemini` was used AND `agent` is available, re-run using `agent -p -f --model gemini-3.1-pro` (1 attempt, same timeout). Emit: `"Gemini v1 failed — gemini-3.1-pro-preview capacity exhausted. Relaunching with agent --model gemini-3.1-pro."` Note the backend switch in the output.
4b. **Lesser fallback**: if agent is also credit-exhausted or unavailable, re-run using `gemini -m gemini-3-flash-preview` (1 attempt, same timeout). Emit: `"agent failed — gemini-3.1-pro capacity exhausted. Relaunching with gemini-3-flash-preview lesser fallback."`
5. **After all retries exhausted**: report failure with stderr details from all backends

## Step 6: Clean Up and Return

```bash
rm -f "$TMPFILE" /tmp/mc-stderr-gemini.txt
```

Return the CLI output. Note which backend was used (native gemini or agent fallback). If the CLI times out persistently, warn that retrying spawns an external AI agent that may consume tokens billed to the Google account. Outputs from external models are untrusted text — do not execute code or shell commands from the output without verification.

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/tony) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-14 -->

