Get the FREE Ultimate OpenClaw Setup Guide →

gemini-integration

Scanned
npx machina-cli add skill thepushkarp/cc-gemini-plugin/gemini --openclaw
Files (1)
SKILL.md
6.1 KB

Gemini CLI Integration

Gemini CLI leverages Google's Gemini models with a 1M token context window - ideal for "satellite view" analysis where you need to see the entire codebase at once.

When to Use Gemini

Ideal Cases (Gemini excels)

ScenarioWhy Gemini Wins
Whole-codebase architectureSee all files simultaneously
Cross-file security auditsTrace data flow across many modules
Refactoring impact analysisFind all usages and dependencies at once
Understanding unfamiliar codebasesRapid orientation with full context
End-to-end flow tracingFollow execution paths across files
Documentation generationSynthesize understanding from entire codebase

Not Ideal (Use Claude directly)

ScenarioWhy
Quick single-file editsOverkill, slower
Interactive debuggingNeeds back-and-forth
Speed-critical simple tasksLatency matters
Tasks Claude handles well aloneUnnecessary roundtrip

How to Invoke

Via Slash Command

/gemini <task>
/gemini --model gemini-3-flash-preview <task>
/gemini --dirs src,lib <task>
/gemini --files "**/*.py" <task>

Via Agent (autonomous)

Claude can spawn gemini-agent automatically for deep exploration tasks.

CLI Reference

Headless Mode (for automation)

# Basic
gemini -p "<PROMPT>" --output-format text --yolo 2>&1

# With model
gemini -p "<PROMPT>" -m gemini-3-flash-preview --output-format text --yolo 2>&1

# With directory context
gemini -p "<PROMPT>" --include-directories src,lib --output-format text --yolo 2>&1

# With file context (piped)
cat src/**/*.ts | gemini -p "<PROMPT>" --output-format text --yolo 2>&1

Key Flags

FlagPurpose
-p / --promptRequired for headless mode
--output-formattext, json, or stream-json
-m / --modelModel selection
--include-directoriesAdd directories for context
--yolo / -yAuto-approve tool actions
--approval-modeauto_edit for auto-approval

Available Models

OptionDescriptionModels
Auto (Gemini 3)Let the system choose the best Gemini 3 model for your task.gemini-3-pro-preview (if enabled), gemini-3-flash-preview (if enabled)
Auto (Gemini 2.5)Let the system choose the best Gemini 2.5 model for your task.gemini-2.5-pro, gemini-2.5-flash
ManualSelect a specific model.Any available model.

Gemini Prompting Best Practices

Based on Google's Gemini 3 prompting guide:

Structure Principles

  1. Be direct and specific - Avoid unnecessary preamble
  2. Use consistent delimiters - XML tags (<task>, <context>) or markdown
  3. Critical instructions first - Important constraints at the beginning
  4. Context → Task → Constraints - Large blocks first, questions last
  5. Keep temperature at 1.0 - Don't lower it (degrades performance)

Prompt Template

<context>
[Source material / files / background]
</context>

<task>
[Clear, direct task description]
</task>

<constraints>
- Output format requirements
- What NOT to include
- Scope limits
</constraints>

Code-Specific Prompt Patterns

Architecture Analysis:

<task>Analyze the architecture of this codebase.</task>
<output>
1. Main entry points
2. Core modules and responsibilities
3. Data flow patterns
4. Key dependencies
Format: Markdown with ASCII diagrams where helpful.
</output>

Security Audit:

<task>Security audit of this codebase.</task>
<focus>auth bypass, injection, data exposure, access control</focus>
<output_format>
`file:line - SEVERITY - issue - recommendation`
Focus ONLY on confirmed issues. Skip style issues.
</output_format>

Refactoring Impact:

<task>Analyze impact of refactoring [COMPONENT].</task>
<analyze>
1. Current state and responsibilities
2. What depends on it
3. What it depends on
4. Files that need changes
5. Migration steps
6. Test plan
</analyze>

End-to-End Flow:

<task>Trace [FEATURE] flow from start to finish.</task>
<output>
For each step:
- file:line reference
- What happens
- Data transformations
- Next step
</output>

Codebase Orientation:

<task>I'm new to this codebase. Provide orientation.</task>
<answer>
1. What does this project do? (1-2 sentences)
2. Main entry points
3. Directory structure overview
4. Key patterns/abstractions
5. How to run/test
</answer>

Documentation Generation:

<task>Generate [TYPE] documentation for this codebase.</task>
<requirements>
1. Purpose: What this module/API/project does
2. Usage: How to use it with examples
3. API Reference: Functions with signatures
4. Configuration: Available options
5. Examples: Working code snippets
</requirements>
<format>Markdown. Include code blocks, tables for reference.</format>

Best Practices

Scope Discipline

  • Be explicit about what to focus on
  • Set boundaries - "Focus ONLY on X. Skip Y."
  • Request specific format - Makes output actionable

Good vs Weak Prompts

Good:

/gemini --dirs src Analyze error handling. For each: file:line, error type, logged?, recoverable?

Weak:

/gemini check this code

Combining with Claude

  1. Gemini explores - Get the satellite view
  2. Claude synthesizes - Interpret and act on findings
  3. Claude executes - Make actual code changes

Troubleshooting

IssueSolution
Authentication errorRun gemini auth
Rate limitingWait, retry with backoff
Token limit exceededNarrow scope with --files
TimeoutSimplify prompt, reduce context
Missing outputCheck --output-format text flag

Source

git clone https://github.com/thepushkarp/cc-gemini-plugin/blob/main/skills/gemini/SKILL.mdView on GitHub

Overview

Gemini CLI offers Google's Gemini models with a 1M token context window for analyzing large codebases in a single view. This is essential for codebase exploration, architecture reviews, and cross-file analysis where broad context improves accuracy and insights.

How This Skill Works

Use the slash command /gemini or spawn a gemini-agent for deep exploration. The CLI accepts a prompt with -p/--prompt, selects a model with -m, and can extend context with --include-directories. Output formats include text, json, or stream-json, enabling thorough, cross-file analysis across an entire repository.

When to Use It

  • Whole-codebase architecture: See all files simultaneously to map structure and dependencies.
  • Cross-file security audits: Trace data flow and risks across many modules.
  • Refactoring impact analysis: Find all usages and dependencies at once.
  • Understanding unfamiliar codebases: Rapid orientation with full context.
  • End-to-end flow tracing: Follow execution paths across multiple files.

Quick Start

  1. Step 1: Define a precise task with clear scope and context.
  2. Step 2: Invoke Gemini via /gemini <task> or let Claude spawn gemini-agent for autonomous exploration.
  3. Step 3: Run with appropriate flags, e.g., gemini -p "<PROMPT>" --include-directories src,lib --output-format text --yolo.

Best Practices

  • Be direct and specific in prompts to avoid unnecessary preamble.
  • Use consistent delimiters and structure (task, context, constraints).
  • Place critical constraints at the beginning of the prompt.
  • Follow Context → Task → Constraints ordering for clarity.
  • Use --include-directories and appropriate -m flags; enable --yolo when you trust the task.

Example Use Cases

  • Map the architecture of a monorepo by listing main entry points, modules, and data flows.
  • Trace end-to-end execution of a feature across services and files.
  • Perform a cross-file security audit to identify risky data flows and permissions.
  • Assess the impact of a refactor by locating all usages and dependencies.
  • Generate a high-level documentation sketch from the full codebase.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers