Claude Driving Gemini CLI with Explicit Verification

Claude designs the approach, Gemini CLI or Antigravity CLI executes, and explicit verification steps close the loop. Split reasoning from execution across tools.

October 20, 2026
claudegeminiorchestrationcross-tool

Claude Driving Gemini CLI with Explicit Verification

Claude Driving Gemini with Explicit Verification

Claude Code has strong reasoning and extended thinking, but no built-in autonomous verification loop. Gemini CLI and Antigravity CLI bring a 1M-token context window and cheaper execution, but weaker instruction following. Neither tool ships a feature called the "Ralph loop."

This pattern uses Claude to design the approach and Gemini to execute it, with verification written explicitly into the prompt and checked by Claude afterward. Claude is the conductor. Gemini does the work.

Overview

The pattern splits a task into two roles:

  1. Claude Code — Designs the approach, writes the prompt, invokes agy (or gemini) via bash, reviews the output, iterates
  2. Gemini CLI / agy — Receives the task, reads the relevant files, makes changes, and reports results

The key insight: Claude excels at designing a task and reviewing the output. Gemini excels at executing large-context tasks. Verification is a prompt requirement plus a follow-up check, not an automatic product loop.

Key Features

  • Combines Claude's reasoning quality with Gemini's 1M-token context
  • Claude writes targeted prompts that ask Gemini to read, plan, execute, and report
  • A separate verification pass catches errors Claude might miss on review
  • Execution is cheaper than running everything through Claude
  • Works for code review, refactoring, research, and documentation

Installation & Setup

Prerequisites

Both tools must be installed and configured:

Claude Code:

npm install -g @anthropic-ai/claude-code
export ANTHROPIC_API_KEY=sk-ant-...

Antigravity CLI (consumer path):

curl -fsSL https://antigravity.google/cli/install.sh | bash
# Binary is 'agy', not 'antigravity'
export GEMINI_API_KEY="your-key"
# Also set "modelProvider": "gemini" in ~/.gemini/antigravity-cli/settings.json

Gemini CLI (enterprise path):

npm install -g @google/gemini-cli
gcloud auth application-default login
export GOOGLE_GENAI_USE_VERTEXAI=true
export GOOGLE_CLOUD_PROJECT="your-project-id"
export GOOGLE_CLOUD_LOCATION="your-location"

For CI/CD, set GOOGLE_APPLICATION_CREDENTIALS to a service account key instead of running the ADC login.

Configuration

No special configuration is needed for the basic pattern. Claude invokes agy (or gemini) via the bash tool. Optionally, add a shortcut in your CLAUDE.md:

## Gemini / Antigravity Delegation

When using Gemini CLI or Antigravity CLI (agy) for sub-tasks:
- Use `agy -p "task"` for headless execution
- Use `--model` with a slug from `agy models`
- Always include `--output-format json` for structured output
- Ask for files read, changes made, and commands run in the response
- Verify the output before integrating it

Available Tools/Resources

ToolRoleStrength
Claude bash toolInvokes Gemini/agy CLIReliable subprocess execution
agy -pHeadless task executionNon-interactive runs
agy --modelSelect modelgemini-3.1-pro-high for complex work, gemini-3.8-flash-high for fast runs
agy --output-formatStructured outputjson for parsing, text for reading
agy --sandboxIsolated executionRequired for untrusted tasks

Configuration Example

Claude task prompt for Gemini/Antigravity

Claude writes a targeted prompt, invokes agy (or Gemini CLI), and reviews:

agy --model gemini-3.1-pro-high --output-format json \
  -p "Analyze the codebase in src/ for performance issues.
      First read the directory structure and dependency manifests.
      Then identify the slowest paths and explain each bottleneck.
      Run the existing benchmark or test command if one exists.
      Report: files read, commands run, findings with file:line references."

When to use

  • Large codebase analysis (leverage Gemini's 1M context)
  • Tasks where a second model provides a useful quality gate
  • When you want an explicit verification step as a second check
  • When Claude's API costs matter

Common Use Cases

Codebase Analysis

Gemini's 1M context window reads the entire project. Claude designs the analysis framework and reviews the findings.

Multi-Step Refactoring

Claude plans the refactoring strategy across files. Gemini executes each step and reports what changed; Claude checks the diff and runs the tests.

Research & Documentation

Claude designs the documentation structure. Gemini generates the initial draft from the full codebase. Claude reviews and refines.

Cross-Language Translation

Claude designs the translation strategy (idiomatic equivalents, patterns to preserve). Gemini handles the volume of the translation; Claude reviews for semantic drift.

Best Practices

Security Considerations

  • Antigravity CLI runs with the same permissions as the user unless you pass --sandbox. Use it for untrusted tasks.
  • When reviewing Gemini output, Claude should verify before integrating. Prompt-level verification catches some errors but not all.
  • Never pipe API keys or secrets into Gemini prompts.

Performance Optimization

  • Use gemini-3.8-flash-high for fast iterations, escalate to gemini-3.1-pro-high when quality matters
  • JSON output format (--output-format json) makes parsing the result in Claude's review step easier
  • If a run stalls, Claude can kill the process and re-prompt with a narrower scope

Troubleshooting

Gemini doesn't respond or times out

Set a timeout on the bash invocation in Claude:

timeout 120 agy -p "task description"

The task goes in circles

Without a built-in loop, a model can still repeat failed edits. Claude should detect repetition and re-prompt with explicit exit conditions: what counts as done, which tests must pass, and what to report if blocked.

Output format mismatch

When using --output-format json, the model may still wrap output in markdown code fences. Claude should strip these before parsing.

Sources